Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I am using this code:

#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <cv.h>
#include <highgui.h>
#include <cxcore.h>
#include <cxtypes.h>

int main(int argc, char* argv[])
{
 IplImage* img = cvLoadImage( "dow2oc8.png" );
 cvNamedWindow( "Example1", CV_WINDOW_AUTOSIZE );
 cvShowImage("Example1", img);
 cvWaitKey(0);
 cvReleaseImage( &img );
 cvDestroyWindow( "Example1" );
 return 0;
}

I took out the pound signs and carrets and I can't get it to read the image file, I have added the file to the project. What should I do next

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
149 views
Welcome To Ask or Share your Answers For Others

1 Answer

My first guess would be that it's attempting to load the png file from a location other than where the png file actually is. It doesn't matter whether it's in the project or not - where is it on disk? Cause, with no path specified, it should probably be in the folder your executable is running from - which, if you added it to the project, it probably isn't.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...