gpt4 book ai didi

c++ - imread 无法读取图像

转载 作者:太空宇宙 更新时间:2023-11-04 13:36:48 25 4
gpt4 key购买 nike

我一直致力于检测离线手写签名的项目。我遇到了一个基本问题。我的程序无法使用 imread() 函数。它没有显示任何错误,但也没有加载图像。如果我检查图像,它会显示我指定的错误消息。我正在使用 OpenCV 2.4.10 和 Microsoft Visual C++ 2010,我正在使用 Windows 8。

这是我配置OpenCV的方式的问题还是版本有问题?

我该如何克服这个问题?

如果您有任何使用 Microsoft Visual C++ 配置 OpenCV 的完美教程,请与我分享。这是我正在运行的代码。而且,在运行时,输出对话框显示,Native' 已退出,代码为 -1。现在我没有看到消息“错误:无法加载图像..!!”。但是问题还是没有解决。

#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <iostream>

using namespace cv;
using namespace std;

int main( int argc, char** argv )
{
Mat image;
image = imread("C:\Users\sony\Downloads\Shareit\Photo\New Doc 7_1.jpg",CV_LOAD_IMAGE_UNCHANGED);

if (image.empty()) //check whether the image is loaded or not
{
cout << "Error : Image cannot be loaded..!!" << endl;
//system("pause"); //wait for a key press
return -1;
}

namedWindow("MyWindow", CV_WINDOW_AUTOSIZE); //create a window with the name "MyWindow"
imshow("MyWindow", image); //display the image which is stored in the 'img' in the "MyWindow" window

waitKey(0); //wait infinite time for a keypress

destroyWindow("MyWindow"); //destroy the window with the name, "MyWindow"

return 0;
}

最佳答案

OpenCV documentation提供了使用 Visual Studio 设置 OpenCV 的教程,还有一些示例代码使用 cv::imread 加载底部包含的图像。

关于c++ - imread 无法读取图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29284381/

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