来自: 伱丶蕞紾匮
回复量:5
创建时间: 2017-03-29 15:56
initModule_nonfree();//初始化模块,使用SIFT或SURF时用到
Ptr<FeatureDetector> detector = FeatureDetector::create("SIFT");//创建SIFT特征检测器
Ptr<DescriptorExtractor> descriptor_extractor = DescriptorExtractor::create( "SIFT" );//创建特征向量生成器
Ptr<DescriptorMatcher> descriptor_matcher = DescriptorMatcher::create( "BruteForce" );//创建特征匹配器
if( detector.empty() || descriptor_extractor.empty() )
cout<<"fail to create detector!";
//读入图像
IplImage * img1 = cvLoadImage("phone2.jpg");
IplImage * img2 = cvLoadImage("phone3.jpg");
//特征点检测
double t = getTickCount();//当前滴答数
vector<KeyPoint> keypoints1,keypoints2;
detector->detect( img1, keypoints1 );(这里出现了问题)
0 赞
5 回复
不知道楼主解决没有。我也是和你一样的问题。我是编译的opencv3.1加上opencv_contrib这个库。其他的imread imshow这些都能用,也能这样定义Ptr<xfeatures2d::SURF> detector = xfeatures2d::SURF::create(1000); detector,
但是运行detector->detect(image1, keypoints);这一句时程序就崩溃了。
楼主最好能下载opencv的source code然后debug到opencv的代码里面去
我大概帮楼主看了一下这个opencv的实现,detect里面有些assert被触发了就会crash。
根据下面的code可以看到首先你的img1要不为空,其次image的type要是CV_8U。如果不是,要通过cvCvtColor转换
if( image.empty() || image.depth() != CV_8U ) CV_Error( Error::StsBadArg, "image is empty or has incorrect depth (!=CV_8U)" ); if( !mask.empty() && mask.type() != CV_8UC1 ) CV_Error( Error::StsBadArg, "mask has incorrect type (!=CV_8UC1)" );
你好,我在使用过程中遇到了同样的问题,经查找资料,是vector析构引起的,只要在opencv 函数调用前,先对vector手动分配内存即可,我的问题是这样解决的,具体的问题,还得具体分析:
double t = getTickCount();//当前滴答数
vector<KeyPoint> keypoints1, keypoints2;
keypoints1.resize(100);
keypoints2.resize(100);
detector->detect(img1, keypoints1);//检测img1中的SIFT特征点,存储到keypoints1中
detector->detect(img2, keypoints2);
//detector.detect(img1, keypoints1);
先对vector手动分配内存
回答非常正确。
693
mapreduce中 combiner 合并文件,默认是一次合并多少个文件啊?
726
请问 谁有课程 (推荐算法与Spark MLLIB) 里面的代码
940
730
947