CameraExtensionCharacteristics


public final class CameraExtensionCharacteristics
extends Object

java.lang.Object
   ↳ android.hardware.camera2.CameraExtensionCharacteristics


Allows clients to query availability and supported resolutions of camera extensions.

Camera extensions give camera clients access to device-specific algorithms and sequences that can improve the overall image quality of snapshots in various cases such as low light, selfies, portraits, and scenes that can benefit from enhanced dynamic range. Often such sophisticated processing sequences will rely on multiple camera frames as input and will produce a single output.

Camera extensions are not guaranteed to be present on all devices so camera clients must query for their availability via CameraExtensionCharacteristics#getSupportedExtensions().

In order to use any available camera extension, camera clients must create a corresponding CameraExtensionSession via CameraDevice#createExtensionSession(ExtensionSessionConfiguration)

Camera clients must be aware that device-specific camera extensions may support only a subset of the available camera resolutions and must first query CameraExtensionCharacteristics#getExtensionSupportedSizes(int, int) for supported single high-quality request output sizes and CameraExtensionCharacteristics#getExtensionSupportedSizes(int, Class) for supported repeating request output sizes.

The extension characteristics for a given device are expected to remain static under normal operating conditions.

Summary

Constants

int EXTENSION_AUTOMATIC

Device-specific extension implementation for automatic selection of particular extension such as HDR or NIGHT depending on the current lighting and environment conditions.

int EXTENSION_BEAUTY

This constant was deprecated in API level 33. Use EXTENSION_FACE_RETOUCH instead.

int EXTENSION_BOKEH

Device-specific extension implementation which can blur certain regions of the final image thereby "enhancing" focus for all remaining non-blurred parts.

int EXTENSION_FACE_RETOUCH

Device-specific extension implementation which tends to smooth the skin and apply other cosmetic effects to people's faces.

int EXTENSION_HDR

Device-specific extension implementation for enhancing the dynamic range of the final image.

int EXTENSION_NIGHT

Device-specific extension implementation that aims to suppress noise and improve the overall image quality under low light conditions.

Public methods

<T> T get(int extension, Key<T> key)

Gets an extension specific camera characteristics field value.

Set<CaptureRequest.Key<T>> getAvailableCaptureRequestKeys(int extension)

Returns the set of keys supported by a CaptureRequest submitted in a CameraExtensionSession with a given extension type.

Set<CaptureResult.Key<T>> getAvailableCaptureResultKeys(int extension)

Returns the set of keys supported by a CaptureResult passed as an argument to CameraExtensionSession.ExtensionCaptureCallback#onCaptureResultAvailable.

Range<Long> getEstimatedCaptureLatencyRangeMillis(int extension, Size captureOutputSize, int format)

Returns the estimated capture latency range in milliseconds for the target capture resolution during the calls to CameraExtensionSession#capture.

List<Size> getExtensionSupportedSizes(int extension, int format)

Check whether a given extension is available and return the supported output surface resolutions that can be used for high-quality capture requests via CameraExtensionSession#capture.

<T> List<Size> getExtensionSupportedSizes(int extension, Class<T> klass)

Get a list of sizes compatible with klass to use as an output for the repeating request CameraExtensionSession#setRepeatingRequest.

Set<CameraCharacteristics.Key<T>> getKeys(int extension)

Returns the CameraCharacteristics keys that have extension-specific values.

List<Size> getPostviewSupportedSizes(int extension, Size captureSize, int format)

Get a list of the postview sizes supported for a still capture, using its capture size captureSize, to use as an output for the postview request.

List<Integer> getSupportedExtensions()

Return a list of supported device-specific extensions for a given camera device.

boolean isCaptureProcessProgressAvailable(int extension)

Retrieve support for capture progress callbacks via CameraExtensionSession.ExtensionCaptureCallback#onCaptureProcessProgressed.

boolean isPostviewAvailable(int extension)

Checks for postview support of still capture.

Inherited methods

Constants

EXTENSION_AUTOMATIC

Added in API level 31
public static final int EXTENSION_AUTOMATIC

Device-specific extension implementation for automatic selection of particular extension such as HDR or NIGHT depending on the current lighting and environment conditions.

Constant Value: 0 (0x00000000)

EXTENSION_BEAUTY

Added in API level 31
Deprecated in API level 33
public static final int EXTENSION_BEAUTY

This constant was deprecated in API level 33.
Use EXTENSION_FACE_RETOUCH instead.

Device-specific extension implementation which tends to smooth the skin and apply other cosmetic effects to people's faces.

Constant Value: 1 (0x00000001)

EXTENSION_BOKEH

Added in API level 31
public static final int EXTENSION_BOKEH

Device-specific extension implementation which can blur certain regions of the final image thereby "enhancing" focus for all remaining non-blurred parts.

