SURF比较,相似得分,PYTHON

时间:2018-05-03 16:02:12

标签: python similarity surf

我需要比较两个图像,为此,我使用了冲浪比较,但我还需要得到两个图像的相似度得分% 它似乎不像cv2库有这样的命令!

您将在下面找到我用于SURF比较的代码:

import cv2
import numpy as np

filename1 = askopenfilename(filetypes=[("image","*.png")])
filename2 = askopenfilename(filetypes=[("image","*.png")])

img1=cv2.imread(filename1,1)
img2=cv2.imread(filename2,1)

# ORB Detector
orb = cv2.ORB_create()
kp1, des1 = orb.detectAndCompute(img1, None)
kp2, des2 = orb.detectAndCompute(img2, None)

# Brute Force Matching
bf = cv2.BFMatcher(cv2.NORM_HAMMING, crossCheck=True)
matches = bf.match(des1, des2)
matches = sorted(matches, key = lambda x:x.distance)

matching_result = cv2.drawMatches(img1, kp1, img2, kp2, matches[:50], None, flags=2)  
cv2.imshow("Reference image", img1)
cv2.imshow("Image", img2)
img3 = img1 - img2   
cv2.imshow("Matching result", matching_result)
cv2.waitKey(0)
cv2.destroyAllWindows()

感谢您的帮助。

0 个答案:

没有答案