Opencv Imread(Filename) Fails in Debug Mode When Using Release Libraries

OpenCV imread(filename) fails in debug mode when using release libraries

I'll never get tired of telling people that the C++ OpenCV interface for Windows has the wierdest bugs.

Write a small test using the C interface to check if it works or not (cvLoadImage(), etc).

Update: now that you know that the C interface works properly, you can either go to the mailing list and report this bug there or dig into the code yourself to find why it fails.

opencv 2.3.* imread not working

The problem was due to mixing up debugging and release builds. If building in debug mode, the debug libs are needed. On unix this dont seem to be a problem.

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

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.

Why is imread() always returning null data?

To debug your issue you should try to confirm that the image path is correct.

As suggested in the comments, try specifying the full absolute path of the file. Remember to to use escape slashes if you are on windows (e.g. c:\a.bmp will need to be "c:\a.bmp")

OR

If you are executing your application from Visual Studio then you can configure the working directory to be that of the bitmap too! (OpenCV cvLoadImage() does not load images in visual studio debugger?)

You can also try using cvLoadImage instead of imread. If cvLoadImage can open the file then it is possible that you have a mix of release and debug libraries causing you an issue as per:

  • OpenCV imread(filename) fails in debug mode when using release libraries


Related Topics



Leave a reply



Submit