简体   繁体   English

带有ORB描述符的opencv FLANN?

[英]opencv FLANN with ORB descriptors?

I am trying to use FLANN with ORB descriptors, but opencv crashes with this simple code: 我试图使用带有ORB描述符的FLANN,但opencv崩溃了这个简单的代码:

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. 如果我使用SurfDescriptorExtractor()它运作良好。

How can I solve this? 我怎么解决这个问题?

OpenCV says: OpenCV说:

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

Flann needs the descriptors to be of type CV_32F so you need to convert them! Flann需要描述符为CV_32F类型,因此您需要转换它们! find_object/example/main.cpp : find_object / example / main.cpp

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

may work ;-) 可以工作;-)

When using ORB you should construct your matcher like so: 使用ORB时,您应该像这样构建匹配器:

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

I've also seen this constructor suggested : 我也看到过这个构造函数的建议

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

Binary-string descriptors - ORB, BRIEF, BRISK, FREAK, AKAZE etc. 二进制字符串描述符 - ORB,BRIEF,BRISK,FREAK,AKAZE等。

Floating-point descriptors - SIFT, SURF, GLOH etc. 浮点描述符 - SIFT,SURF,GLOH等


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 . 要比较OpenCV中的二进制描述符,请使用FLANN + LSH索引Brute Force + Hamming距离

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


By default FlannBasedMatcher works as KDTreeIndex with L2 norm. 默认情况下,FlannBasedMatcher作为具有L2范数的KDTreeIndex。 This is the reason why it works well with SIFT/SURF descriptors and throws an exception for ORB descriptor. 这就是为什么它适用于SIFT / SURF描述符并抛出 ORB描述符异常的原因。

Binary features and Locality Sensitive Hashing (LSH) 二进制特征和局部敏感哈希(LSH)

Performance comparison between binary and floating-point descriptors 二进制和浮点描述符之间的性能比较

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM