最終更新:2018-02-19 (月) 14:52:29 (2251d)  

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.

ドキュメント

使い方

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.AutoFocusCallbackCallback 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.FaceDetectionListenerCallback 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.PreviewCallbackCallback 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.

クラス

メソッド

  • APIレベル8で追加。バッファを使いまわせる
    final voidCamera.addCallbackBuffer?(byte[] callbackBuffer)Adds a pre-allocated buffer to the preview callback buffer queue.
    final voidCamera.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.

ソースコード

関連

参考