Where's Waldo? with Python and OpenCV
Upcoming SlideShare
Loading in...5
×
 

Where's Waldo? with Python and OpenCV

on

  • 1,431 views

SF PyLadies lightning talk on how to use OpenCV and cv2 to play Where's Waldo

SF PyLadies lightning talk on how to use OpenCV and cv2 to play Where's Waldo

Statistics

Views

Total Views
1,431
Views on SlideShare
1,119
Embed Views
312

Actions

Likes
1
Downloads
11
Comments
0

3 Embeds 312

http://annaschneider.org 309
https://twitter.com 2
http://www.linkedin.com 1

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Where's Waldo? with Python and OpenCV Where's Waldo? with Python and OpenCV Presentation Transcript

  • Wheres Waldo?with Python and OpenCVAnna Schneider@windupannaSF PyLadies Lightning Talk25 June 2013
  • OpenCV: computer vision in C++video processing, face recognition, and more!http://opencv.org/http://sourceforge.net/projects/opencvlibrary/>>> import cv2
  • Lets get started>>> pyladies = cv2.imread(pyladies.png)>>> cv2.imshow("pyladies", # titlepyladies) # image
  • Images are NumPy arrays!>>> pyladies.shape(638, 1499, 3)# (height, width, n_colors)but with weird conventions>>> pyladies[300,300]array([ 57, 2, 237], dtype=uint8)# (blue, green, red)
  • How would you solve it?>>> waldo = cv2.imread(waldo_face.png)>>> scene = cv2.imread(waldo_scene.png)
  • Matchmaker, matchmaker>>> pyplot.imshow(scores)>>> scores = cv2.matchTemplate(scene,# bigwaldo, # smallcv2.TM_CCORR_NORMED) # method
  • Let the best score win>>> minmaxs = cv2.minMaxLoc(scores)>>> min, max, min_pos, max_pos = minmaxs>>> print max, max_pos0.999999880791 (979, 842)# best score upper-left corner
  • Layer it on>>> cv2.rectangle(scene, # imagecorner1, # upper-leftcorner2, # lower-right(0,255,0), # (r,g,b)5) # pixels>>> corner1 = max_pos>>> corner2 = (corner1[0]+waldo.shape[1],corner1[1]+waldo.shape[0])>>> cv2.imshow("Theres Waldo!", scene)
  • Theres Waldo!
  • Thanks, and happy searching!all the code and more:https://gist.github.com/aschn/5861365say hi:@windupannaannarschneider@gmail.com