OpenCV SURF extractor.compute error

OpenCV SURF extractor.compute error

本文关键字:error compute extractor SURF OpenCV      更新时间:2023-10-16

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

我使用的是这个教程链接

看起来您忘记初始化非自由模块了。在使用SurfDescriptorExtractor:

之前尝试调用适当的函数
#include <opencv2/nonfree/nonfree.hpp>
...
cv::initModule_nonfree();