Jetpack Camera App (JCA)

repository·main·Indexed 43 days ago

https://github.com/google/jetpack-camera-app

A reference camera application built with CameraX, Kotlin, and Jetpack Compose. Designed for developers and OEMs to validate camera feature implementations following Android best practices, featuring support for 10-bit HDR video, Ultra HDR image capture, Dual Concurrent Camera mode, and various video stabilization settings.

Tokens
6.1K
Snippets
12
Records
37
Agent score
56%

What's inside Jetpack Camera App

  1. Use the Viewfinder

    main

    The viewfinder provides a real-time, WYSIWYG (What You See Is What You Get) preview of the camera sensor output.

    Usage:

    • The viewfinder is active automatically when the camera app is opened.

    Limitations:

    • Resolution: Due to CameraX performance/quality tradeoffs, the viewfinder resolution is limited to 1080p.
    • Stabilization: When video stabilization is set to "High Quality", the viewfinder may not be strictly WYSIWYG because the real-time preview might not replicate the exact stabilization algorithm applied to the final recorded video.
  2. Enable the pre-push formatting hook

    main

    To prevent CI failures caused by formatting issues, the repository includes a pre-push hook that uses spotless to check code formatting.

    To enable this hook for your local repository, run the following command from the root directory:

    git config core.hooksPath scripts/git-hooks

    This configuration is local to this repository and will not affect other Git projects. Once enabled, the hook runs automatically every time you attempt to push changes.

  3. Flip the camera lens

    main

    Switches between the primary (rear) and front-facing cameras.

    How to use:

    • Button: Tap the flip camera button in the main UI.
    • Gesture: Double tap on the viewfinder.
    • Quick Settings: Tap the downward facing arrow at the top of the screen and tap the flip camera button.

    Limitations:

    • The flip button is disabled if the device lacks a front or rear camera.
  4. Use Tap to Focus

    main

    Allows manual selection of the camera's focus point.

    How to use:

    1. Open the camera app.
    2. Tap any area on the viewfinder to adjust focus to that location.

    Limitations:

    • Performance may degrade in low-light conditions.
    • Focus can be affected by subject or camera movement.
  5. Use Screen Flash for front-facing camera illumination

    main

    Screen flash illuminates the subject by displaying a bright, solid overlay on the device screen and maximizing brightness during front-facing image capture.

    How to use:

    1. Select the front-facing camera.
    2. Tap the flash icon to toggle to "On" or "Auto" mode.
    3. Take a photo.

    Constraints:

    • Only works with front-facing cameras.
    • Limited to image capture; does not provide illumination for video.
    • In "Auto" mode, it behaves identically to "On" mode regardless of ambient light.
  6. Use Zoom functionality

    main

    Enables digital or optical zoom. On devices supporting Camera2's LOGICAL_MULTI_CAMERA, the app automatically transitions between lenses (main, telephoto, wide-angle) for seamless transitions.

    How to use:

    • Use pinch-to-zoom gestures on the viewfinder. The current magnification factor is displayed above the capture button.

    Limitations:

    • Digital zoom may reduce image quality.
    • In Dual Concurrent Camera mode, only the primary lens can be zoomed; the secondary lens will not respond to pinch gestures.
  7. Flip camera during video recording

    main

    You can switch between the front and rear cameras while a video is actively being recorded.

    1. While recording, tap the flip camera button.

    Limitations:

    • This feature uses the experimental Persistent Recording API and may behave unexpectedly.
    • It may be buggy when used in conjunction with pause/resume.
    • It does not work when using concurrent cameras, stabilization, or single stream modes.
  8. Use Low Light Boost (LLB)

    main

    LLB enhances brightness for previews and videos in dark environments. On supported devices, it utilizes Camera2's ON_LOW_LIGHT_BOOST_BRIGHTNESS_PRIORITY auto-exposure mode.

    How to use:

    1. Tap the flash icon to cycle modes.
    2. Look for the crescent moon icon:
      • Outlined Crescent Moon: LLB is inactive (scene is bright enough).
      • Filled Crescent Moon: LLB is active (scene is dark, brightness is enhanced).

    Constraints:

    • Only works on Preview and Video Capture in multi-stream mode.
    • May reduce frame rate, potentially introducing motion blur.
    • Requires lenses that support ON_LOW_LIGHT_BOOST_BRIGHTNESS_PRIORITY in CONTROL_AE_AVAILABLE_MODES.
  9. Sign the Contributor License Agreement (CLA)

    main

    Before contributing to this project, you or your employer must sign the Google Contributor License Agreement (CLA). This agreement grants permission to use and redistribute your contributions as part of the project while you retain the copyright.

    If you have already signed the Google CLA for other projects, you likely do not need to sign it again. You can check your existing agreements or sign a new one at the Google CLA portal.

    https://cla.developers.google.com/
  10. Configure Single-stream vs Multi-stream modes

    main

    This setting determines how the camera handles data streams:

    • Multi-stream mode: Uses separate streams for preview, video, and still images. Generally more efficient and higher performance.
    • Single-stream mode: Uses one stream for all functions. The preview is an exact reflection of what is captured (ideal for applying real-time effects).

    How to use:

    1. Open quick settings.
    2. Tap the single/multi stream button to toggle.

    Constraints:

    • Ultra HDR is disabled in single-stream mode.
    • These selectors are unavailable when Dual Concurrent Camera is active.
  11. Capture images

    main

    Captures a still image based on the current viewfinder scene, incorporating settings like Ultra HDR if enabled.

    How to use:

    1. Open the camera app.
    2. Tap the shutter button (white circle).

    Output:

    • Images are saved to the device's media store.
    • If the app is launched via ACTION_IMAGE_CAPTURE or INTENT_ACTION_STILL_IMAGE_CAMERA intents, images are saved to the provided URI(s).

    Constraints:

    • Image capture is disabled if the app is launched with the ACTION_VIDEO_CAPTURE intent.
    • Image capture is disabled in concurrent camera mode.
    • Image capture is disabled when HDR is enabled if the device does not support Ultra HDR.