#include 'cv.h' #include 'highgui.h' #include <stdio.h> int main(int argc, char* argv[]){ cvNamedWindow('Window1', CV_WINDOW_AUTOSIZE); IplImage* image = 0; ->->image = cvLoadImage(argv[1]);<-<- if(!image) printf('Unable to load image!'); cvShowImage('Window1', image); char c = cvWaitKey(0); cvReleaseImage(&image); cvDestroyWindow('Window1'); return 0; }
If I replace the indicated line with cvLoadImage('247.png') I get a blank window and image remains equal to zero
If I run the exe and give it 247.png as an argument, it’s just dandy. If I put the ‘247.png’ right into the code and build and run it Visual Studio 2008, it fails. If I build and run from the command prompt, it works.
Why is this? I’m a little bit weary of moving forwards without getting this down.
Under Project->Properties->Configuration Properties->Debugging there is a field ‘Working Directory’. Set that to the directory you want to execute in and that should fix the problem.