I'm trying to calculate the distance (Euclidean or hamming) between two descriptors already calculated. The problem is I don't want to use a matcher, I just want to calculate the distance between two descriptors. I'm using OpenCV 2.4.9 and i have mine descriptors stored in a Mat type:
Mat descriptors1;
Mat descriptors2;
and now i just want to calculate the distance (preferably the Hamming distance since I'm using binary descriptors) between row1 of descriptors1 and row1 of descriptors2 (for example).
I have tried to use bitwise_xor() function but then I got not an effective way of doing the bitcount. There is no function to calculate the hamming distance between two arrays?
I notice that I'm fairly new to OpenCV but I appreciate any help. Thank you
you can use opencv's norm function for this.
Mat descriptors1;
Mat descriptors2;
double dist_l2 = norm(descriptors1,descriptors2,NORM_L2); // l2 for surf,sift
double dist_ham = norm(descriptors1,descriptors2,NORM_HAMMING); // for ORB,BRIEF,etc.
来源:https://stackoverflow.com/questions/26326252/calculate-distance-between-two-descriptors