Issue with reading an image using “cv::imread” function in OpenCv

和自甴很熟 提交于 2019-12-17 16:28:03

问题


I have got a problem with some basic OpenCV code. Here is my code:

 cv::Mat src;
 src=imread("Calibration.bmp",0);

 if (src.empty())
  cout << "Cannot load image" << " ";
 else
  cout << src.cols << " " << src.rows << " ";

Unfortunatelly cv::imread returns NULL matrix with any kind of input image (I have tried .bmp, .jpg). The filename seems to be working fine (program does not end with error), as using wrong filename generates an error message. I have tried using oldstyle "CvLoadImage" but same result occurred. Does anyone have any idea how to fix this?


回答1:


Ok, I fixed the problem... Problem arises when you are mixing up release and debug OpenCV libs. I've changed paths and libs names in project properties and "cv::imread" works just fine.




回答2:


I had this behavior when trying to load an ARGB bitmap image (which I tried to load with color). Converting the bitmap to RGB (24bpp) solved the problem.



来源:https://stackoverflow.com/questions/2584273/issue-with-reading-an-image-using-cvimread-function-in-opencv

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