Constant Value: 2 (0x00000002)

EXTENSION_FACE_RETOUCH

Added in API level 33
public static final int EXTENSION_FACE_RETOUCH

Device-specific extension implementation which tends to smooth the skin and apply other cosmetic effects to people's faces.

Constant Value: 1 (0x00000001)

EXTENSION_HDR

Added in API level 31
public static final int EXTENSION_HDR

Device-specific extension implementation for enhancing the dynamic range of the final image.

Constant Value: 3 (0x00000003)

EXTENSION_NIGHT

Added in API level 31
public static final int EXTENSION_NIGHT

Device-specific extension implementation that aims to suppress noise and improve the overall image quality under low light conditions.

Constant Value: 4 (0x00000004)

Public methods

get

Added in API level 35
public T get (int extension, 
                Key<T> key)

Gets an extension specific camera characteristics field value.

An extension can have a reduced set of camera capabilities (such as limited zoom ratio range, available video stabilization modes, etc). This API enables applications to query for an extension\u2019s specific camera characteristics. Applications are recommended to prioritize obtaining camera characteristics using this API when using an extension. A null result indicates that the extension specific characteristic is not defined or available.

Parameters
extension int: The extension type. Value is either 0 or a combination of EXTENSION_AUTOMATIC, EXTENSION_FACE_RETOUCH, EXTENSION_BOKEH, EXTENSION_HDR, EXTENSION_NIGHT, and android.hardware.camera2.CameraExtensionCharacteristics.EXTENSION_EYES_FREE_VIDEOGRAPHY

key Key: The characteristics field to read. This value cannot be null.

Returns
T The value of that key, or null if the field is not set.

Throws
IllegalArgumentException if the key is not valid or extension type is not a supported device-specific extension.

getAvailableCaptureRequestKeys

Added in API level 33
public Set<CaptureRequest.Key<T>> getAvailableCaptureRequestKeys (int extension)

Returns the set of keys supported by a CaptureRequest submitted in a CameraExtensionSession with a given extension type.

The set returned is not modifiable, so any attempts to modify it will throw a UnsupportedOperationException.

Devices launching on Android Build.VERSION_CODES.VANILLA_ICE_CREAM or newer versions are required to support CaptureRequest#CONTROL_AF_MODE, CaptureRequest#CONTROL_AF_REGIONS, CaptureRequest#CONTROL_AF_TRIGGER, CaptureRequest#CONTROL_ZOOM_RATIO for CameraExtensionCharacteristics#EXTENSION_NIGHT.

Parameters
extension int: the extension type Value is either 0 or a combination of EXTENSION_AUTOMATIC, EXTENSION_FACE_RETOUCH, EXTENSION_BOKEH, EXTENSION_HDR, EXTENSION_NIGHT, and android.hardware.camera2.CameraExtensionCharacteristics.EXTENSION_EYES_FREE_VIDEOGRAPHY

Returns
Set<CaptureRequest.Key<T>> non-modifiable set of capture keys supported by camera extension session initialized with the given extension type. This value cannot be null.

Throws
IllegalArgumentException in case of unsupported extension.

getAvailableCaptureResultKeys

Added in API level 33
public Set<CaptureResult.Key<T>> getAvailableCaptureResultKeys (int extension)

Returns the set of keys supported by a CaptureResult passed as an argument to CameraExtensionSession.ExtensionCaptureCallback#onCaptureResultAvailable.

The set returned is not modifiable, so any attempts to modify it will throw a UnsupportedOperationException.

In case the set is empty, then the extension is not able to support any capture results and the CameraExtensionSession.ExtensionCaptureCallback#onCaptureResultAvailable callback will not be fired.

Devices launching on Android Build.VERSION_CODES.VANILLA_ICE_CREAM or newer versions are required to support CaptureResult#CONTROL_AF_MODE, CaptureResult#CONTROL_AF_REGIONS, CaptureResult#CONTROL_AF_TRIGGER, CaptureResult#CONTROL_AF_STATE, CaptureResult#CONTROL_ZOOM_RATIO for CameraExtensionCharacteristics#EXTENSION_NIGHT.

Parameters
extension int: the extension type Value is either 0 or a combination of EXTENSION_AUTOMATIC, EXTENSION_FACE_RETOUCH, EXTENSION_BOKEH, EXTENSION_HDR, EXTENSION_NIGHT, and android.hardware.camera2.CameraExtensionCharacteristics.EXTENSION_EYES_FREE_VIDEOGRAPHY

Returns
Set<CaptureResult.Key<T>> non-modifiable set of capture result keys supported by camera extension session initialized with the given extension type. This value cannot be null.

Throws
IllegalArgumentException in case of unsupported extension.

