1 | initial version |
In matchTemplate functions you can normalized output results
normalize(results , results ,1,0,NORM_MINMAX);
results .convertTo(img, CV_8U, 255);
then you can thresh results image and find connected components :
threshold(img, dst, thresh, 255, THRESH_BINARY);
connectedComponentsWithStats(dst, labels, stats, centroids, 8);
if (centroids.rows < 10)
{
cout << "**********************************************************************************\n";
for (int i = 0; i < centroids.rows; i++)
{
cout << dst.cols - centroids.at<double>(i, 0) << " ";
cout << dst.rows - centroids.at<double>(i, 1) << "\n";
}
cout << "----------------------------------------------------------------------------------\n";
}
A full example is here (colorMatchTemplate)