Ask Your Question
0

OpenCV with Android camera surface view

asked 2013-10-06 14:39:35 -0600

Bella gravatar image

updated 2013-10-06 17:04:47 -0600

berak gravatar image

Hello...I am trying to develop an image recognition android application... I am using the customized camera using surface view.... (As Here)in android to capture images ... I want to process the captured images using opencv , how can i get the captured image and convert it to mat ? also is there a way to save the captured image Temporary ? thanks in advance

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2013-10-07 11:36:51 -0600

Daniil Osokin gravatar image

Hi Bella, as explained in details here by Andrey Kamaev, you can use Highgui.imdecode function for conversion data in a JPEG format to Mat. So full code snippet looks like this:

Mat jpegData = new Mat(1, data.length, CvType.CV_8UC1);
jpegData.put(0, 0, data);
Mat bgrMat = Highgui.imdecode(jpegData, Highgui.IMREAD_COLOR);

For the second issue, you can save image in a number ways:

  • through FileOutputStream on device's storage;
  • use Highgui.imwrite to save a Mat;
  • just copy byte[] data into class member buffer.
edit flag offensive delete link more

Comments

1

thanks alot @Daniil Osokin :)

Bella gravatar imageBella ( 2013-10-08 12:06:18 -0600 )edit
Bella gravatar imageBella ( 2013-10-10 17:05:28 -0600 )edit

Question Tools

Stats

Asked: 2013-10-06 14:39:35 -0600

Seen: 1,650 times

Last updated: Oct 07 '13