我使用的是OpenCV 2.44和Visual Studio C ++ 2010
编译本时
#include <opencv2/imgproc/imgproc_c.h>
#include <stdio.h>
#include <math.h>
#include <opencv/highgui.h>
#include <opencv/cv.h>
#include <opencv2/features2d/features2d.hpp>
#include <opencv2/calib3d/calib3d.hpp>
#include <opencv2/core/core.hpp>
#include <opencv2/nonfree/features2d.hpp>
#include <opencv2/legacy/legacy.hpp>
using namespace cv;
void main()
{
Mat img1 = imread( "hh.jpg", CV_LOAD_IMAGE_GRAYSCALE );
Mat img2 = imread( "hh.jpg", CV_LOAD_IMAGE_GRAYSCALE );
// detecting keypoints
FastFeatureDetector detector(15);
vector<KeyPoint> keypoints1;
detector.detect(img1, keypoints1);
// computing descriptors
SurfDescriptorExtractor extractor;
Mat descriptors1;
extractor.compute(img1, keypoints1, descriptors1);
当我运行代码时,我在prj.exe中的0x580f375b处得到未处理的异常:0xC0000005:访问冲突读取位置0x001f7014。 错误在提取器
我正在使用本教程link
答案 0 :(得分:0)
看起来你忘记了初始化非自由模块。在使用 SurfDescriptorExtractor :
之前尝试调用适当的函数#include <opencv2/nonfree/nonfree.hpp>
...
cv::initModule_nonfree();