我想找到两个签名的匹配百分比

时间:2019-05-31 15:44:59

标签: python-3.x

我要使用我的最后一个项目名称“银行支票分析仪系统”,因为在匹配两个签名时我遇到了问题。问题是我希望匹配的百分比不超过100%。   该程序可以很好地判断签名是否匹配,但我也希望获得百分比

我是Python新手,这是下面的代码

import numpy as np
import cv2
from matplotlib import pyplot as plt


orb = cv2.ORB_create()

img1 = cv2.imread('hn2.jpg', cv2.IMREAD_GRAYSCALE)
kp1, des1 = orb.detectAndCompute(img1,None)

img2 = cv2.imread('hn1.jpg', cv2.IMREAD_GRAYSCALE)
kp2, des2 = orb.detectAndCompute(img2,None)


bf = cv2.BFMatcher()
matches = bf.knnMatch(des1,des2, k=2)

# Apply ratio test
good = []
for m,n in matches:
    if m.distance < 0.75*n.distance:
        good.append([m])
score = m.distance**2 + n.distance**2

img4 = cv2.drawKeypoints(img1, kp1, outImage=None)
img5 = cv2.drawKeypoints(img2, kp2, outImage=None)

f, axarr = plt.subplots(1, 2)
axarr[0].imshow(img4)
axarr[1].imshow(img5)
plt.show()

img3 = cv2.drawMatchesKnn(img1,kp1,img2,kp2,good,flags=2, outImg=None)
plt.imshow(img3)
plt.show()

if len(good) == len(matches):
 print("RESULT: Signature matched with percentage = {}".format(len(good)/len(matches)*100))
elif len(good) > 20:
 print("RESULT: Signature matched with percentage")
else:
 print("RESULT: Signature does not matched with percentage")
``````````````````````````````````````````````````````````````````````**strong text**

0 个答案:

没有答案