2013-03-29 46 views
-4

我使用OpenCV的2.44和Visual Studio C++ 2010OpenCV的SURF extractor.compute錯誤

當我編譯這個

#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:0000005 :訪問衝突讀取位置0x001f7014。 錯誤是在提取

我使用本教程link

回答

0

它看起來像你忘了初始化非自由模塊。嘗試在使用前調用適當的功能SurfDescriptorExtractor

#include <opencv2/nonfree/nonfree.hpp> 
... 
cv::initModule_nonfree();