Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

I am trying to run this simple OpenCV program, but i got this error:

OpenCV Error: Assertion failed (size.width>0 && size.height>0) in imshow, file .../opencv/modules/highgui/src/window.cpp, line 276

and the image shown was gray.

The code is:

include <opencv\cv.h>

include <opencv\highgui.h>

using namespace cv;

int main(int argc, char* argv) { IplImage img = cvLoadImage( "C:\Users\elala mobile\Documents\Visual Studio 2010\Projects\opencv\opencv\mypic.png" ); //change the name (image.jpg) according to your Image filename. cvNamedWindow( "Example1", CV_WINDOW_NORMAL ); cvShowImage("Example1", img); cvWaitKey(0); cvReleaseImage( &img ); cvDestroyWindow( "Example1" ); return 0; }

What's the cause of this error?

click to hide/show revision 2
No.2 Revision

updated 2017-06-16 19:52:13 -0500

berak gravatar image

I am trying to run this simple OpenCV program, but i got this error:

OpenCV Error: Assertion failed (size.width>0 && size.height>0) in imshow, file .../opencv/modules/highgui/src/window.cpp, line 276

and the image shown was gray.

The code is:

include <opencv\cv.h>

#include <opencv\cv.h>
#include <opencv\highgui.h>
  

include <opencv\highgui.h>

using namespace cv;

cv;

int main(int argc, char* char** argv) { IplImage IplImage* img = cvLoadImage( "C:\Users\elala mobile\Documents\Visual "C:\\Users\\elala mobile\\Documents\\Visual Studio 2010\Projects\opencv\opencv\mypic.png" 2010\\Projects\\opencv\\opencv\\mypic.png" ); //change the name (image.jpg) according to your Image filename. cvNamedWindow( "Example1", CV_WINDOW_NORMAL ); cvShowImage("Example1", img); cvWaitKey(0); cvReleaseImage( &img ); cvDestroyWindow( "Example1" ); return 0; }

}

What's the cause of this error?

click to hide/show revision 3
No.3 Revision

updated 2017-06-16 19:52:38 -0500

berak gravatar image

I am trying to run this simple OpenCV program, but i got this error:

OpenCV Error: Assertion failed (size.width>0 && size.height>0) in imshow, file .../opencv/modules/highgui/src/window.cpp, line 276

and the image shown was gray.

The code is:

#include <opencv\cv.h>
#include <opencv\highgui.h>

using namespace cv;

int main(int argc, char** argv)
{
    IplImage* img = cvLoadImage( "C:\\Users\\elala mobile\\Documents\\Visual Studio 2010\\Projects\\opencv\\opencv\\mypic.png" ); //change the name (image.jpg) according to your Image filename.
    cvNamedWindow( "Example1", CV_WINDOW_NORMAL );
    cvShowImage("Example1", img);
    cvWaitKey(0);
    cvReleaseImage( &img );
    cvDestroyWindow( "Example1" );
    return 0;
}

What's the cause of this error?