简体   繁体   中英

Access violation reading location 0xFFFFFFFFFFFFFFFF when using FAST feature detector in OpenCV

I am beginner using opencv, and was using the FAST feature detector in opencv to simply get the keypoints of an image.

#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/features2d.hpp"

std::vector<cv::KeyPoint> kp;

int main()
{
    cv::Mat img = cv::imread("im.jpg", 0);
    cv::FAST(img, kp, 100, true);

    cv::Mat img2;
    cv::drawKeypoints(img, kp, img2 , CV_RGB(255, 0, 0));
    cv::imshow("Display", img2);
    cv::waitKey(0);
    cv::destroyWindow("Display");

    return 0;
}

But when debugging the code (Debug mode): I found out that the vector kp (passed as the keypoints vector) in to FAST() has a large size ( kp = { size=658812287755660302 }) which is not possible. But the image denoting correct keypoints is generated. The above mentioned access violation error message comes at the end of debugging.

In Release mode: The code runs fine at first showing the keypoints in the image. At the end when image window is closed, the program is crashed. When debugged, kp has a reasonable size (kp = { size=427 }).

When the code is run in debug mode without debugging, an application error pops out stating that memory at 0xffffffff could not be read.

The call stack is as shown here , which doesn't make any sense to me.

What am I doing wrong? Is it related to the way I'm initializing the vector or something else?

I was unable to reproduce this issue either using my own image or using the image you provided. I therefore have to conclude that there's a problem with your build environment.

  • Make sure that you've set up your project includes and libraries correctly, including the shared libraries that OpenCV uses by default.
  • Make sure that you're using Visual Studio 2015 (or the binary-compatible VS2017) to compile your code.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM