最終更新:2018-02-19 (月) 14:52:29 (2404d)
android.hardware.Camera
Top / android.hardware.Camera
The Camera class is used to set image capture settings, start/stop preview, snap pictures, and retrieve frames for encoding for video.
ドキュメント
- http://developer.android.com/reference/android/hardware/Camera.html
- http://developer.android.com/guide/topics/media/camera.html
使い方
To take pictures with this class, use the following steps:
- Obtain an instance of android.hardware.Camera from open(int).
- Get existing (default) settings with camera.getParameters().
- If necessary, modify the returned Camera.Parameters object and call camera.setParameters(Camera.Parameters).
- If desired, call camera.setDisplayOrientation?(int).
- Important: Pass a fully initialized SurfaceHolder to camera.setPreviewDisplay?(SurfaceHolder). Without a surface, the camera will be unable to start the preview.
- Important: Call camera.startPreview() to start updating the preview surface. Preview must be started before you can take a picture.
- When you want, call takePicture(Camera.ShutterCallback?, Camera.PictureCallback?, Camera.PictureCallback?, Camera.PictureCallback?) to capture a photo. Wait for the callbacks to provide the actual image data.
- After taking a picture, preview display will have stopped. To take more photos, call startPreview() again first. Call stopPreview() to stop updating the preview surface.
- Important: Call release() to release the camera for use by other applications. Applications should release the camera -immediately in onPause() (and re-open() it in onResume()).
ネステッドクラス
インターフェイス
Camera.AutoFocusCallback Callback interface used to notify on completion of camera auto focus. Camera.AutoFocusMoveCallback? Callback interface used to notify on auto focus start and stop. Camera.ErrorCallback? Callback interface for camera error notification. Camera.FaceDetectionListener Callback interface for face detected in the preview frame. Camera.OnZoomChangeListener? Callback interface for zoom changes during a smooth zoom operation. Camera.PictureCallback? Callback interface used to supply image data from a photo capture. Camera.PreviewCallback Callback interface used to deliver copies of preview frames as they are displayed. Camera.ShutterCallback? Callback interface used to signal the moment of actual image capture.
クラス
android.hardware.Camera.Area? The Area class is used for choosing specific metering and focus areas for the camera to use when calculating auto-exposure, auto-white balance, and auto-focus. android.hardware.Camera.CameraInfo Information about a camera android.hardware.Camera.Face Information about a face identified through camera face detection. android.hardware.Camera.Parameters Camera service settings. android.hardware.Camera.Size? Image size (width and height dimensions).
メソッド
final Camera.Parameters Camera.getParameters() Returns the current settings for this Camera service. final void Camera.setPreviewCallback(Camera.PreviewCallback cb) Installs a callback to be invoked for every preview frame in addition to displaying them on the screen. final void Camera.setPreviewDisplay(SurfaceHolder holder) Sets the Surface to be used for live preview. final void Camera.setPreviewTexture(SurfaceTexture surfaceTexture) Sets the SurfaceTexture to be used for live preview.
- APIレベル8で追加。バッファを使いまわせる
final void Camera.addCallbackBuffer?(byte[] callbackBuffer) Adds a pre-allocated buffer to the preview callback buffer queue. final void Camera.setPreviewCallbackWithBuffer(Camera.PreviewCallback cb) Installs a callback to be invoked for every preview frame, using buffers supplied with Camera.addCallbackBuffer?(byte[]), in addition to displaying them on the screen.
ソースコード
- AOSP/frameworks/base/core/java/android/hardware/Camera.java
- AOSP/frameworks/base/core/jni/android_hardware_Camera.cpp