Camera API 介绍系列文章:
Android Camera之 --- Camera API说明(一)
Android Camera之 --- Camera API说明(二)
Android Camera之 --- Camera API说明(三)
下面重点介绍Camera API内的回调函数和内部辅助类,以及msg的相应过程。
首先来认识以下Camera内部的回调接口,使用者必须实现器大部分很的回调接口以便更好的操作camera设备。
1. interface ShutterCallback
// 回调接口,快门声
// takePicture(ShutterCallback, PictureCallback, PictureCallback, PictureCallback)的第一个参数,被触发来播放一个快门声音
@Deprecated
public interface ShutterCallback
{
/**
* 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.
*/
void onShutter();
}
// 回调接口, 提供拍照时的数据,数据类型有:Raw picture, posview picture, JPEG picture.
// takePicture(ShutterCallback, PictureCallback, PictureCallback, PictureCallback)的后三个参数都为PictureCallback.
// 分别为RawPictureCallback, PostViewPictureCallback, JPEGPictureCallback
@Deprecated
public interface PictureCallback {
/**
* Called when image data is available after a picture is taken.
* The format of the data depends on the context of the callback
* and {@link Camera.Parameters} settings.
*
* @param data a byte array of the picture data
* @param camera the Camera service object
*/
void onPictureTaken(byte[] data, Camera camera);
};
3. interface PreviewCallback
// 回调接口,用来获取YUV数据,格式必须支持NV21和YV12.
// 想获取YV12,则必须调用Camera.Parameters。setPreviewFormat(int)进行设置,默认为NV21数据
@Deprecated
public interface PreviewCallback
{
/**
* Called as preview frames are displayed. This callback is invoked
* on the event thread {@link #open(int)} was called from.
*
* <p>If using the {@link android.graphics.ImageFormat#YV12} format,
* refer to the equations in {@link Camera.Parameters#setPreviewFormat}
* for the arrangement of the pixel data in the preview cal

本文是Android Camera API系列的第二部分,主要讲解Camera API中的回调接口如ShutterCallback、ErrorCallback和FaceDetectionListener,以及辅助类Face、Size和Area的用法。Face用于存储人脸识别信息,Size表示分辨率,Area则在3A模式中定义矩形区域。所有的回调通过postEventFromNative方法由Handler处理。
最低0.47元/天 解锁文章
2267

被折叠的 条评论
为什么被折叠?



