OpenCV can't read image!

和自甴很熟 提交于 2019-12-13 04:15:17

问题


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


回答1:


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.



来源:https://stackoverflow.com/questions/1533542/opencv-cant-read-image

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!