I'm trying to develop a simple welcome world for OpenCV, but I'm running out of ideas on why it doesn't work.
When I compile and run this code:
#include <cv.h> #include <highgui.h> int main(int argc, char* argv[]) { IplImage* img = cvLoadImage( "myjpeg.jpg" ); cvNamedWindow( "MyJPG", CV_WINDOW_AUTOSIZE ); cvShowImage("MyJPG", img); cvWaitKey(0); cvReleaseImage( &img ); cvDestroyWindow( "MyJPG" ); return 0; }
I get a gray box about 200x200 in size instead of the specified .jpg file. If I use another jpg, I get the same window, and if I put an invalid file name, I get a very small window (expected).
I am using Visual Studio 2008 under Windows 7 Professional.
Most sample programs seem to work just fine, so I double-confuse how this code loads the jpg sample just fine, but in the code above it doesn't work (even tried the jpeg sample).
Update
Compiled executables work fine, however the Visual Studio 2008 debugger loads a null pointer into img every time I try to run the debugger - regardless of whether the file location is implicit or explicit.
c ++ visual-studio-2008 opencv visual-studio-debugging
Nerf42
source share