About the imread in OpenCV 2.0

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

About the imread in OpenCV 2.0

happyharrycn
For the new opencv2.0, I fetch the code from the SVN (Rev 2367) and compile it with VS2005 (Win XP). Everything runs smoothly, except the new imread() function. This function does not work at all!

As I debug into the source code, it confused me a lot. The imread() function calles the imread_() function, which is also called by the cvLoadImage() function (works fine), and quits at the decoder.empty check. The problem is simple, the (const string&) filename received by the imread() function is wrong. For example:

...
string filename = "d:/test.jpg";
Mat img = imread(filename);
...

The parameter received by the imread() function is actually two byte of 0xCC + the orignal string. In the aforementioned code, the filename received by the imread() is "0xCC 0xCC d:/test.jpg". This is really a wield problem for me. As my understanding, for the function

Mat imread( const string& filename, int flags )

the parameter, saying filename, should be OK across different platforms. Can someone help me with this? Thanks very much!

Moreover, I have updated the VC 2008 Redistributable Package, as mentioned by someone in the discussion group, and that won't help.



Reply | Threaded
Open this post in threaded view
|

Re: About the imread in OpenCV 2.0

Matthias Schmieder
Hi,

I have exactly the same problem. Can someone tell me if this is fixed in the new svn snapshot?

Thanks!


happyharrycn wrote
For the new opencv2.0, I fetch the code from the SVN (Rev 2367) and compile it with VS2005 (Win XP). Everything runs smoothly, except the new imread() function. This function does not work at all!

As I debug into the source code, it confused me a lot. The imread() function calles the imread_() function, which is also called by the cvLoadImage() function (works fine), and quits at the decoder.empty check. The problem is simple, the (const string&) filename received by the imread() function is wrong. For example:

...
string filename = "d:/test.jpg";
Mat img = imread(filename);
...

The parameter received by the imread() function is actually two byte of 0xCC + the orignal string. In the aforementioned code, the filename received by the imread() is "0xCC 0xCC d:/test.jpg". This is really a wield problem for me. As my understanding, for the function

Mat imread( const string& filename, int flags )

the parameter, saying filename, should be OK across different platforms. Can someone help me with this? Thanks very much!

Moreover, I have updated the VC 2008 Redistributable Package, as mentioned by someone in the discussion group, and that won't help.


Reply | Threaded
Open this post in threaded view
|

Re: About the imread in OpenCV 2.0

ellmi
This post has NOT been accepted by the mailing list yet.
In reply to this post by happyharrycn
The Problem is when you mix the release dlls and the debug dlls in the Linker properties. Don't mix it and you don't have the problem.

thx to Matthias who helped me to solve the problem.

lg Christian
Reply | Threaded
Open this post in threaded view
|

Re: About the imread in OpenCV 2.0

michaelrepucci
In reply to this post by Matthias Schmieder
I don't know if this was actually a problem or not, but in stable version 2.1.0 it works for me. However, I initially thought I had this problem, until I realized my mistake, so I'm posting here in case others accidentally do what I did.

Basically, I'd forgotten that in the line

const char* name = "c:\dir\file.jpg";

the back slashes are escape characters. So the line needs to read

const char* name = "c:/dir/file.jpg"; //works on Windows XP or
const char* name = "c:\\dir\\file.jpg";

Hope that helps others like me from wasting time!

:) Michael

--- In [hidden email], Matthias Schmieder <schmieder.matthias@...> wrote:

>
>
> Hi,
>
> I have exactly the same problem. Can someone tell me if this is fixed in the
> new svn snapshot?
>
> Thanks!
>
>
>
> happyharrycn wrote:
> >
> > For the new opencv2.0, I fetch the code from the SVN (Rev 2367) and
> > compile it with VS2005 (Win XP). Everything runs smoothly, except the new
> > imread() function. This function does not work at all!
> >
> > As I debug into the source code, it confused me a lot. The imread()
> > function calles the imread_() function, which is also called by the
> > cvLoadImage() function (works fine), and quits at the decoder.empty check.
> > The problem is simple, the (const string&) filename received by the
> > imread() function is wrong. For example:
> >
> > ...
> > string filename = "d:/test.jpg";
> > Mat img = imread(filename);
> > ...
> >
> > The parameter received by the imread() function is actually two byte of
> > 0xCC + the orignal string. In the aforementioned code, the filename
> > received by the imread() is "0xCC 0xCC d:/test.jpg". This is really a
> > wield problem for me. As my understanding, for the function
> >
> > Mat imread( const string& filename, int flags )
> >
> > the parameter, saying filename, should be OK across different platforms.
> > Can someone help me with this? Thanks very much!
> >
> > Moreover, I have updated the VC 2008 Redistributable Package, as mentioned
> > by someone in the discussion group, and that won't help.
> >
> >
> >
> >
> >
>
> --
> View this message in context: http://n2.nabble.com/About-the-imread-in-OpenCV-2-0-tp4112504p4249049.html
> Sent from the opencv-users mailing list archive at Nabble.com.
>