imread无法读取图像
imread fails to read image
我一直在做一个项目来检测离线手写签名。我遇到了一个基本问题。我的程序无法使用imread()
功能。它不会显示任何错误,但也不会加载图像。如果我检查图像,它会显示我指定的错误消息。我使用的是带有Microsoft Visual C++2010的OpenCV 2.4.10,而我使用的则是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:UserssonyDownloadsShareitPhotoNew 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文档提供了使用Visual Studio设置OpenCV的教程,还有一些示例代码使用cv::imread加载底部包含的图像。
我最近一直在使用opencv,这是迄今为止我发现的最好的Visual Studio opencv教程:
http://opencv-srf.blogspot.com.es/2013/05/installing-configuring-opencv-with-vs.html
主要,你需要做的是正确配置它如下:
设置环境变量在:我的电脑->属性->高级系统设置->环境变量->使用以下参数创建一个新的:变量名:OPENCV_DIR,变量值:C:\OPENCV\build\
编辑变量"Path",为此,在"变量名称"行的末尾添加以下内容:;%OPENCV_DIR%\x86\vc11\bin
然后您应该配置Visual Studio:
右键单击项目名称,然后单击"道具"在C/C++->常规->附加包含目录中,复制并粘贴"$(OPENCV_DIR)\Include"
在Linker->General->Additional Library Directories中,复制并粘贴$(OPENCV_DIR)\x86\vc11\lib
在Linker->Input->Additional dependencies中,单击Edit并添加您在"C:\opencv\build\x86\vc11\lib"中找到的库
注意:如果您的系统是64位而不是32位,请将"x86"替换为"x64"
你能发布你的代码来分析这个问题吗?
- 增加 gil 读取图像错误
- 如何使用 OpenImageIO 和 read_tiles() 读取平铺图像
- 在 matlab 中调用 opencv 的图像时,无法读取 C++ 中的图像
- 这是我的程序,C++使用 OpenCv 库从数据集中读取图像序列,但它没有运行
- 如何以CV_16UC1的方式读取JPG图像并在屏幕上打印?
- 使用 qt 从 postgres 读取和写入图像(大对象)
- 如何从内存中读取原始图像 (YUV 4:2:2) 格式的图像数据
- 如何在Visual Studio中使用ITK配置的C 读取图像
- 通过插座读取Python中的OpenCV图像
- C 读取/写作PPM图像文件灰色图像
- 如何在Android NDK中的硬盘驱动器中读取图像
- OpenCV 3.2.0:读取 Canny 图像以训练 SVM
- 如何在VTK DICOM阅读器中读取图像类型(0008,0008)
- 使用C++程序中的拉斯皮斯蒂尔读取相机图像
- 从C 中的文件中读取图像,然后传递到Libharu的绘制方法
- 如何在OpenCV中将图像读取为双精度
- 将图像读取为二进制文件
- C++ 模板复杂图像读取类执行时间慢,声明和实现分离
- 如何将opencv图像读取为咖啡格式以进行实时预测
- 将字节数组从位图图像读取到坐标X和Y中