Calculate distance between two descriptors

主宰稳场 提交于 2019-12-22 01:20:47

问题


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


回答1:


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!