Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Camera: Difference between PictureCallback, ShutterCallback and PreviewCallback

Tags:

android

camera

I am currently working on my Final Year Project which is building an Android Camera App.

I am confused about the Camera interfaces : PictureCallback, ShutterCallback and PreviewCallback.

I know that when I use Camera.takePicture(), PictureCallback will be called. But what about ShutterCallback and PreviewCallback? When do I use them?

I have search thru the internet but I still don't have a clear idea of how to use them. Can anyone provide a clear explanation for these 3 callbacks?

like image 481
Zack Avatar asked Oct 25 '13 06:10

Zack


2 Answers

ShutterCallback is used to provide feedback to the user that the camera is working, for example to play a sound, animate your shutter button, etc.

PreviewCallback gives you a byte array of the current camera preview frame as it gets captured by the camera sensor. Use this if you want to alter the frames in some sort, like to display rectangles over detected faces.

PictureCallback gives you a byte array that represents the captured picture. The format of the picture (jpg, raw or postview) depends on where you passed the callback in takePicture()

For further reference, you should read the documentation for Camera and its related interfaces and classes.

like image 167
npace Avatar answered Nov 09 '22 08:11

npace


I think google's documents give enough explanation for your question :

Camera.ShutterCallback
public abstract void onShutter ()

Called as near as possible to the moment when a photo is captured from the sensor. This is a good opportunity to play a shutter sound or give other feedback of camera operation. This may be some time after the photo was triggered, but some time before the actual data is available.

Camera.PreviewCallback  
public abstract void onPreviewFrame (byte[] data, Camera camera)

Called as preview frames are displayed. This callback is invoked on the event thread open(int) was called from.

If using the YV12 format, refer to the equations in setPreviewFormat(int) for the arrangement of the pixel data in the preview callback buffers.

You can use ShutterCallback when a picture is taken and PreviewCallBack to capture frames from camera. Keep in mind PreviewCallBack has some problems. see link.

references:
http://developer.android.com/reference/android/hardware/Camera.ShutterCallback.html
http://developer.android.com/reference/android/hardware/Camera.PreviewCallback.html

like image 30
Devrim Avatar answered Nov 09 '22 10:11

Devrim