Answer the question
In order to leave comments, you need to log in
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
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.
I'm afraid so. In uncompressed form, only previews are available (any barcode scanners, etc. use exactly preview callbacks).
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.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question