Problem with imread in debug mode [closed]
Hi
I am trying to use imread() in a very simple manner:
const string ImageName("D:/SomeImage.tif");
Mat Image=imread(ImageName);
the problem is that the returned Mat is empty.
I compiled the opencv sources myself (Ver 2.4.6.0) using VS 2008 SP1 in both debug and release modes.
Have started debugging the code in debug mode where I have used the debug lib files for linker input (i.e., opencv_somemodule246d.lib etc.) and copied the corresponding debug dlls and pdb files to the application directory.
When the debugger hit the imread() line I steped into imread and saw that the actual value passed in the string for the file name was garbage so obviously it returned empty matrix. I also tried to use non const string and const and non const char* for the image name - the results were identical!. I should note that in release mode there isn't any problem and the passed string is the correct one.
Any ideas?
Edit : Changed my typo ImageName("D:\SomeImage.tif") to ImageName("D:/SomeImage.tif"); I have actually tried it with "\\" and with "/" for the file separator - the result were the same: garbage passed string - once again this happens only on debug mode, in release - everything OK!
I just tested the following configuration
which works just perfectly using opencv 2.4.6 and a correctly configured project. Are you sure your path is correct? Always use front slashes, it will make your system work on each operating system!
Yes, I am sure about the path and I also used "/". Did you tested it in debug mode? Once again, the problem, as reflects when debugging the code, is that the string which actually got passed to imread was different than the one I specified.
I always test in debug mode ... but it works also in release. Edit your question and post your complete configuration with screens? I could take a look!
Just a guess: Do check your "Character Set" setting in the VS Project Settings (Configuration Properties->General) for Debug mode. It should use the same setting as the Release mode and OpenCV lib (i.e. Multi-Byte Character Set).
Close enough!!. Problem solved!. Actually, though the "Character Set" wasn't set that wasn't the problem. The problem was "Runtime library" in Project settings->C/C++ -> Code Generation which should be "Multi-threaded Debug DLL" instead of just "Multi-threaded" Thank U!!