Object Detection

Overview

// enums

enum cv::TemplateMatchModes;

// global functions

void
cv::matchTemplate(
InputArray image,
InputArray templ,
OutputArray result,
int method,
);


Detailed Documentation

Global Functions

void
cv::matchTemplate(
InputArray image,
InputArray templ,
OutputArray result,
int method,

The function slides through image , compares the overlapped patches of size $$w \times h$$ against templ using the specified method and stores the comparison results in result . Here are the formulae for the available comparison methods ($$I$$ denotes image, $$T$$ template, $$R$$ result ). The summation is done over template and/or the image patch: $$x' = 0...w-1, y' = 0...h-1$$
 image Image where the search is running. It must be 8-bit or 32-bit floating-point. templ Searched template. It must be not greater than the source image and have the same data type. result Map of comparison results. It must be single-channel 32-bit floating-point. If image is $$W \times H$$ and templ is $$w \times h$$, then result is $$(W-w+1) \times (H-h+1)$$. method Parameter specifying the comparison method, see cv::TemplateMatchModes mask Mask of searched template. It must have the same datatype and size with templ. It is not set by default. Currently, only the TM_SQDIFF and TM_CCORR_NORMED methods are supported.