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?
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With