Issue with reading an image using “cv::imread” fun

2019-01-14 21:21发布

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?

2条回答
Fickle 薄情
2楼-- · 2019-01-14 21:59

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.

查看更多
仙女界的扛把子
3楼-- · 2019-01-14 22:00

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.

查看更多
登录 后发表回答