opencv3.2 配置opencv_contrib后运行sift特征点检测代码出错
opencv吧
全部回复
仅看楼主
level 2
代码如下:
#include <iostream>
#include <opencv2/opencv.hpp> //头文件
#include <opencv2/xfeatures2d.hpp>
using namespace cv; //包含cv命名空间
using namespace std;
int main()
{
//Create SIFT class pointer
Ptr<Feature2D> f2d = xfeatures2d::SIFT::create();
//读入图片
Mat img_1 = imread("1.jpg");
Mat img_2 = imread("2.jpg");
//Detect the keypoints
vector<KeyPoint> keypoints_1, keypoints_2;
f2d->detect(img_1, keypoints_1); //调试到这里时出错!!!!!
f2d->detect(img_2, keypoints_2);
//Calculate descriptors (feature vectors)
Mat descriptors_1, descriptors_2;
f2d->compute(img_1, keypoints_1, descriptors_1);
f2d->compute(img_2, keypoints_2, descriptors_2);
//Matching descriptor vector using BFMatcher
BFMatcher matcher;
vector<DMatch> matches;
matcher.match(descriptors_1, descriptors_2, matches);
//绘制匹配出的关键点
Mat img_matches;
drawMatches(img_1, keypoints_1, img_2, keypoints_2, matches, img_matches);
imshow("【match图】", img_matches);
//等待任意按键按下
waitKey(0);
}
2017年04月05日 05点04分 1
level 2
显示这个错误
2017年04月05日 05点04分 2
level 2
后来就显示这个错误了:
0x00007FF8AA9A8A5C 处(位于 test1.exe 中)有未经处理的异常: Microsoft C++ 异常: cv::Exception,位于内存位置 0x0000006308B2E440 处。
2017年04月05日 05点04分 3
level 2
控制台显示
2017年04月05日 05点04分 4
level 2
我也是刚开始学OPENCV,也找的这个例程,亲测可以运行。你的读入图片路径有没有改啊。。。
2017年04月05日 14点04分 5
请问你配置3.2用的是github上下的opencv_contrib_master吗
2017年04月06日 03点04分
2017年04月06日 03点04分
level 7
Mat img_1 = imread("1.jpg");
imshow("test", img_1);
这个能否显示
否则可能VC和openCV的版本不合
2017年04月06日 09点04分 6
能显示的,vs2015+opencv3.2,之前运行其他程序都可以的,只是配置了opencv_contrib后,运行这个不行
2017年04月06日 09点04分
@男主不会死 不如用c语言的siftwin32
2017年04月07日 06点04分
不知道opencv中是否用 SiftGPU
2017年04月07日 06点04分
level 2
你的debug或者x64有没有对应啊
2017年04月07日 02点04分 7
对应了啊
2017年04月07日 04点04分
level 1
似乎是debug版出错,换到release版
2018年04月04日 07点04分 10
level 1
请问楼主现在解决了吗
2018年11月27日 05点11分 11
level 1
哈哈哈,我来终结这个这个问题吧。出现这个原因是因为在opencv3.X中这个算法已经申请专利了。所以需要使用cmake重新编译,记得在 编译勾选上OPENCV_ENABLE_NONFREE
。具体使用教程见https://blog.csdn.net/ZengTudou/article/details/84403047
2018年12月24日 15点12分 12
level 1
我也是这个地方报错,应该是图像的问题,示例图可以检测关键点,但是换做自己的图像就不行了
2021年07月07日 09点07分 13
1