首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >first-time-FlannBasedMatcher会影响后续FlannBasedMatcher的结果

first-time-FlannBasedMatcher会影响后续FlannBasedMatcher的结果
EN

Stack Overflow用户
提问于 2017-12-28 19:05:22
回答 1查看 52关注 0票数 1

我在我的项目中使用了两次FlannBasedMatcher,但是第一个FlannBasedMatcher似乎影响了第二个FlannBasedMatcher的结果。

代码语言:javascript
复制
cvtColor(c_image1,hsi1,CV_BGR2HSV);
cvtColor(c_image2,hsi2,CV_BGR2HSV);
split(hsi1,channel_hsi1);
split(hsi2,channel_hsi2);
image1s=channel_hsi1[1];
image2s=channel_hsi2[1];
cvtColor(c_image1,image1,CV_RGB2GRAY);
cvtColor(c_image2,image2,CV_RGB2GRAY); 
SiftFeatureDetector detector(800);
SiftDescriptorExtractor extractor;
FlannBasedMatcher matcher;   

//第一个匹配

代码语言:javascript
复制
vector<KeyPoint>keypoint1,keypoint2;
detector.detect(image1,keypoint1);
detector.detect(image2,keypoint2);
Mat des1,des2;
extractor.compute(image1,keypoint1,des1);
extractor.compute(image2,keypoint2,des2);
vector<DMatch>matchpoints_i;
**matcher.match(des1,des2,matchpoints_i);//this line,if I delete it,the result of matchpoints_s will be right.But if I reserve it,the match condition of matchpoints_s will be bad,and even matchpoints_s[i].distance changed a lot.**
sort(matchpoints_i.begin(),matchpoints_i.end());

//第二场比赛

代码语言:javascript
复制
vector<KeyPoint>keypoint1s,keypoint2s;
detector.detect(image1s,keypoint1s);
detector.detect(image2s,keypoint2s);
Mat des1s,des2s;
extractor.compute(image1s,keypoint1s,des1s);
extractor.compute(image2s,keypoint2s,des2s);
vector<DMatch>matchpoints_s;
matcher.match(des1s,des2s,matchpoints_s);
sort(matchpoints_s.begin(),matchpoints_s.end());
for(size_t i=0;i<matchpoints_s.size();i++)
    { 
        cout<< matchpoints_s[i].distance<<endl;
   }

reserve the line,bad result

delete the line,good result

当我使用FlannBasedMatcher两次时,是否会发生冲突?

EN

回答 1

Stack Overflow用户

发布于 2017-12-28 23:31:22

当然,不应该有任何冲突。确保你检查输入--特别是我担心,通过HSV图像的S通道来检测特征是一个好主意:

代码语言:javascript
复制
 image1s=channel_hsi1[1];
 image2s=channel_hsi2[1];

也许H-channel会更好:

代码语言:javascript
复制
 image1s=channel_hsi1[0];
 image2s=channel_hsi2[0];

附注:我已经仔细检查了我的工作代码--是的,在你使用其他图像集之前,你必须调用matcher.clear()。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/48006330

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档