OpenCV 错误的解决方案:不支持的格式或格式组合 - 当将 ORB 功能与 FlannBasedMatcher 匹配
Solution for OpenCV Error: Unsupported format or combination of format - when matching ORB features with FlannBasedMatcher
我试图使用 ORB.My 代码找到好的匹配如下:
Ptr<FeatureDetector> detector = ORB::create();
Mat descriptors_img1, descriptors_img2;
//-- Step 2: Calculate descriptors (feature vectors)
detector->detect(img1, kp1,descriptors_img1);
detector->detect(img2, kp2,descriptors_img2);
Ptr<DescriptorExtractor> extractor = ORB::create();
extractor->compute(img1, kp1, descriptors_img1 );
extractor->compute(img2, kp2, descriptors_img2 );
//-- Step 3: Matching descriptor vectors using FLANN matcher
descriptors_img1.convertTo(descriptors_img1, CV_32F);
descriptors_img2.convertTo(descriptors_img2, CV_32F);
FlannBasedMatcher matcher;
std::vector<DMatch> matches;
matcher.match(descriptors_img1,descriptors_img2,matches);
double max_dist = 0; double min_dist = 100;
//-- Quick calculation of max and min distances between keypoints
for( int i = 0; i < descriptors_img1.rows; i++ )
{
double dist = matches[i].distance;
if( dist < min_dist )
min_dist = dist;
if( dist > max_dist )
max_dist = dist;
}
printf("-- Max dist : %f n", max_dist );
printf("-- Min dist : %f n", min_dist );
//-- Draw only "good" matches (i.e. whose distance is less than 3*min_dist )
std::vector< DMatch > good_matches;
for( int i = 0; i < descriptors_img1.rows; i++ )
{
if( matches[i].distance < 3*min_dist )
{
good_matches.push_back( matches[i]);
}
}
Mat img_matches;
drawMatches(img1,kp1,img2,kp2,good_matches,img_matches,Scalar::all(-1),
Scalar::all(-1),vector<char>(),DrawMatchesFlags::NOT_DRAW_SINGLE_POINTS );
//-- Show detected matches
imshow( "Good Matches", img_matches );
但是当我运行它时,我收到错误说:
OpenCV 错误:不支持的格式或格式组合(类型 = 0 ( 在 buildIndex_ 中,文件/home/openCV-3.2.0/modules/flann/src/miniflann.cpp,第 315 行 在抛出"cv::异常"实例后终止调用 what((:/home/opencv-3.2.0/modules/flann/src/miniflann.cpp:315:函数buildIndex_中的错误:(-210( type=0
我看了类似的问题,但没有找到答案。调试后,我开始知道错误在
matcher.match(....);
请帮助我解决这个问题。提前致谢
我解决了这个错误。 您只需修改代码
Ptr<ORB> detector = ORB::create()
而不是
Ptr<FeatureDetector> detector = ORB::create();
然后它对我有用。
相关文章:
- 当将值推送到矢量时,什么也没发生
- #pragma(*诊断)当将Clang分析器与GCC编译器混合时
- 获取 clang 格式以将多行函数调用的右括号放在单独的行上?
- OpenCV 错误的解决方案:不支持的格式或格式组合 - 当将 ORB 功能与 FlannBasedMatcher 匹配
- OpenCV:当将 std::vector 传递给需要 OutputArray 的函数时,vec 包含垃圾
- 当将参数包传递给另一个可变参数模板函数时,我是否必须使用 std::forward
- 当将QT创建者与CMAKE一起使用时,为什么我不必手动链接MSVC库
- 将字符串转换为十六进制格式并将"0x "附加到十六进制值
- 当将向量设置为一个值时,整个向量会被覆盖
- 当将多个TypedArrayContents数组加载到V8数组中时(数组数组)时,最后一个元素将覆盖所有元素
- 当将对象传递给具有参数作为引用类型的函数以及当其类对象类型时,会得到不同的输出
- 当将 getline 与 int 一起使用时,如何修复"没有重载函数 'getline' 的实例与参数列表匹配"
- 为什么当将 short[] 转换为字符*时,数组是反转的?
- 当将变量作为函数参数传递时,由于隐式铸造而导致的精度丧失
- 当将编译器从G 切换到MSVC时,为什么此开关语句不会返回任何内容
- 当将OPENCV添加到库时,Apple Mach-O Linker(LD)错误组;可能的修复
- 在VIM中,当我在C 文件中键入Semicolon时,如何自动格式当前行
- 当将负文字作为无符号参数传递时,可以g++警告
- POD变量的直接初始化不起作用,但当将变量推到向量上时,复制初始化起作用
- 当将应用程序作为启动的守护程序运行时,C++ 库中的信号 10 (SIGBUS)