getEstimatedCaptureLatencyRangeMillis

Added in API level 31
public Range<Long> getEstimatedCaptureLatencyRangeMillis (int extension, 
                Size captureOutputSize, 
                int format)

Returns the estimated capture latency range in milliseconds for the target capture resolution during the calls to CameraExtensionSession#capture. This includes the time spent processing the multi-frame capture request along with any additional time for encoding of the processed buffer if necessary.

Parameters
extension int: the extension type Value is either 0 or a combination of EXTENSION_AUTOMATIC, EXTENSION_FACE_RETOUCH, EXTENSION_BOKEH, EXTENSION_HDR, EXTENSION_NIGHT, and android.hardware.camera2.CameraExtensionCharacteristics.EXTENSION_EYES_FREE_VIDEOGRAPHY

captureOutputSize Size: size of the capture output surface. If it is not in the supported output sizes, maximum capture output size is used for the estimation This value cannot be null.

format int: device-specific extension output format Value is ImageFormat.UNKNOWN, PixelFormat.RGBA_8888, PixelFormat.RGBX_8888, PixelFormat.RGB_888, ImageFormat.RGB_565, ImageFormat.YV12, ImageFormat.Y8, android.graphics.ImageFormat.Y16, ImageFormat.YCBCR_P010, ImageFormat.NV16, ImageFormat.NV21, ImageFormat.YUY2, ImageFormat.JPEG, ImageFormat.DEPTH_JPEG, ImageFormat.YUV_420_888, ImageFormat.YUV_422_888, ImageFormat.YUV_444_888, ImageFormat.FLEX_RGB_888, ImageFormat.FLEX_RGBA_8888, ImageFormat.RAW_SENSOR, ImageFormat.RAW_PRIVATE, ImageFormat.RAW10, ImageFormat.RAW12, ImageFormat.DEPTH16, ImageFormat.DEPTH_POINT_CLOUD, android.graphics.ImageFormat.RAW_DEPTH, android.graphics.ImageFormat.RAW_DEPTH10, ImageFormat.PRIVATE, ImageFormat.HEIC, or ImageFormat.JPEG_R

Returns
Range<Long> the range of estimated minimal and maximal capture latency in milliseconds or null if no capture latency info can be provided

Throws
IllegalArgumentException in case of format different from ImageFormat#JPEG, ImageFormat#YUV_420_888, ImageFormat#JPEG_R ImageFormat#YCBCR_P010; or unsupported extension.

getExtensionSupportedSizes

Added in API level 31
public List<Size> getExtensionSupportedSizes (int extension, 
                int format)

Check whether a given extension is available and return the supported output surface resolutions that can be used for high-quality capture requests via CameraExtensionSession#capture.

Note that device-specific extensions are allowed to support only a subset of the camera resolutions advertised by StreamConfigurationMap#getOutputSizes.

Device-specific extensions currently support at most three multi-frame capture surface formats. ImageFormat.JPEG will be supported by all extensions while ImageFormat.YUV_420_888, ImageFormat.JPEG_R, or ImageFormat.YCBCR_P010 may or may not be supported.

Parameters
extension int: the extension type Value is either 0 or a combination of EXTENSION_AUTOMATIC, EXTENSION_FACE_RETOUCH, EXTENSION_BOKEH, EXTENSION_HDR, EXTENSION_NIGHT, and android.hardware.camera2.CameraExtensionCharacteristics.EXTENSION_EYES_FREE_VIDEOGRAPHY

format int: device-specific extension output format

Returns
List<Size> non-modifiable list of available sizes or an empty list if the format is not supported. This value cannot be null.

Throws
IllegalArgumentException in case of format different from ImageFormat.JPEG, ImageFormat.YUV_420_888, ImageFormat.JPEG_R, ImageFormat.YCBCR_P010; or unsupported extension.

getExtensionSupportedSizes

Added in API level 31
public List<Size> getExtensionSupportedSizes (int extension, 
                Class<T> klass)

Get a list of sizes compatible with klass to use as an output for the repeating request CameraExtensionSession#setRepeatingRequest.

Note that device-specific extensions are allowed to support only a subset of the camera output surfaces and resolutions. The SurfaceTexture class is guaranteed at least one size for backward compatible cameras whereas other output classes are not guaranteed to be supported.

Starting with Android Build.VERSION_CODES.UPSIDE_DOWN_CAKE SurfaceView classes are also guaranteed to be supported and include the same resolutions as SurfaceTexture. Clients must set the desired SurfaceView resolution by calling SurfaceHolder.setFixedSize(int, int).

