Using FeatureDetector in OpenCV gives access violation

陌路散爱 提交于 2019-12-20 01:07:32

问题


I need to find and match feature points in stereo images. Therefore I want to compare the different Feature Detection algorithms that are supported in OpenCV 2.4.5. by passing "SURF", "SIFT", etc. to the function.

The code snippet:

#include "opencv2/opencv.hpp"
#include <opencv/highgui.h>
#include <opencv2/nonfree/features2d.hpp>

using namespace cv;
using namespace std;

...

void DisparityAnalysis::detectKeyPoints(Mat1b leftImageGrey, Mat1b rightImageGrey, string algorithmName)
{
    Ptr<FeatureDetector> detector = FeatureDetector::create(algorithmName);
    detector->detect(leftImageGrey, keypoints_1);
    detector->detect(rightImageGrey, keypoints_2);
}

The error:

Unhandled exception at 0x770b15de in DisparityAnalysis.exe: 0xC0000005: Access violation reading location 0x00000000.

I've already searched for solutions and found this one: Access violation reading in FeatureDetector OpenCV 2.4.5 The difference I've recognized is, that they use cv::initModule_nonfree() at the beginning. But when copying it into my code it doesn't compile because the identifier isn't found. Any suggestions?


回答1:


for SIFT and SURF, you'll need the nonfree module, that is :

  • include "opencv2/nonfree/nonfree.hpp"

  • call cv::initModule_nonfree() at the beginning

  • link against opencv_nonfree2.4.x.lib



来源:https://stackoverflow.com/questions/17785028/using-featuredetector-in-opencv-gives-access-violation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!