-4

我使用 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。错误在提取器

我正在使用这个教程链接

4

1 回答 1

0

看起来您忘记了初始化非自由模块。在使用SurfDescriptorExtractor之前尝试调用适当的函数:

#include <opencv2/nonfree/nonfree.hpp>
...
cv::initModule_nonfree();
于 2013-03-30T20:37:44.900 回答