Starting March 27, 2025, we recommend using android-latest-release
instead of aosp-main
to build and contribute to AOSP. For more information, see Changes to AOSP.
Camera bokeh
Stay organized with collections
Save and categorize content based on your preferences.
Camera bokeh is a shallow depth-of-field effect created by blurring out parts of
a scene so that they're not in focus. On cameras on mobile devices, bokeh is
achieved using depth information acquired from the stereo vision from two
cameras or from dual photodiodes (PDs) of a single camera.
Starting from Android 11, the Android platform
supports bokeh implementations and provides APIs to make the feature available
to third-party apps.
Implementation
To make the camera bokeh feature available on your device, do the following:
Advertise ANDROID_CONTROL_AVAILABLE_EXTENDED_SCENE_MODE_MAX_SIZES
:
This tag is in the format of a three-integer tuple array, with each tuple
in the format of {mode, maxWidth, maxHeight}
. In addition to
{ANDROID_CONTROL_EXTENDED_SCENE_MODE_DISABLED, 0, 0}
, the camera HAL must
also list one or both of the
ANDROID_CONTROL_EXTENDED_SCENE_MODE_BOKEH_STILL_CAPTURE
and
ANDROID_CONTROL_EXTENDED_SCENE_MODE_BOKEH_CONTINUOUS
modes with their
corresponding maximum streaming sizes.
Advertise
ANDROID_CONTROL_AVAILABLE_EXTENDED_SCENE_MODE_ZOOM_RATIO_RANGES
:
This tag is in the format of a {minZoomRatio, maxZoomRatio}
array,
which contains all the zoom ratio ranges for an enabled extended scene
mode, in the same order as in
ANDROID_CONTROL_AVAILABLE_EXTENDED_SCENE_MODE_MAX_SIZES
. A zoom range of
[1.0, 1.0]
means that zoom isn't supported.
Populate ANDROID_CONTROL_USE_EXTENDED_SCENE_MODE
in
ANDROID_CONTROL_AVAILABLE_MODES
.
For an app to trigger the bokeh feature, the app must set ANDROID_CONTROL_MODE
to ANDROID_CONTROL_USE_EXTENDED_SCENE_MODE
and
ANDROID_CONTROL_EXTENDED_SCENE_MODE
to one of supported extended scene modes.
Note that implementing bokeh might lead to extra memory consumption because of
stereo computation.
If a supported extended scene mode can't be applied per frame and results in
unexpected delays when enabled/disabled, include
ANDROID_CONTROL_EXTENDED_SCENE_MODE
in
ANDROID_REQUEST_AVAILABLE_SESSION_KEYS
. At the same time, implement the
ICameraDeviceSession::isReconfigurationRequired()
method to avoid
reconfiguration for extended scene modes that don't require reconfiguration.
Validation
To validate the bokeh feature on your device, run the following CTS, VTS, and
CTS Verifier tests:
CtsCameraTestCases
VtsHalCameraProviderV2_4TargetTest
CameraBokehTest
in CTS Verifier
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-06-12 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-06-12 UTC."],[],[],null,["# Camera bokeh is a shallow depth-of-field effect created by blurring out parts of\na scene so that they're not in focus. On cameras on mobile devices, bokeh is\nachieved using depth information acquired from the stereo vision from two\ncameras or from dual photodiodes (PDs) of a single camera.\n\nStarting from Android 11, the Android platform\nsupports bokeh implementations and provides APIs to make the feature available\nto third-party apps.\n\nImplementation\n--------------\n\nTo make the camera bokeh feature available on your device, do the following:\n\n- Advertise `ANDROID_CONTROL_AVAILABLE_EXTENDED_SCENE_MODE_MAX_SIZES`:\n\n This tag is in the format of a three-integer tuple array, with each tuple\n in the format of `{mode, maxWidth, maxHeight}`. In addition to\n `{ANDROID_CONTROL_EXTENDED_SCENE_MODE_DISABLED, 0, 0}`, the camera HAL must\n also list one or both of the\n `ANDROID_CONTROL_EXTENDED_SCENE_MODE_BOKEH_STILL_CAPTURE` and\n `ANDROID_CONTROL_EXTENDED_SCENE_MODE_BOKEH_CONTINUOUS` modes with their\n corresponding maximum streaming sizes.\n- Advertise\n `ANDROID_CONTROL_AVAILABLE_EXTENDED_SCENE_MODE_ZOOM_RATIO_RANGES`:\n\n This tag is in the format of a `{minZoomRatio, maxZoomRatio}` array,\n which contains all the zoom ratio ranges for an enabled extended scene\n mode, in the same order as in\n `ANDROID_CONTROL_AVAILABLE_EXTENDED_SCENE_MODE_MAX_SIZES`. A zoom range of\n `[1.0, 1.0]` means that zoom isn't supported.\n- Populate `ANDROID_CONTROL_USE_EXTENDED_SCENE_MODE` in\n `ANDROID_CONTROL_AVAILABLE_MODES`.\n\nFor an app to trigger the bokeh feature, the app must set `ANDROID_CONTROL_MODE`\nto `ANDROID_CONTROL_USE_EXTENDED_SCENE_MODE` and\n`ANDROID_CONTROL_EXTENDED_SCENE_MODE` to one of supported extended scene modes.\nNote that implementing bokeh might lead to extra memory consumption because of\nstereo computation.\n\nIf a supported extended scene mode can't be applied per frame and results in\nunexpected delays when enabled/disabled, include\n`ANDROID_CONTROL_EXTENDED_SCENE_MODE` in\n`ANDROID_REQUEST_AVAILABLE_SESSION_KEYS`. At the same time, implement the\n`ICameraDeviceSession::isReconfigurationRequired()` method to avoid\nreconfiguration for extended scene modes that don't require reconfiguration.\n\nValidation\n----------\n\nTo validate the bokeh feature on your device, run the following CTS, VTS, and\nCTS Verifier tests:\n\n- `CtsCameraTestCases`\n- `VtsHalCameraProviderV2_4TargetTest`\n- `CameraBokehTest` in CTS Verifier"]]