BFmatcher crashes because of different descriptor shapes

asked 2016-07-22 08:11:50 -0500

danceToBebop gravatar image

Hey everyone,

I'm using binary images of the same size, extracting ORB Features but when it comes to compare the descriptors I receive an:

The Error

OpenCV/opencv/modules/core/src/stat.cpp:3757: error: (-215) type == src2.type() && src1.cols == src2.cols && (type == CV_32F || type == CV_8U) in function batchDistance

However when I check the descriptors with

print img.dtype, np.shape(img), np.shape(descriptors)
print oldimg.dtype, np.shape(oldimg), np.shape(olddescriptors)

I get

uint8 (21, 27) (22, 32)
uint8 (21, 27) (17, 32)

Apparently this seems to be the error. On the other hand there's not much I can do against it. Has anybody an idea? At least is there some kind of tutorial online, of how to manually match the descriptors ?

Btw it is the same if I use SIFT, SURF, etc.

Here's my code:

I'm working with python 2.7 and OpenCV 2.4

    orb = cv2.ORB_create(edgeThreshold=3)
    oldkeypoints, olddescriptors = orb.detectAndCompute(oldimg,None)
    keypoints, descriptors = orb.detectAndCompute(img,None) 

    bf = cv2.BFMatcher(cv2.NORM_HAMMING)

    matches = bf.match(descriptors) # crashes here
    matches = sorted(matches, key = lambda x:x.distance)
edit retag flag offensive close merge delete