Ask Your Question
1

Android: Highgui.imread Help

asked 2012-09-05 09:02:41 -0500

Bia6969 gravatar image

updated 2012-09-05 09:42:18 -0500

Andrey Pavlenko gravatar image

(Android emulator + OpenCV)

I'm using the android camera app to take a picture. I am successfully able to get the newly taken picture bitmap and display it:

Bitmap theImage = (Bitmap) data.getExtras().get("data");

but now i need to get an Mat out of the picture. For that, i've been using a simple line:

Mat a = Highgui.imread("data");

I've testing it and it is always empty! How can i reach the picture then? Reaching a gallery photo would be fine as well but i don't know how.

Thanks

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
1

answered 2012-09-05 15:17:38 -0500

Rui Marques gravatar image

updated 2012-09-05 15:21:15 -0500

Maybe this is what you are looking for:

Bitmap theImage = (Bitmap) data.getExtras().get("data");

Mat theImageMat = new Mat();
Utils.bitmapToMat(theImage, theImageMat ); // converts some Bitmap to some Mat

imread() is used to read an image file from the file system directly to a Mat object.

bitmapToMat() is to convert an existing Bitmap object to a Mat object.

edit flag offensive delete link more

Comments

that was exactly it. Thanks!

Bia6969 gravatar imageBia6969 ( 2012-09-06 03:22:01 -0500 )edit
0

answered 2012-09-05 09:59:35 -0500

Andrey Pavlenko gravatar image

As per OpenCV ref man or even OpenCV JavaDoc:

The function imread loads an image from the specified file and returns it.

The string "data" doesn't look like a correct file path in a file system. You need to search the internet on discovering Android Gallery and Camera-taken-photo files paths...

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

Stats

Asked: 2012-09-05 09:02:41 -0500

Seen: 1,555 times

Last updated: Sep 05 '12