I
I
iOrange2010-09-24 15:56:49
Google
iOrange, 2010-09-24 15:56:49

Android SDK: how to get uncompressed photo?

Good afternoon!

I am writing an Android application that should receive a photo and process it in a special way. I read in the docks that takePicture of the Camera class takes callbacks as parameters, into which the data received during the shooting (rawCallback and jpegCallback) are then transferred.
As a result of experiments, it turned out that jpegCallback stably receives a ready-made JPEG file, which can be immediately written to a USB flash drive, but null comes to rawCallback. Googling doesn't help. The option to unpack JPEG and work with it is not suitable in many respects (speed, quality, etc.)

Please tell me what to do?

PS. Tested on Google Nexus ONE and HTC Desire.
P.S.S. I am attaching an excerpt from the code:

public void TakePicture()
{
 if (m_Camera != null && m_CanDoPhoto)
 {
  m_CanDoPhoto = false;
  m_Camera.takePicture(shutterCallback, rawCallback, jpegCallback);
 }
}

PictureCallback rawCallback = new PictureCallback()
{
 public void onPictureTaken(byte[] _data, Camera _camera)
 {
  String path = Environment.getExternalStorageDirectory().toString();
  File file = new File(path, "MyTestPhoto.raw");
  try
  {
   FileOutputStream fOut = new FileOutputStream(file);
   fOut.write(_data);
   fOut.flush();
   fOut.close();
  }
  catch (FileNotFoundException e)
  {
   e.printStackTrace();
  }
  catch (IOException e)
  {
   e.printStackTrace();
  }
 }
 }
};

PictureCallback jpegCallback = new PictureCallback()
{
 public void onPictureTaken(byte[] _data, Camera _camera)
 {
  m_CanDoPhoto = true;
  m_Camera.startPreview();
 }
};

Answer the question

In order to leave comments, you need to log in

4 answer(s)
A
apangin, 2010-09-26
@iOrange

There is an answer directly from the android developer here:
groups.google.com/group/android-developers/browse_thread/thread/65191ea020f6bb27/
In short, rawCallback has never worked and likely never will.
Callbacks of this kind were not intended for signal processing, but only for taking pictures.

A
apangin, 2010-09-26
@apangin

I'm afraid so. In uncompressed form, only previews are available (any barcode scanners, etc. use exactly preview callbacks).

S
stepango, 2011-06-15
@stepango

In uncompressed form, no one will give you an image due to the limitation on the amount of memory allocated for the application. An uncompressed 5MP picture without compression will weigh about 40mb, while desire has a limit per application of 24mb.

I
iOrange, 2010-09-26
@iOrange

That is, it turns out that it is impossible to get a “raw” image from the camera? Only in the form of already compressed JPEG?
Aren't there any workarounds? Maybe with the help of Native SDK?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question