c++ - OpenCV can`t find image -


i trying basic tutorial found here http://bsd-noobz.com/opencv-guide/40-1-load-and-display-an-image handles loading , displaying image. doing in visual studio 2012.

i have placed image file "lena.png" in debug folder beside exe file. when try execute exe file terminal replies "cannot load image!". have tried in release folder same result.

this code have program:

#include <opencv2/highgui/highgui.hpp> #include <iostream>  using namespace cv; using namespace std;  int main(int argc, char** argv) {     if(argc > 1){         cout << argv[1] << endl;     }      mat img = imread("lena.png", cv_load_image_color);      if (img.empty())     {         cout << "cannot load image!" << endl;         return -1;     }      namedwindow("image", cv_window_autosize);     imshow("image", img);     waitkey(0);      return 0; } 

i not understand why hapens, picture in same directory .exe , following example code letter. please me understand why can`t find file!

edit: hahahahaha fixed it. in rage fit changed additional dependencies *.lib *d.lib since running debugging version , worked. if read tutorial on how use opencv says there difference since compiled thought work. going try release version , see if works (with changing dependencies of course).

edit 2: yea worked. answer own question need link correct .lib files include folder dependencies debug , release build. ones ending "d" debug , others release. maybe not surprising found problem there is.

maybe has file formats imread. try .jpg or of valid image formats.to quote here,

the function imread loads image specified file , returns it. if image can not read (because of missing file, improper permissions, unsupported or invalid format), function returns empty matrix ( mat::data==null ).


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -