templatematch: Match rectangle grows redder with increased match certainty

This is useful for debugging your matches as it indicates how certain the
match was in addition to its position.
This commit is contained in:
William Manley 2012-06-20 15:22:52 +01:00 committed by Thiago Santos
parent b608767288
commit 88cb33a1dc

View file

@ -370,13 +370,23 @@ gst_template_match_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
if (filter->display) {
CvPoint corner = best_pos;
CvScalar color;
if (filter->method == CV_TM_SQDIFF_NORMED
|| filter->method == CV_TM_CCORR_NORMED
|| filter->method == CV_TM_CCOEFF_NORMED) {
/* Yellow growing redder as match certainty approaches 1.0. This can
only be applied with method == *_NORMED as the other match methods
aren't normalized to be in range 0.0 - 1.0 */
color = CV_RGB (255, 255 - pow (255, best_res), 32);
} else {
color = CV_RGB (255, 32, 32);
}
buf = gst_buffer_make_writable (buf);
corner.x += filter->cvTemplateImage->width;
corner.y += filter->cvTemplateImage->height;
cvRectangle (filter->cvImage, best_pos, corner, CV_RGB (255, 32, 32), 3,
8, 0);
cvRectangle (filter->cvImage, best_pos, corner, color, 3, 8, 0);
}
}