To understand how template matching works, the use case is applied to detecting faces in an image. Using the template face image in the provided files, this module shows how to use the algorithm to detect faces in either provided images, or even in a live video feed. Patrick explains some of the limitations and workarounds of template matching, including the effect of scaling or rotation compared to a source template object.
- [Instructor] Now we can dive into template matching…as a means to detect features in an image.…As you may recall, template matching works by…sliding a source template image and making a difference…at every possible location against a reference image.…This difference shows us how close…those two images are together and if there are any…close matches between the template and the source frame…it will indicate that area as a very bright spot…in the resulting image.…Note that we have read in both images, here, as zero,…meaning they are in grayscale.…In this case, we resolve any differences…between the color of our original template…and the reference image.…
Next, let's actually display these two…by typing cv2 dot…imgshow…and then we'll type in frame…comma…frame…enter, cv2 dot imgshow…template…comma template.…Now, let's actually run our template matching command.…We'll type result…equals…cv2 dot…match…template…and then we'll pass in the frame…followed by the template,…followed by the cv2…dot…and then in all caps, T-M, underscore,…
AuthorPatrick W. Crawford
- Installing and configuring OpenCV
- Data types and structures
- Image types
- Manipulating pixels
- Scaling and rotating images
- Using video inputs
- Creating custom interfaces
- Object detection
- Face and feature detection
- Template matching
Skill Level Intermediate
Python: Programming Efficientlywith Michele Vallisneri2h 15m Intermediate
NumPy Data Science Essential Trainingwith Charles Kelly3h 54m Intermediate
1. Install and Configure OpenCV
2. Basic Image Operations
3. Object Detection
4. Face and Feature Detection
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.