FLANN error in OpenCV 3

流过昼夜 提交于 2019-12-05 00:25:44
Rafael Ruiz Muñoz

So what I said:

in order to use FlannBasedMatcher you need to convert your descriptors to CV_32F:

if(descriptors_1.type()!=CV_32F) {
    descriptors_1.convertTo(descriptors_1, CV_32F);
}

if(descriptors_2.type()!=CV_32F) {
    descriptors_2.convertTo(descriptors_2, CV_32F);
}

you can take a look to this similar question:

The answer by Rafael Ruiz Muñoz is wrong.

Convert the descriptors to CV_32F elimilated the assertion error. But, the matcher will behavior in the wrong way.

ORB is hamming descriptor. By default, the FlannBasedMatcher creates L2 euclid KDTreeIndexParams().

Try to init the matcher in the flowing way,

cv::FlannBasedMatcher matcher(new cv::flann::LshIndexParams(20, 10, 2));

Unsupported format or combination of formats is also thrown if no descriptors could be computed.

You can check if that's the case using empty() after detectAndCompute, thus:

  detector->detectAndCompute( img_1, noArray(), keypoints_1, descriptors_1 );
  detector->detectAndCompute( img_2, noArray(), keypoints_2, descriptors_2 ); 

  if ( descriptors_1.empty() ) {
     cvError(0,"MatchFinder","descriptors_1 descriptor empty",__FILE__,__LINE__);
  }
  if ( descriptors_2.empty() ) {
     cvError(0,"MatchFinder","descriptors_2 empty",__FILE__,__LINE__);
  }
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!