FacundoGFlores
FacundoGFlores

Reputation: 8118

OpenCV imread issue

I'm compiling a simple project on VS2012 with OpenCV 2.4.7.

So when I do:

cv::Mat img = cv::imread("C:\lena.jpg",1);

Then I looked for a solution for the following error:

OpenCV Error: Assertion Failed (size.width>0 && size.height>0) in unknown function

So, I put this:

IplImage* img1 = cvLoadImage("C:\lena.jpg", 1);
Mat img(img1);

And it works well. Is this just only one solution?

PS: I had the same problem on Ubuntu, and I tried changing the path in different ways.

Upvotes: 0

Views: 1073

Answers (1)

Liam McInroy
Liam McInroy

Reputation: 4366

This is because of your escape sequencing. Look at the below path:

C:\\Users\\name\\Pictures\\Dell WebCam Central\\img.jpg

This will compile normally, as will

C://Users//name//Pictures//Dell WebCam Central//img.jpg

However, with improper escape sequencing, as you had used, then the assertion will fail.

See escape sequences for more information.

Upvotes: 1

Related Questions