-1

I am trying to detect and extract image feature using DynamicAdaptedFeatureDetector, but i am receiving Access violation error. The complete error is: Unhandled exception at 0x000007FEE08AB89A (opencv_features2d2411d.dll) in Feature.exe: 0xC0000005: Access violation reading location 0x0000000000000000.

my sample code is:

.
.
.
    Ptr<FeatureDetector> detector;
    vector<KeyPoint> keypoints1, keypoints2; 
    detector = new DynamicAdaptedFeatureDetector(new FastAdjuster(10, true), 5000, 10000, 10);
    detector->detect(leftImg_roi, keypoints1);
    detector->detect(rightImg_roi, keypoints2);

    Ptr<DescriptorExtractor> extractor;
    extractor = DescriptorExtractor::create("SIFT");
    Mat descriptors1, descriptors2;
    extractor->compute(leftImg_roi, keypoints1, descriptors1);
    extractor->compute(rightImg_roi, keypoints2, descriptors2);

    vector< vector<DMatch> > matches;
    Ptr<DescriptorMatcher> matcher = DescriptorMatcher::create("BruteForce");
    matcher->knnMatch(descriptors1, descriptors2, matches, 500);
.
.
.

Error is coming in the line: extractor->compute(rightImg_roi, keypoints2, descriptors2);

Total detected keypoints from images are: keypoints1 = 1649 and keypoints2 = 1558

Any idea whats wrong in my code?

Sanjay
  • 107
  • 1
  • 4
  • 17
  • Usually this indicates undefined behavior. You may want to check if you go out of bounds somewhere or use a deleted pointer or something else of the sort. In this case it looks like a null pointer exception `Access violation reading location 0x0000000000000000` – Neijwiert Feb 27 '18 at 06:29
  • You seem to be using an old version of OpenCV, for example the newest libraries I have doesn't have anything like DynamicAdaptedFeatureDetector or FastAdjuster. Check if the return value of DescriptorExtractor::create("SIFT"); with extractor->empty(). It returns a bool. If it's false then the create() call failed. – Zebrafish Feb 27 '18 at 07:38
  • @Zebrafish you are right, i am using Old opencv (2.4.11) due to some reason.Also extractor->empty() is false that's why create() call is failing. – Sanjay Feb 27 '18 at 08:37
  • Using default SiftDescriptorExtractor works for me instead of create create("SIFT"). DescriptorExtractor* extractor; extractor = new SiftDescriptorExtractor(); – Sanjay Feb 27 '18 at 08:39

1 Answers1

1

You are getting a null pointer exception. As you are trying to use a pointer that is null, the system is trying to read from address 0. This isn't allowed, hence the error: Access violation reading location 0x0000000000000000.

As you stated the error happens on the line where it uses the variable extractor. My guess is that extractor is null. If not, check other variables and try to use the debugger to step through your code. You aren't really providing a minimal complete and verifiable example, so I can't check myself.

Neijwiert
  • 985
  • 6
  • 19