我使用OpenCv查找与参考图像上的模板匹配的区域.当代码找到与模板匹配的区域时,在该区域周围绘制一个矩形,但我想要的是当代码找不到该区域时代码不会绘制任何矩形
码:
IplImage *res;
CvPoint minloc, maxloc;
double minval, maxval;
int img_width, img_height;
int tpl_width, tpl_height;
int res_width, res_height;
NSString *path = [[NSBundle mainBundle] pathForResource:@"reference" ofType:@"jpg"];
reference.image = [UIImage imageWithContentsOfFile:path];
NSString *pathPatron = [[NSBundle mainBundle] pathForResource:@"template" ofType:@"jpg"];
template.image = [UIImage imageWithContentsOfFile:pathPatron];
IplImage *img = [self CreateIplImageFromUIImage:original.image];//
IplImage *tpl = [self CreateIplImageFromUIImage:patron.image];
img_width = img->width;
img_height = img->height;
tpl_width = tpl->width;
tpl_height = tpl->height;
res_width = img_width - tpl_width + 1;
res_height = img_height - tpl_height + 1;
res = cvCreateImage( …
Run Code Online (Sandbox Code Playgroud)