Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Get Full Resolution & Uncompressed Image Data with Android Camera?

I want to get a full resolution(and not compressed)image data, then i can do some image processing.

As far as i know, the android api takePicture (shutter, raw, jpg) can do something.But what i need is not a compressed JPEG data, a uncompressed image data instead.Also I knew the raw callback doesn't work according to some posts i have read.

I also found the api onPreviewFrame, and the larggest picture size i got from this is 1280*720(use setPreviewSize) while the original image i caputure from the camera is a resolution of 1952*3264.

Also, Intent.putExtra(MediaStore.EXTRA_OUTPUT, uri) may be help, but it likely that the file of the uri should be a jpeg file which is a compressed format.

But is there anyway to get a full size(the same as captured) and uncompressed(not a JPEG) image data?

like image 202
napoleon bonaparte Avatar asked Oct 02 '22 15:10

napoleon bonaparte


1 Answers

The documentation for takePicture() clearly says that raw data can be requested, but the callback is optional. Today, most of devices do not support raw callback. This should not be a surprise: modern cameras perform Jpeg compression in hardware, and the memory bus between the camera and the application processor cannot handle 24 Megabyte of raw data fast enough (for a modest 8 megapixel camera).

Avoid temptation to use preview callback instead of takePicture(): even at same resolution, image qualiity of a still picture will be better. Preview image may have imprecise autofocus, stabilization, exposure and even white balance.

like image 176
Alex Cohn Avatar answered Oct 07 '22 21:10

Alex Cohn