OpenCV的2.3.1无法读取图像 [英] Opencv 2.3.1 unable to read image

查看:178
本文介绍了OpenCV的2.3.1无法读取图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的Windows使用opencv 2.3.1与Visual Studio 2008年7月32位machine.I刚刚安装/提取OpenCV的2.3.1,它工作正常与Visual Studio 2008,因为我没有得到任何错误,同时编译OpenCV的code。我的问题是,该程序是无法读取任何图像。结果
我的code是

I am using Opencv 2.3.1 with visual studio 2008 on my windows 7 32 bit machine.I have just installed/extracted opencv 2.3.1 and it works fine with visual studio 2008 as I am not getting any errors while compiling a opencv code .My problem is that,the program is unable to read any image.
My code is

 #include "stdafx.h"
 #include <cv.h>
 #include <highgui.h>
 int main()
 {
 IplImage* img = cvLoadImage("C:\Users\Anks\Documents\Visual Studio 2008\Projects\examp_aishack\aishack.jpg");
 cvNamedWindow("myfirstwindow");
 cvShowImage("myfirstwindow", img);
 cvWaitKey(0);
 cvReleaseImage(&img);
 return 0;
 }

通过编写此我得到零误差,但是当我运行它出现在控制台窗口和空白(灰色)窗口appear.It多年平均值显示图像。
我已经throughly搜索互联网,却无力解决我problem.Please帮助我。
PS:我在OpenCV的新手。

By compiling this I get zero error and but when I run it the console window appears and a blank(gray) window appear.It doesnot show the image. I have throughly searched internet ,but unable to solve my problem.Please help me. PS:I am a novice in opencv.

推荐答案

您需要逃跑的斜线:

IplImage* img = cvLoadImage("C:\\Users\\Anks\\Documents\\Visual Studio 2008\\Projects\\examp_aishack\\aishack.jpg");

和它是很好的做法,以测试是否加载成功:

and it's good practice to test if the loading was successful:

if (!img)
{
    // print error
    // return -1;
}

这篇关于OpenCV的2.3.1无法读取图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