计算两个描述符之间的距离 [英] Calculate distance between two descriptors

查看:350
本文介绍了计算两个描述符之间的距离的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试计算已经计算的两个描述符之间的距离(欧几里得或海明).问题是我不想使用匹配器,我只想计算两个描述符之间的距离. 我使用的是OpenCV 2.4.9,并且在Mat类型中存储了我的描述符:

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; 

现在我只想计算描述符1的row1和描述符2的row1之间的距离(最好是汉明距离,因为我使用的是二进制描述符).

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).

我尝试使用bitwise_xor()函数,但是后来我没有一种有效的位计数方法.没有计算两个数组之间的汉明距离的函数吗?

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?

我注意到我是OpenCV的新手,但我非常感谢您的帮助.谢谢

I notice that I'm fairly new to OpenCV but I appreciate any help. Thank you

推荐答案

,您可以使用opencv的

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.

这篇关于计算两个描述符之间的距离的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