opencv中java的dmatch_关于OpenCV的那些事——ORB的brief描述子(256bit)的match心得

用了ORB那么久,今天第一次将256bit的描述子打印出来,直观看到了match的汉明距离。

7390a109814dc0e3852ddcbafbc7c02f.png

上代码:#include 

#include 

#include 

#include 

#include 

#include 

using namespace std;

using namespace cv;

int main()

{

Mat image = imread("t.png");

Mat image1 = imread("t1.png");

Mat gray,gray1;

cvtColor(image, gray, CV_BGR2GRAY);

cvtColor(image1, gray1, CV_BGR2GRAY);

ORB orb(1000);

vector keypoints,keypoints1;

orb.detect(gray, keypoints);

orb.detect(gray1, keypoints1);

Mat descriptors, descriptors1;

orb.compute(gray, keypoints, descriptors);

orb.compute(gray1, keypoints1, descriptors1);

BFMatcher bf(NORM_HAMMING);

vector matches,good;

bf.match(descriptors, descriptors1, matches);

for (size_t i = 0; i 

{

if (matches[i].distance 

good.push_back(matches[i]);

}

cout <

Mat imagem;

drawMatches(image, keypoints, image1, keypoints1, good,imagem);

imshow("1", imagem);

for (size_t i = 0; i 

{

cout <

for (int j = 0; j 

{

cout <( (int)descriptors.at(good[i].queryIdx, j) ) <

cout <( (int)descriptors1.at(good[i].trainIdx, j) ) <

}

cout <

}

waitKey(0);

return 0;

}

查看了Mat descriptors的信息,行数为keypoints的值,列数为32,说明type为CV_8U(256/32=8)通道的话就只能是1通道。(PS: 强制转换到CV_32U等均报错)

不同于brief描述子的uchar类型,sift和surf均采用float型。所以ORB(brief)描述子8维,32bytes(256bits),CV_8UC1。SIFT描述子128维,512bytes,CV_32UC4(512*8/32 = 32*4,第一个32表示描述子Mat是32列,第二个32表示float类型)。SURF描述子64维,256bytes,CV_32UC2。(OpenCV里compute的描述子的列数都是32)

————————————————

版权声明:本文为CSDN博主「cc_sunny」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。

#转载请注明出处 www.skcircle.com 《少有人走的路》勇哥的工业自动化技术网站。如果需要本贴图片源码等资源,请向勇哥索取。

收藏 | 0点赞 | 0打赏作者

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值