简体   繁体   English

在 OpenCV 中组合 SIFT 和 ORB 描述符的最佳方法

[英]Best way to combine SIFT and ORB descriptors in OpenCV

I need to combine SIFT and ORB descriptors of an image.我需要结合图像的SIFTORB描述符。

As you know, SIFT descriptors are of 128-length and ORB descriptors are of 32-length.如您所知, SIFT描述符的长度为 128,而ORB描述符的长度为 32。

At this moment what I do is:此时此刻我做的是:

  1. Reshaping SIFT descriptors to 32-length.SIFT描述符重塑为 32 位长度。 For instance, reshape a (135, 128) descriptor to a (540, 32) descriptor例如,将 (135, 128) 描述符重塑为 (540, 32) 描述符
  2. Concatenating SIFT and ORB descriptors (since at this moment both have 32-length)连接SIFTORB描述符(因为此时两者的长度均为 32)

Code:代码:

sift_kp, sift_desc = sift.detectAndCompute(img,None)
new_sift_desc = sift_desc.reshape((int(128/32) * sift_desc.shape[0], 32))
orb_kp, orb_img_descriptor = orb.detectAndCompute(img,None)
all_descriptors = np.concatenate((new_sift_desc , orb_img_descriptor), axis=0)

I am wondering if there is a better way to combine these descriptors.我想知道是否有更好的方法来组合这些描述符。

After combinating the descriptors, the idea is to use all_descriptors in order to perform feature matching against another image.组合描述符后,想法是使用all_descriptors以便对另一幅图像执行特征匹配。

In case someone is interested, what I have finally done is to use ORB in order to detect the images keypoints and use SIFT to compute descriptors from that keypoints如果有人感兴趣,我最终做的是使用 ORB 来detect图像关键点并使用 SIFT 从该关键点compute描述符

Code:代码:

def get_orb_sift_image_descriptors(search_img, idx_img):
    # Initiate SIFT detector
    sift = cv.SIFT_create()
    # Initiate ORB detector
    orb = cv.ORB_create()
    # Find keypoints with ORB
    search_kp_orb = orb.detect(search_img, None)
    idx_kp_orb = orb.detect(idx_img, None)
    # Compute descriptors with SIFT
    search_kp_sift, search_des_sift = sift.compute(search_img, search_kp_orb)
    idx_kp_sift, idx_des_sift = sift.compute(idx_img, idx_kp_orb)
    return search_des_sift, idx_des_sift

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM