我将opencv与python绑定一起使用。我正在尝试使用模板匹配,但它没有完全按照我的需要执行。如果没有与我提供的模板匹配的图像,我不希望它返回匹配项。它似乎总是返回一个匹配的模板是否存在于我提供的图像中。
我看过opencv和Python的文档,似乎没有提到如何设置匹配模板的最小阈值。我需要它相对严格时,比较模板和图像。
image = LoadImage("c:/image.png")
template = LoadImage("c:/image-crop2.png")
W,H = GetSize(image)
w,h = GetSize(template)
width = W - w + 1
height = H - h + 1
result = CreateImage((width, height), 32, 1)
MatchTemplate(image, template, result, CV_TM_CCORR)
(min_x, max_y, minloc, maxloc) = MinMaxLoc(result)
(x, y) = minloc
print result
目前没有回答
相关问题 更多 >
编程相关推荐