Ask Your Question
0

OpenCV Error: Assertion failed

asked 2016-02-02 02:27:44 -0600

yuyue62 gravatar image

OpenCV Error: Assertion failed (size.width>0 && size.height>0) in cv::imshow, fi le D:\opencv\sources\modules\highgui\src\window.cpp, line 269

The code is:

image description

But I also tried cv::Mat patternImage = cv::imread("F:\opencv - Copy (2)\Pattern.jpg"); and cv::Mat patternImage = cv::imread("F:/opencv - Copy (2)/Pattern.jpg");

But the error is always the same.

In another computer I use vs2010 and opencv 2.32 this error does not exsit. But in this computer I use vs2013 and opencv 2.49 with opengl. I meet this error. Can anybody help me please. Thanks a lot.

Add: strange thing is the same code can run if I create another project, but when it added to my current project, it doesn't work.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2016-02-02 02:35:03 -0600

berak gravatar image

updated 2016-02-02 02:36:43 -0600

please add a check after reading:

 if (a.empty())
 {
       cerr << "image was not read !" << endl;
       return 1;
 }

also, check your linker settings. make sure you're using debug opencv libs with debug build and release libs with release strictly

edit flag offensive delete link more

Comments

Thanks a lot. I check my libs and found the problem!

yuyue62 gravatar imageyuyue62 ( 2016-02-02 03:00:18 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2016-02-02 02:10:21 -0600

Seen: 12,471 times

Last updated: Feb 02 '16