ゼロシャッター ラグでレイテンシを短縮する
コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
CameraX 1.2 以降、ゼロシャッター ラグをキャプチャ モードとして利用できます。ゼロシャッター ラグを有効にすると、デフォルトのキャプチャ モードに比べてレイテンシが大幅に短縮されるため、シャッター チャンスを逃さずに済みます。
ゼロシャッター ラグを有効にする
ゼロシャッター ラグを有効にするには、CAPTURE_MODE_ZERO_SHOT_LAG
を ImageCapture.Builder.setCaptureMode()
に渡します。失敗した場合、setCaptureMode()
は CAPTURE_MODE_MINIMIZE_LATENCY
にフォールバックします。
キャプチャ モードの詳細については、画像キャプチャ ガイドをご覧ください。
仕組み
ゼロシャッター ラグは、最新の 3 つのキャプチャ フレームを保存するリングバッファを使用します。ユーザーがキャプチャ ボタンを押すと、CameraX は takePicture()
を呼び出し、リングバッファはキャプチャしたフレームを、ボタン押下のタイムスタンプに最も近いタイムスタンプで取得します。次に CameraX はキャプチャ セッションを再処理して、そのフレームから画像を生成し、JPEG 形式でディスクに保存します。
前提条件
ゼロシャッター ラグを有効にする前に、isZslSupported()
を使用して、デバイスが次の要件を満たしているかどうかを確認してください。
- Android 6.0(API レベル 23)以降をターゲットとしている。
PRIVATE
の再処理をサポートしている。
デバイスが最小要件を満たしていない場合、CameraX は CAPTURE_MODE_MINIMIZE_LATENCY
にフォールバックします。
ゼロシャッター ラグは、画像キャプチャでのみ使用できます。動画キャプチャやカメラ拡張機能では有効にできません。
最後に、フラッシュを使用するとレイテンシが増加するため、フラッシュが ON または AUTO モードの場合、ゼロシャッター ラグは機能しません。フラッシュ モードの設定について詳しくは、setFlashMode()
をご覧ください。
このページのコンテンツやコードサンプルは、コンテンツ ライセンスに記載のライセンスに従います。Java および OpenJDK は Oracle および関連会社の商標または登録商標です。
最終更新日 2025-07-27 UTC。
[[["わかりやすい","easyToUnderstand","thumb-up"],["問題の解決に役立った","solvedMyProblem","thumb-up"],["その他","otherUp","thumb-up"]],[["必要な情報がない","missingTheInformationINeed","thumb-down"],["複雑すぎる / 手順が多すぎる","tooComplicatedTooManySteps","thumb-down"],["最新ではない","outOfDate","thumb-down"],["翻訳に関する問題","translationIssue","thumb-down"],["サンプル / コードに問題がある","samplesCodeIssue","thumb-down"],["その他","otherDown","thumb-down"]],["最終更新日 2025-07-27 UTC。"],[],[],null,["# Reduce latency with Zero-Shutter Lag\n\n| **Note:** Zero-Shutter Lag is an experimental feature. To leave feedback on Zero-Shutter Lag, join the [Android CameraX Discussion Group](https://groups.google.com/a/android.com/g/camerax-developers).\n\nStarting in [CameraX 1.2](/jetpack/androidx/releases/camera), Zero-Shutter Lag is available as a capture mode.\nEnable Zero-Shutter Lag to significantly reduce latency compared to the\n[default capture mode](/reference/androidx/camera/core/ImageCapture#CAPTURE_MODE_MINIMIZE_LATENCY()), so you never miss the shot.\n\nEnable Zero-Shutter Lag\n-----------------------\n\nTo enable Zero-Shutter Lag, pass [`CAPTURE_MODE_ZERO_SHOT_LAG`](/reference/androidx/camera/core/ImageCapture#CAPTURE_MODE_ZERO_SHUTTER_LAG()) to\n[`ImageCapture.Builder.setCaptureMode()`](/reference/androidx/camera/core/ImageCapture.Builder#setCaptureMode(int)). If unsuccessful,\n`setCaptureMode()` falls back to `CAPTURE_MODE_MINIMIZE_LATENCY`.\n\nFor more on capture modes, see the [Image capture guide](/media/camera/camerax/take-photo#set-capture-mode).\n\nHow it works\n------------\n\nZero-Shutter Lag uses a ring buffer that stores the three most recent capture\nframes. When a user presses the capture button, CameraX invokes\n[`takePicture()`](/reference/android/hardware/Camera#takePicture(android.hardware.Camera.ShutterCallback,%20android.hardware.Camera.PictureCallback,%20android.hardware.Camera.PictureCallback,%20android.hardware.Camera.PictureCallback)), and the ring buffer retrieves the captured frame with the\ntimestamp that is closest to that of the button press. CameraX then\n[reprocesses](/reference/android/hardware/camera2/CameraDevice#reprocessing) the capture session to generate an image from that frame, which\nsaves to disk in JPEG format.\n\nPrerequisites\n-------------\n\nBefore you enable Zero-Shutter Lag, use [`isZslSupported()`](/reference/androidx/camera/core/CameraInfo#isZslSupported()) to determine if\nyour device meets the following requirements:\n\n- Targets Android 6.0+ (API level 23 and higher).\n- Supports [`PRIVATE` reprocessing](/reference/android/hardware/camera2/CameraMetadata#REQUEST_AVAILABLE_CAPABILITIES_PRIVATE_REPROCESSING).\n\nFor devices that don't meet the minimum requirements, CameraX falls back to\n`CAPTURE_MODE_MINIMIZE_LATENCY`.\n\nZero-Shutter Lag is only available for [Image capture](/training/camerax/take-photo). You cannot enable it\nfor [Video capture](/training/camerax/video-capture) or with [Camera extensions](/training/camera/camera-extensions).\n\nFinally, because using flash results in greater latency, Zero-Shutter Lag does\nnot work when flash is ON or in AUTO mode. For more information about setting\nthe flash mode, see [`setFlashMode()`](/media/camera/camerax/take-photo#set-flash-mode)."]]