Template matching for object detection

Before we start with the shape-analysis and feature-analysis algorithms, we are going to learn about an easy-to-use, extremely powerful method of object detection called template matching. Strictly speaking, this algorithm does not fall into the category of algorithms that use any knowledge about the shape of an object, but it uses a previously acquired template image of an object that can be used to extract a template-matching result and consequently objects of known look, size, and orientation. You can use the matchTemplate function in OpenCV to perform a templating-matching operation. Here's an example that demonstrates the complete usage of the matchTemplate function:

Mat object = imread("Object.png"); ...

Get Hands-On Algorithms for Computer Vision now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.