Parameters
extension int: the extension type Value is either 0 or a combination of EXTENSION_AUTOMATIC, EXTENSION_FACE_RETOUCH, EXTENSION_BOKEH, EXTENSION_HDR, EXTENSION_NIGHT, and android.hardware.camera2.CameraExtensionCharacteristics.EXTENSION_EYES_FREE_VIDEOGRAPHY

klass Class: a non-null Class object reference

Returns
List<Size> non-modifiable list of available sizes or an empty list if the Surface output is not supported This value cannot be null.

Throws
NullPointerException if klass was null
IllegalArgumentException in case of unsupported extension.

getKeys

Added in API level 35
public Set<CameraCharacteristics.Key<T>> getKeys (int extension)

Returns the CameraCharacteristics keys that have extension-specific values.

An application can query the value from the key using get(int, android.hardware.camera2.CameraCharacteristics.Key) API.

Parameters
extension int: The extension type. Value is either 0 or a combination of EXTENSION_AUTOMATIC, EXTENSION_FACE_RETOUCH, EXTENSION_BOKEH, EXTENSION_HDR, EXTENSION_NIGHT, and android.hardware.camera2.CameraExtensionCharacteristics.EXTENSION_EYES_FREE_VIDEOGRAPHY

Returns
Set<CameraCharacteristics.Key<T>> An unmodifiable set of keys that are extension specific. This value cannot be null.

Throws
IllegalArgumentException in case the extension type is not a supported device-specific extension

getPostviewSupportedSizes

Added in API level 34
public List<Size> getPostviewSupportedSizes (int extension, 
                Size captureSize, 
                int format)

Get a list of the postview sizes supported for a still capture, using its capture size captureSize, to use as an output for the postview request.

Available postview sizes will always be either equal to or less than the still capture size. When choosing the most applicable postview size for a usecase, it should be noted that lower resolution postviews will generally be available more quickly than larger resolution postviews. For example, when choosing a size for an optimized postview that will be displayed as a placeholder while the final image is processed, the resolution closest to the preview size may be most suitable.

Note that device-specific extensions are allowed to support only a subset of the camera resolutions advertised by StreamConfigurationMap#getOutputSizes.

Parameters
extension int: the extension type Value is either 0 or a combination of EXTENSION_AUTOMATIC, EXTENSION_FACE_RETOUCH, EXTENSION_BOKEH, EXTENSION_HDR, EXTENSION_NIGHT, and android.hardware.camera2.CameraExtensionCharacteristics.EXTENSION_EYES_FREE_VIDEOGRAPHY

captureSize Size: size of the still capture for which the postview is requested This value cannot be null.

format int: device-specific extension output format of the postview

Returns
List<Size> non-modifiable list of available sizes or an empty list if the format and size is not supported. This value cannot be null.

Throws
IllegalArgumentException in case of unsupported extension or if postview feature is not supported by extension.

getSupportedExtensions

Added in API level 31
public List<Integer> getSupportedExtensions ()

Return a list of supported device-specific extensions for a given camera device.

Returns
List<Integer> non-modifiable list of available extensions This value cannot be null.

isCaptureProcessProgressAvailable

Added in API level 34
public boolean isCaptureProcessProgressAvailable (int extension)

Retrieve support for capture progress callbacks via CameraExtensionSession.ExtensionCaptureCallback#onCaptureProcessProgressed.

Parameters
extension int: the extension type Value is either 0 or a combination of EXTENSION_AUTOMATIC, EXTENSION_FACE_RETOUCH, EXTENSION_BOKEH, EXTENSION_HDR, EXTENSION_NIGHT, and android.hardware.camera2.CameraExtensionCharacteristics.EXTENSION_EYES_FREE_VIDEOGRAPHY

Returns
boolean true in case progress callbacks are supported, false otherwise

Throws
IllegalArgumentException in case of an unsupported extension.

isPostviewAvailable

Added in API level 34
public boolean isPostviewAvailable (int extension)

Checks for postview support of still capture.

A postview is a preview version of the still capture that is available before the final image. For example, it can be used as a temporary placeholder for the requested capture while the final image is being processed. The supported sizes for a still capture's postview can be retrieved using CameraExtensionCharacteristics#getPostviewSupportedSizes(int, Size, int).

Starting with Android Build.VERSION_CODES.VANILLA_ICE_CREAM, the formats of the still capture and postview are not required to be equivalent upon capture request.

Parameters
extension int: the extension type Value is either 0 or a combination of EXTENSION_AUTOMATIC, EXTENSION_FACE_RETOUCH, EXTENSION_BOKEH, EXTENSION_HDR, EXTENSION_NIGHT, and android.hardware.camera2.CameraExtensionCharacteristics.EXTENSION_EYES_FREE_VIDEOGRAPHY

Returns
boolean true in case postview is supported, false otherwise

Throws
IllegalArgumentException in case the extension type is not a supported device-specific extension