OpenCV flann.h断言错误 [英] OpenCV flann.h assertion Error
本文介绍了OpenCV flann.h断言错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我写了一个程序,得到2张图片之间的匹配。
这是代码。但如果我使用BruteForceMatcher>(不是flann)它工作。
#include< stdio.h>
#includeopencv2 / core / core.hpp
#includeopencv2 / features2d / features2d.hpp
#includeopencv2 / highgui / highgui.hpp
using namespace cv;
void help()
{
printf(\\\
This程序演示使用features2d检测器,描述符提取器和简单matcher \\\
使用SURF描述符:\\\
\\\
用法:\\\
matcher_simple< image1>< image2> \\\
);
}
int main()
{
Mat img1 = imread(C:\\Users\\Hayk\ \Desktop \\source1.bmp,CV_LOAD_IMAGE_GRAYSCALE);
Mat img2 = imread(C:\\Users\\Hayk\\Desktop\\\source2.bmp,CV_LOAD_IMAGE_GRAYSCALE);
if(img1.empty()|| img2.empty())
{
printf(无法读取其中一个images \\\
return -1;
}
//检测keypoints
SurfFeatureDetector检测器(6000);
vector< KeyPoint> keypoints1,keypoints2;
detector.detect(img1,keypoints1);
detector.detect(img2,keypoints2);
//计算描述符
SurfDescriptorExtractor提取器;
Mat descriptors1,descriptors2;
extractor.compute(img1,keypoints1,descriptors1);
extractor.compute(img2,keypoints2,descriptors2);
//匹配描述符
FlannBasedMatcher匹配器;
vector< DMatch>火柴;
matcher.match(descriptors1,descriptors2,matches);
//绘制结果
namedWindow(matches,1);
Mat img_matches;
drawMatches(img1,keypoints1,img2,keypoints2,matches,img_matches);
imshow(matches,img_matches);
waitKey(0);
return 0;
}
运行程序后遇到此错误
OpenCV错误:未知
函数中的assertion failed(dataset.type()== CvType< T> :: type c:\Users\vp\work\ocv\opencv\modules\features2d\..\flann\include\o
pencv2 / flann / flann.hpp,第105行
任何人都可以告诉我我做错了什么?
我有几个问题的C ++ OpenCV的Windows界面。当我必须使用Windows,我使用C接口。
I wrote a program which gets matches between 2 pictures. And this is the code. but if I use BruteForceMatcher> (not flann) it works.
#include <stdio.h>
#include "opencv2/core/core.hpp"
#include "opencv2/features2d/features2d.hpp"
#include "opencv2/highgui/highgui.hpp"
using namespace cv;
void help()
{
printf("\nThis program demonstrates using features2d detector, descriptor extractor and simple matcher\n"
"Using the SURF desriptor:\n"
"\n"
"Usage:\n matcher_simple <image1> <image2>\n");
}
int main()
{
Mat img1 = imread("C:\\Users\\Hayk\\Desktop\\source1.bmp", CV_LOAD_IMAGE_GRAYSCALE);
Mat img2 = imread("C:\\Users\\Hayk\\Desktop\\source2.bmp", CV_LOAD_IMAGE_GRAYSCALE);
if(img1.empty() || img2.empty())
{
printf("Can't read one of the images\n");
return -1;
}
// detecting keypoints
SurfFeatureDetector detector(6000);
vector<KeyPoint> keypoints1, keypoints2;
detector.detect(img1, keypoints1);
detector.detect(img2, keypoints2);
// computing descriptors
SurfDescriptorExtractor extractor;
Mat descriptors1, descriptors2;
extractor.compute(img1, keypoints1, descriptors1);
extractor.compute(img2, keypoints2, descriptors2);
// matching descriptors
FlannBasedMatcher matcher;
vector<DMatch> matches;
matcher.match(descriptors1, descriptors2, matches);
// drawing the results
namedWindow("matches", 1);
Mat img_matches;
drawMatches(img1, keypoints1, img2, keypoints2, matches, img_matches);
imshow("matches", img_matches);
waitKey(0);
return 0;
}
And this error I am getting after running the program
OpenCV Error: Assertion failed (dataset.type() == CvType<T>::type()) in unknown
function, file c:\Users\vp\work\ocv\opencv\modules\features2d\..\flann\include\o
pencv2/flann/flann.hpp, line 105
Can anyone say to me what I am doing wrong?
解决方案
Your code works just fine on Linux with OpenCV 2.3.1a.
I've had several problems with the C++ OpenCV's interface for Windows. When I have to use Windows, I use the C interface.
这篇关于OpenCV flann.h断言错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文