简体   繁体   English

opencv“ cv2.TM_CCORR_NORMED”和“ cv.CV_COMP_BHATTACHARYYA”中matchTemplate()的匹配方法具有相同的度量

[英]The matching methods for matchTemplate() in opencv “ cv2.TM_CCORR_NORMED” and “cv.CV_COMP_BHATTACHARYYA” give the same measure

Hi i would like to bring to your notice there is some issue in the openCV matchTemplate() methods. 嗨,我想提醒您注意,openCV matchTemplate()方法中存在一些问题。 According to book bhattacharya coefficient is totally different from Normalized cross correalation , but when i tried this chunk of code , i got the same distance everywhere for each image.Can anyone bring this notice to opencv developers and try to tell why this happened. 根据书,bhattacharya系数与归一化的交叉校正完全不同,但是当我尝试这段代码时,每张图片到处都是相同的距离,谁能将此通知带给opencv开发人员并尝试说明为什么会发生这种情况。 I was trying to find the distance measure using these two methods 我试图使用这两种方法找到距离量度

path1 = 'D:/cat1.png'
path2 = 'D:/cat2.png'
im1=cv2.imread(path1, cv2.CV_LOAD_IMAGE_GRAYSCALE)
im2=cv2.imread(path2, cv2.CV_LOAD_IMAGE_GRAYSCALE)
result = cv2.matchTemplate(im1,im2,cv.CV_COMP_BHATTACHARYYA) #Bhattacharya Coefficient
result2=cv2.matchTemplate(im1,im2,cv2.TM_CCORR_NORMED)       #Normalized Cross Correlation

print"BCC :",result
print '\n'
print"NCC :",result2

no wonder. 难怪。

apart from CV_COMP_BHATTACHARYYA not being a valid compare flag for matchTemplate , 除了CV_COMP_BHATTACHARYYA不是matchTemplate的有效比较标志之外

both CV_COMP_BHATTACHARYYA and TM_CCORR_NORMED resolve to the same enum value 3 under the hood. CV_COMP_BHATTACHARYYA和TM_CCORR_NORMED都在后台解析为相同的枚举值3。

so basically you're doing the very same thing twice. 所以基本上您要做两次相同的事情。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM