【问题标题】:How do you use Akaze in Open CV on python你如何在 python 上的 Opencv 中使用 Amaze
【发布时间】:2020-03-19 15:40:29
【问题描述】:

我在 c++ 中找到了示例: http://docs.opencv.org/3.0-beta/doc/tutorials/features2d/akaze_matching/akaze_matching.html

但在 python 中没有任何示例显示如何使用此功能检测器(在有关 AKAZE 的文档中也找不到更多内容,有 ORB SIFT、SURF 等,但不是我想要的) http://docs.opencv.org/3.1.0/db/d27/tutorial_py_table_of_contents_feature2d.html#gsc.tab=0

有人可以分享或告诉我在哪里可以找到如何将 python 中的图像与 akaze 匹配的信息吗?

【问题讨论】:

    标签: python opencv


    【解决方案1】:

    我不确定在哪里可以找到它,我让它工作的方式是通过这个使用蛮力匹配器的函数:

    def kaze_match(im1_path, im2_path):
        # load the image and convert it to grayscale
        im1 = cv2.imread(im1_path)
        im2 = cv2.imread(im2_path)
        gray1 = cv2.cvtColor(im1, cv2.COLOR_BGR2GRAY)
        gray2 = cv2.cvtColor(im2, cv2.COLOR_BGR2GRAY)    
    
        # initialize the AKAZE descriptor, then detect keypoints and extract
        # local invariant descriptors from the image
        detector = cv2.AKAZE_create()
        (kps1, descs1) = detector.detectAndCompute(gray1, None)
        (kps2, descs2) = detector.detectAndCompute(gray2, None)
    
        print("keypoints: {}, descriptors: {}".format(len(kps1), descs1.shape))
        print("keypoints: {}, descriptors: {}".format(len(kps2), descs2.shape))    
    
        # Match the features
        bf = cv2.BFMatcher(cv2.NORM_HAMMING)
        matches = bf.knnMatch(descs1,descs2, k=2)    # typo fixed
    
        # Apply ratio test
        good = []
        for m,n in matches:
            if m.distance < 0.9*n.distance:
                good.append([m])
    
        # cv2.drawMatchesKnn expects list of lists as matches.
        im3 = cv2.drawMatchesKnn(im1, kps1, im2, kps2, good[1:20], None, flags=2)
        cv2.imshow("AKAZE matching", im3)
        cv2.waitKey(0) 
    

    请记住,特征向量是二进制向量。因此,相似度是基于汉明距离,而不是常用的 L2 范数或欧几里得距离。

    【讨论】:

    • 比率测试是否正确?它给了我关键点编号而不是比率。
    • 此处实现的比率测试将返回有效点列表。
    【解决方案2】:

    我搜索了相同的教程,发现该教程以 3 种替代语言 C++、Python 和 Java 提供。在代码区开始之前有 3 个超链接。

    试试这个 [https://docs.opencv.org/3.4/db/d70/tutorial_akaze_matching.html]

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-10-16
      • 2018-06-19
      • 2011-06-29
      • 1970-01-01
      • 1970-01-01
      • 2020-10-18
      • 2022-01-06
      相关资源
      最近更新 更多