gpt4 book ai didi

c++ - cv::Mat 在 Visual C++ Express 2010 中给出错误

转载 作者:太空宇宙 更新时间:2023-11-03 22:35:01 25 4
gpt4 key购买 nike

我在 64 位计算机上有 opencv2.1 和 Visual C++ 2010 Express 编码。我之前没有问题,我可以使用其他代码,但是下面的简单代码会出错:

Unhandled exception at 0x571365af (msvcr90d.dll) in cvMatExample.exe: 0xC0000005: Access violation reading location 0x6d622e65.

#include "cvaux.h"
#include "highgui.h"
#include <stdio.h>

using namespace cv;
using namespace std;

int main(){

Mat xxx;
xxx= imread("frame.bmp",0);

namedWindow("Result",CV_WINDOW_AUTOSIZE);
imshow("Result", xxx);

return 0;

}

那么问题到底出在哪里呢?还是 cv::Mat 与我的电脑不兼容?提前致谢。

最佳答案

最好在可以时检查函数调用的返回值:

xxx = imread("frame.bmp",0);

if (!xxx .data)
{
printf("Failed to load image\n");
// deal with error
}

也许您的图像不是由 imread() 加载的。在 Windows 上通常使用双斜杠来指代完整路径:C:\\folder\\another_folder\\img.jpg

关于c++ - cv::Mat 在 Visual C++ Express 2010 中给出错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8743424/

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