c++ imread / cvLoadImage fails on android?

949 views
Skip to first unread message

Pramod Sharma

unread,
Feb 27, 2012, 3:40:27 AM2/27/12
to android...@googlegroups.com
Folks,

I am writing c++ opencv code through jni in Android. Most of the things work seamlessly however I am hitting a very basic problem. When I try to load a png file stored on sd card using imread, it returns NULL image. I verified that image file does exist and I can open in using file.open in C++.

I tried using opencv C interface i.e. cvLoadImage which also return NULL IplImg.

Any idea whats going on here? How can I debug this? I am running this on nexus S. I have already wasted more than 2 hours google-ing but can't find anything -:(

Cheers,
Pramod

Andrey Pavlenko

unread,
Feb 27, 2012, 3:58:12 AM2/27/12
to android...@googlegroups.com
Are you sure the file contains a correct image?

Pramod Sharma

unread,
Feb 27, 2012, 4:02:43 AM2/27/12
to android...@googlegroups.com
Yes, I am able to read it on java side as:

            Mat img = Highgui.imread(<path_to_file_onsdcard>, 0);

works (i verified width and height of img)! But on C++ side following code gives empty image:

        Mat img = imread(<path_to_file_onsdcard>, CV_LOAD_IMAGE_GRAYSCALE );

Thanks for quick response. Any idea how to debug this?

-Pramod

Pramod Sharma

unread,
Feb 27, 2012, 4:03:15 AM2/27/12
to android...@googlegroups.com
Btw its png file. I tried converting this to BMP as well. It did not help.

Andrey Pavlenko

unread,
Feb 27, 2012, 4:09:08 AM2/27/12
to android...@googlegroups.com
Then I guess there is something wrong with your native library building procedure...


On Monday, February 27, 2012 1:03:15 PM UTC+4, Pramod Sharma wrote:
Btw its png file. I tried converting this to BMP as well. It did not help.

Reply all
Reply to author
Forward
0 new messages