Home > Software engineering >  Best way to combine SIFT and ORB descriptors in OpenCV
Best way to combine SIFT and ORB descriptors in OpenCV

Time:03-16

I need to combine SIFT and ORB descriptors of an image.

As you know, SIFT descriptors are of 128-length and ORB descriptors are of 32-length.

At this moment what I do is:

  1. Reshaping SIFT descriptors to 32-length. For instance, reshape a (135, 128) descriptor to a (540, 32) descriptor
  2. Concatenating SIFT and ORB descriptors (since at this moment both have 32-length)

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.

CodePudding user response:

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

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
  • Related