gpt4 book ai didi

c++ - VS2010 和 OpenCV : Stack around a variable was corrupted

转载 作者:行者123 更新时间:2023-11-28 07:57:18 25 4
gpt4 key购买 nike

下面的代码在 Visual Studio 2010 中运行时出现以下错误:Run-Time Check Failure #2 - Stack around the variable 'keypoints' was corrupted.

#include<iostream>
#include<fstream>
#include<cv.h>
#include<highgui.h>
#include<opencv2/nonfree/features2d.hpp>
using namespace std;
using namespace cv;

int main(int argc, char *argv[])
{
Mat image = imread("C:/IMAGE.JPG");

SiftFeatureDetector detector;
vector<KeyPoint> keypoints;

detector.detect(image, keypoints);

return 0;
}

知道我做错了什么吗?

最佳答案

这段代码:

Mat image = imread("C:/IMAGE.JPG");

可能会失败。在将它作为参数传递给其他函数之前,你需要确保 image 已成功加载:

if (!image.data )
{
cout << "Could not load image" << endl ;
return -1;
}

如果 imread() 失败并且该文件存在于该位置,您可能需要使用另一个斜线并将其转义:

Mat image = imread("C:\\IMAGE.JPG");

如果图像加载成功但崩溃仍然存在,请尝试将图像加载为灰度:

Mat image = imread("C:\\IMAGE.JPG", 0);

关于c++ - VS2010 和 OpenCV : Stack around a variable was corrupted,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12417529/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com