From the course: OpenCV for Python Developers
Unlock the full course today
Join today to access over 24,400 courses taught by industry experts.
Application of template matching
From the course: OpenCV for Python Developers
Application of template matching
- [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 at zero, meaning they are in gray scale. In this case, we resolved any differences between the color of our original template and the reference image. Next, let's actually display these two by typing cv2.imshow. And then we'll type in Frame, comma, frame. Enter, cv2.imshow. Template, comma, template. Now, let's actually run our template-matching command. We'll type result, equals, cv2.matchTemplate. And then…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.