opencv FLANN with ORB descriptors?

我只是一个虾纸丫 提交于 2019-11-27 15:54:42

问题


I am trying to use FLANN with ORB descriptors, but opencv crashes with this simple code:

vector<vector<KeyPoint> > dbKeypoints;
vector<Mat> dbDescriptors;
vector<Mat> objects;   

/*
  load Descriptors from images (with OrbDescriptorExtractor())
*/

FlannBasedMatcher matcher;

matcher.add(dbDescriptors); 
matcher.train() //> Crash!

If I use SurfDescriptorExtractor() it works well.

How can I solve this?

OpenCV says:

OpenCV Error: Unsupported format or combination of formats (type=0
) in unknown function, file D:\Value\Personal\Parthenope\OpenCV\modules\flann\sr
c\miniflann.cpp, line 299

回答1:


Flann needs the descriptors to be of type CV_32F so you need to convert them! find_object/example/main.cpp:

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

may work ;-)




回答2:


It's a bug. It will be fixed soon.

http://answers.opencv.org/question/503/how-to-use-the-lshindexparams/




回答3:


When using ORB you should construct your matcher like so:

FlannBasedMatcher matcher(new cv::flann::LshIndexParams(5, 24, 2));

I've also seen this constructor suggested:

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



回答4:


Binary-string descriptors - ORB, BRIEF, BRISK, FREAK, AKAZE etc.

Floating-point descriptors - SIFT, SURF, GLOH etc.


Feature matching of binary descriptors can be efficiently done by comparing their Hamming distance as opposed to Euclidean distance used for floating-point descriptors.

For comparing binary descriptors in OpenCV, use FLANN + LSH index or Brute Force + Hamming distance.

http://answers.opencv.org/question/59996/flann-error-in-opencv-3/


By default FlannBasedMatcher works as KDTreeIndex with L2 norm. This is the reason why it works well with SIFT/SURF descriptors and throws an exception for ORB descriptor.

Binary features and Locality Sensitive Hashing (LSH)

Performance comparison between binary and floating-point descriptors



来源:https://stackoverflow.com/questions/11565255/opencv-flann-with-orb-descriptors

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