Q3Support.py 文件源码

python
阅读 31 收藏 0 点赞 0 评论 0

项目:Recognition 作者: thautwarm 项目源码 文件源码
def SIFTMATCHCOUNT(img1,img2):
    img1=img1.copy()
    img2=img2.copy()
    # find the keypoints and descriptors with SIFT
    kp1, des1 = Sift.detectAndCompute(img1,None)
    kp2, des2 = Sift.detectAndCompute(img2,None)
    # BFMatcher with default params
    bf = cv2.BFMatcher()
    matches = bf.knnMatch(des1,des2, k=2)
    if len(np.array(matches).shape)!=2 or np.array(matches).shape[1]!=2:
        return 0
    # Apply ratio test
    good = []
    for m,n in matches:
        if 0.50*n.distance<m.distance < 0.80*n.distance:
            good.append([m])
    return len(good)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号