我一直在努力运行这段简单的代码(这是一个更大的项目的一部分,但这是我现在正在运行的唯一部分)。此代码在Macbook上的Xcode中运行完美,但在Visual Studio 2015中的Windows 10 PC上运行不正确。代码以32位调试模式运行。 OpenCV是使用Cmake for Visual Studio 2015(vc14)(x86)构建的。
在0x0F9E2BE6(opencv_features2d320d.dll)中抛出异常 VIVI.exe:0xC0000005:访问冲突写入位置0x0000001C。 抛出未处理的异常:写入访问冲突。这是0x1C。
调用时似乎达到了写访问冲突:
detectorAKAZE->detectAndCompute(cam_frame_gray, noArray(), kp_cam, descriptors_cam);
因为这是Visual Studio插入断点并停止的地方。
来自调用堆栈:
opencv_features2d320d.dll!CV ::点_ :: Point_(常量 cv :: Point_& pt)第1080行C ++
代码:
#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);
...
非常感谢任何帮助!