-4

I use OpenCV 2.44 and Visual Studio C++ 2010

When I compile this

#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);

when I run the code I get Unhandled exception at 0x580f375b in prj.exe: 0xC0000005: Access violation reading location 0x001f7014. the error is at extractor

I'm using this tutorial link

Angie Quijano
  • 3,308
  • 3
  • 20
  • 30
Bogdan Eu
  • 11
  • 1
  • 4

1 Answers1

0

It's looks like that you forget to init non-free module. Try to call appropriate function before using SurfDescriptorExtractor:

#include <opencv2/nonfree/nonfree.hpp>
...
cv::initModule_nonfree();
Rasim
  • 1,246
  • 1
  • 11
  • 24