I've been struggling for days to run this simple piece of code (that is part of a bigger project but this is the only part I'm running now). This code runs flawlessly in Xcode on macbook but not on my Windows 10 PC in Visual Studio 2015. The code is running in 32-bit debug mode. OpenCV has been built using Cmake for Visual Studio 2015 (vc14) (x86).
Exception thrown at 0x0F9E2BE6 (opencv_features2d320d.dll) in VIVI.exe: 0xC0000005: Access violation writing location 0x0000001C. Unhandled exception thrown: write access violation. this was 0x1C.
It seems to reach this write access violation when calling:
detectorAKAZE->detectAndCompute(cam_frame_gray, noArray(), kp_cam, descriptors_cam);
as this is where Visual Studio inserts a breakpoint and stops.
From the call stack:
opencv_features2d320d.dll!cv::Point_::Point_(const cv::Point_ & pt) Line 1080 C++
The code:
#include <iostream>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/core/core.hpp>
#include <opencv2/opencv.hpp>
#include <opencv2/features2d/features2d.hpp>
#include <opencv2/features2d.hpp>
using namespace cv;
//Image search path
String writepath = "D:/opencv-3.2.0/images/success-kid.jpg";
String readpath = "D:/opencv-3.2.0/images/success-kid.jpg";
int main( int argc, const char * argv[] ) {
/*==================================================================
* Variables
*=================================================================*/
int key;
Mat cam_frame_col, cam_frame_gray; //Camera frames in color and grayscale (e.g 'template')
Mat descriptors_cam; //Descriptors for camera frame (e.g. 'template')
std::vector<KeyPoint> kp_cam; //Keypoints for camera frame (e.g. 'template')
//-- AKAZE parameters
float inlier_threshold = 2.5;
float match_ratio = 0.8;
key = 0;
BFMatcher matcher(NORM_HAMMING);
Ptr<AKAZE> detectorAKAZE = AKAZE::create();
//-- Importing image
cam_frame_col = imread(readpath);
//-- Processing the camera frame to grayscale.
cvtColor(cam_frame_col, cam_frame_gray, CV_BGR2GRAY);
imshow("Gray", cam_frame_gray);
waitKey(30);
//-- Find keypoints for camera frame.
detectorAKAZE->detectAndCompute(cam_frame_gray, noArray(), kp_cam, descriptors_cam);
...
Any help is greatly appreciated!
User contributions licensed under CC BY-SA 3.0