使用opencv2.3 imread无法读取图像 [英] Can not read image with opencv2.3 imread
问题描述
您好,我想通过使用opencv的imread函数读取图像在链接(http://opencv.itseez.com/doc/tutorials/introduction/display_image/display_image.html#display-image)。我有VS2010与64位窗口7.每次我尝试我得到错误消息无图像数据,但我想要读取的图像是在同一文件夹中的代码。有人可以帮助我如何读取图像的imread函数?我的代码如下:
#includestdafx.h
#include< cv.h>
#include< highgui.h>
using namespace cv;
int _tmain(int argc,_TCHAR * argv [])
{
Mat image;
image = imread(al.jpg);
if(argc!= 2 ||!image.data)
{
printf(no image data \\\
);
return -1;
}
namedWindow(Display Image,CV_WINDOW_AUTOSIZE);
imshow(Display Image,image);
waitKey(0);
return 0;
}
IplImage * img = cvLoadImage(Image_Name);
p>
然后你可以将它转换为cv :: Mat using,
Mat mat(img);
Hello I am trying to read an image by using imread function of opencv as in the link (http://opencv.itseez.com/doc/tutorials/introduction/display_image/display_image.html#display-image). I have VS2010 with 64 bit windows 7. Each time I try I get error message "no image data", however the image I want to read is in the same folder with codes. Can someone please help me how to read an image with imread function? My code is as below:
#include "stdafx.h" #include <cv.h> #include <highgui.h> using namespace cv; int _tmain(int argc, _TCHAR* argv[]) { Mat image; image = imread("al.jpg"); if(argc != 2 || !image.data ) { printf("no image data \n"); return -1; } namedWindow("Display Image", CV_WINDOW_AUTOSIZE); imshow("Display Image", image); waitKey(0); return 0; }
解决方案It you can load image using
IplImage *img=cvLoadImage("Image_Name);
Then you can convert this into cv::Mat using,
Mat mat(img);
这篇关于使用opencv2.3 imread无法读取图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!