我正在尝试使用一个模板在视频流上执行多个模板,这可能吗? 我尝试使用for循环使代码运行超过1次,但是,当第二个矩形出现时,第一个矩形消失。 以下是我的代码,我正在使用ROS。
$eventsManager->attach('db:beforeQuery', function($event, $connection) {
$profiler->startProfile(statement2sql($connection));
}
$eventsManager->attach('db:afterQuery', function($event, $connection) {
$profiler->stopProfile();
}
答案 0 :(得分:0)
使用阈值和while循环检查图像中的多个模板
while(true)
{
int threshold = 0.9;
double minVal; double maxVal; Point minLoc; Point maxLoc;
Point matchLoc;
minMaxLoc( result, &minVal, &maxVal, &minLoc, &maxLoc, Mat() );
/// For SQDIFF and SQDIFF_NORMED, the best matches are lower values. For all the other methods, the higher the better
if ( match_method == CV_TM_SQDIFF || match_method == CV_TM_SQDIFF_NORMED )
{ matchLoc = minLoc; }
else
{ matchLoc = maxLoc; }
/// Show me what you got
if(maxval >threshold && 0!=matchLoc .x && 0!=matchLoc .y )
{
rectangle( img_display, matchLoc, Point( matchLoc.x + templ.cols , matchLoc.y + templ.rows ), Scalar::all(255), 2, 8, 0 );
rectangle( result, matchLoc, Point( matchLoc.x + templ.cols , matchLoc.y + templ.rows ), Scalar::all(255), 2, 8, 0 );
}
else
{
break;
}
}