问题
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