【发布时间】:2020-09-12 22:57:55
【问题描述】:
我想比较两个签名之间的相似之处。
Python version : 3.7.7
OpenCv version : 4.2.0
这是我到目前为止所做的:
from cv2 import *
import numpy as np
#uploading images
template = cv2.imread("C://Users//subhr//Ams_1.jpg")
original = cv2.imread("C://Users//subhr//Ams_2.jpg")
#resizing images
template = cv2.resize(template,(528,152))
cv2.imshow("template image", template)
cv2.waitKey(0)
cv2.destroyAllWindows()
template.shape #row.columns
original = cv2.resize(original,(528,152))
cv2.imshow("original image", original)
cv2.waitKey(0)
cv2.destroyAllWindows()
#ORB Detector
orb = cv2.ORB_create()
original = cv2.Canny(original, 50, 200)
template = cv2.Canny(template, 50, 200)
# key points and descriptor calculation
kp1, desc_1 = orb.detectAndCompute(template, None)
kp2, desc_2 = orb.detectAndCompute(original, None)
#creating matches
matcher = cv2.DescriptorMatcher_create(cv2.DescriptorMatcher_BRUTEFORCE_HAMMING)
matches_1 = matcher.knnMatch(desc_1, desc_2, 2)
len(matches_1)
result = cv2.drawMatchesKnn(original, kp1 , template, kp2, matches_1, None)
cv2.imshow("result", result)
cv2.waitKey(0)
cv2.destroyAllWindows()
#distance similarity
good_points = []
for m,n in matches_1:
if m.distance < 0.8* n.distance:
good_points.append(m)
len(good_points)
result = cv2.drawMatches(original, kp1 , template, kp2, good_points, None)
cv2.imshow("result", result)
cv2.waitKey(0)
cv2.destroyAllWindows()
print(len(kp1))
print(len(kp2))
#calculating ratio
print("How good is the match : ",len(kp1)/len(good_points))
此时,我已经尝试过 orb 和 akaze ,我想使用 SIFT 但它不可用.我尝试过 Opencv 3.4 版,但没有成功。
有没有更好的方法来比较签名的相似性并标准化整个过程?
图片链接:https://ibb.co/yhvTrng,https://ibb.co/xfBzCgW
谢谢。
【问题讨论】:
标签: python opencv computer-vision opencv3.0 sift