Using FeatureDetector in OpenCV gives access violation

I need to find and map function points in stereo images. Therefore, I want to compare the various function detection algorithms that are supported in OpenCV 2.4.5. by transmitting "SURF", "SIFT", etc. functions.

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

Error:

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

I was already looking for solutions and found this: Reading Access Violations in FeatureDetector OpenCV 2.4.5 The difference I admitted is that they use cv :: initModule_nonfree () at the beginning. But when copying it to my code, it does not compile because the identifier was not found. Any suggestions?

+4
source share
1 answer

for SIFT and SURF you will need a proprietary module, that is:

  • enable "opencv2 / nonfree / nonfree.hpp"

  • call cv :: initModule_nonfree () at the beginning

  • link to opencv_nonfree2.4.x.lib

+3
source

Source: https://habr.com/ru/post/1492676/


All Articles