- 嵌套类Nested Classes和接口interface:
- Camera.Area类,在计算自动曝光,自动白平衡和自动对焦时,选择相机使用的特定测光和对焦区域。
Camera.Area对象包含了两个数据参数:
rect对象,它用于指定Camera预览窗口一块矩形区域;一个权重值
weight:它告诉Camera这块指定区域应该给予的测光或调焦计算的重要性等级。
在Camera.Area对象中的Rect字段,代表了一个被映射成2000x2000单元格的矩形。坐标(-1000,-1000)代表Camera图像的左上角,(1000,1000)代表Camera图像的右下角.
The weight must range from 1 to 1000,and represents a weight for every pixel in the area
- Camera.AutoFocusCallback接口,完成相机自动对焦后的通知。
公共方法:onAutoFocus (boolean success, Camera camera)
- Camera.AutoFocusMoveCallback接口,通知自动对焦启动和停止。
公共方法:
onAutoFocusMoving(boolean start,
Camera camera)
Called when the camera auto focus starts or stops.
This is only supported in continuous autofocus modes --
FOCUS_MODE_CONTINUOUS_VIDEO and
FOCUS_MODE_CONTINUOUS_PICTURE.
- Camera.CameraInfo类,相机信息
公共方法:Camera.CameraInfo ()
常量Constants:
CAMERA_FACING_BACK Constant Value: 0 (0x00000000)
CAMERA_FACING_FRONT Constant Value: 1 (0x00000001)
Field:
canDisableShutterSound 是否禁用快门音?
facing 相机朝向的方向,It should be CAMERA_FACING_BACK or CAMERA_FACING_FRONT.
orientation 图片的方向,该值是摄像机图像需要顺时针旋转的角度,因此能在显示屏上以其自然方向正确显示
- Camera.ErrorCallback接口,相机错误通知
- Camera.Face类,通过相机脸部检测的脸部识别信息。,只在预览期间有效
-
- Camera.FaceDetectionListener接口,在预览框架中检测到脸部,通过相机脸部检测识别的脸部信息。
-
- Camera.Face() Create an empty face.
- getMaxNumDetectedFaces() 检测到设备是否支持面部识别功能
- Camera.OnZoomChangeListener接口,在平滑缩放操作期间缩放。跟相机变焦有关
-
- onZoomChange(int zoomValue, boolean stopped, Camera camera) Called when the zoom value has changed during a smooth zoom.
- Camera.Parameters类,相机服务/参数设置
-
- 公共方法: setPreviewFormat(int pixel_format) 设置预览图像的图像格式。默认 NV21,建议格式为 NV21 or YV12 所有设备都支持
- Camera.PictureCallback接口,提供拍摄照片的图像数据。图像捕获回调它
- Camera.PreviewCallback接口,提供预览框显示的副本。
-
- 公共方法:onPreviewFrame (byte[] data, Camera camera) 其中data就是实时预览帧视频
- 调用PreviewCallback的三种方法:
- Camera.ShutterCallback接口,表示实际图像捕获的时刻,当捕获图像时立刻调用它
- Camera.Size类,图像的大小(宽度和高度尺寸)
- 常量Constants:
-
- String ACTION_NEW_PICTURE 广播动作:相机拍摄的新照片,输入图片已添加到媒体商店。
- String ACTION_NEW_VIDEO 广播动作:相机拍摄的新视频,输入视频已添加到媒体商店。
- int CAMERA_ERROR_SERVER_DIED 媒体服务结束
- int CAMERA_ERROR_UNKNOWN 不明相机错误
- 公共方法Public Methods:
-
- autoFocus(Camera.AutoFocusCallback cb) 自动对焦
Callers should check
getFocusMode() to determine if this method should be called.
- setAutoFocusMoveCallback(Camera.AutoFocusMoveCallback cb) Sets camera auto-focus move callback.
- addCallbackBuffer(byte[] callbackBuffer)
- getCameraInfo(int cameraId, Camera.CameraInfo cameraInfo) Returns the information about a particular camera.
- getNumberOfCameras() Returns the number of physical cameras available on this device.
- getParameters() Returns the current settings for this Camera service.
- open(int cameraId) Creates a new Camera object to access a particular hardware camera.
- release() Disconnects and releases the Camera object resources.
- setDisplayOrientation(int degrees) Set the clockwise rotation of preview display in degrees.
- setParameters(Camera.Parameters params) Changes the settings for this Camera service.
- setPreviewCallback(Camera.PreviewCallback cb) Installs a callback to be invoked for every preview frame in addition to displaying them on the screen.
- setPreviewDisplay(SurfaceHolder holder) Sets the Surface to be used for live preview.
- setPreviewTexture(SurfaceTexture surfaceTexture) Sets the SurfaceTexture to be used for live(实时) preview.
- startPreview() Starts capturing and drawing preview frames to the screen.
- stopPreview() Stops capturing and drawing preview frames to the surface, and resets the camera for a future call to startPreview().
- takePicture(Camera.ShutterCallback shutter, Camera.PictureCallback raw, Camera.PictureCallback jpeg) Equivalent to takePicture(shutter, raw, null, jpeg).
- takePicture(Camera.ShutterCallback shutter, Camera.PictureCallback raw, Camera.PictureCallback postview, Camera.PictureCallback jpeg) Triggers an asynchronous image capture.
- setFaceDetectionListener(Camera.FaceDetectionListener listener) Registers a listener to be notified about the faces detected in the preview frame.
- startFaceDetection() Starts the face detection
- stopFaceDetection() Stops the face detection.
- setZoomChangeListener(Camera.OnZoomChangeListener listener) Registers a listener to be notified when the zoom value is updated by the camera driver during smooth zoom.
- startSmoothZoom(int value) Zooms to the requested value smoothly.
- stopSmoothZoom() Stops the smooth zoom.
- addCallbackBuffer(byte[] callbackBuffer) Adds a pre-allocated buffer to the preview callback buffer queue.
Android上使用相机的的Preview的时候,如果不使用Buffer,相机程序会反复创建销毁Byte数组,造成系统频繁垃圾回收,非常影响体验,这时可以用Buffer来进行处理。
-
- setPreviewCallbackWithBuffer(Camera.PreviewCallback cb) Installs a callback to be invoked for every preview frame, using buffers supplied with addCallbackBuffer(byte[]), in addition to displaying them on the screen.
- setOneShotPreviewCallback(Camera.PreviewCallback cb) Installs a callback to be invoked for the next preview frame in addition to displaying it on the screen.
- 保护方法Protected Methods:
- 继承方法Inherited Methods: