### Example: Speed-up at Start of Capture Session Source: https://developer.android.com/reference/android/hardware/camera2/CaptureRequest Illustrates how CONTROL_SETTINGS_OVERRIDE can speed up zoom by one frame at the start of a capture session. Observe how zoom values are applied earlier. ```text Camera session created Request 1 (zoom=1.0x, override=ZOOM) -> Request 2 (zoom=1.2x, override=ZOOM) -> Request 3 (zoom=1.4x, override=ZOOM) -> Result 1 (zoom=1.2x, override=ZOOM) Request 4 (zoom=1.6x, override=ZOOM) -> Result 2 (zoom=1.4x, override=ZOOM) Request 5 (zoom=1.8x, override=ZOOM) -> Result 3 (zoom=1.6x, override=ZOOM) -> Result 4 (zoom=1.8x, override=ZOOM) -> Result 5 (zoom=1.8x, override=OFF) ``` -------------------------------- ### Get Max Recommended Preview and Snapshot Sizes Source: https://developer.android.com/reference/android/hardware/camera2/CameraCharacteristics This example demonstrates how to retrieve the maximum recommended preview and snapshot resolutions using `getRecommendedStreamConfigurationMap`. It handles cases where recommended configurations might be null and uses a helper function to find the largest size from a set of output sizes. ```java public static Size getMaxSize(Size... sizes) { if (sizes == null || sizes.length == 0) { throw new IllegalArgumentException("sizes was empty"); } Size sz = sizes[0]; for (Size size : sizes) { if (size.getWidth() * size.getHeight() > sz.getWidth() * sz.getHeight()) { sz = size; } } return sz; } CameraCharacteristics characteristics = cameraManager.getCameraCharacteristics(cameraId); RecommendedStreamConfigurationMap previewConfig = characteristics.getRecommendedStreamConfigurationMap( RecommendedStreamConfigurationMap.USECASE_PREVIEW); RecommendedStreamConfigurationMap snapshotConfig = characteristics.getRecommendedStreamConfigurationMap( RecommendedStreamConfigurationMap.USECASE_SNAPSHOT); if ((previewConfig != null) && (snapshotConfig != null)) { Set snapshotSizeSet = snapshotConfig.getOutputSizes( ImageFormat.JPEG); Size[] snapshotSizes = new Size[snapshotSizeSet.size()]; snapshotSizes = snapshotSizeSet.toArray(snapshotSizes); Size suggestedMaxJpegSize = getMaxSize(snapshotSizes); Set previewSizeSet = snapshotConfig.getOutputSizes( ImageFormat.PRIVATE); Size[] previewSizes = new Size[previewSizeSet.size()]; previewSizes = previewSizeSet.toArray(previewSizes); Size suggestedMaxPreviewSize = getMaxSize(previewSizes); } ``` -------------------------------- ### Get Supported Extensions Source: https://developer.android.com/reference/android/hardware/camera2/CameraExtensionCharacteristics Returns a list of supported device-specific extensions for a given camera device. ```APIDOC ## getSupportedExtensions() ### Description Return a list of supported device-specific extensions for a given camera device. ### Method Signature `List getSupportedExtensions()` ``` -------------------------------- ### Get Supported Output Sizes by Format Source: https://developer.android.com/reference/android/hardware/camera2/params/StreamConfigurationMap Obtain a list of sizes compatible with a specified image format. For API levels 23+, consider getHighResolutionOutputSizes for devices supporting BURST_CAPTURE to get resolutions that may not meet the preferred 20fps rate. ```java public Size[] getOutputSizes (int format) ``` -------------------------------- ### Get Available Session Keys Source: https://developer.android.com/reference/android/hardware/camera2/CameraCharacteristics Returns a subset of keys that the camera device can pass as part of the capture session initialization. ```APIDOC ## getAvailableSessionKeys() ### Description Returns a subset of `getAvailableCaptureRequestKeys()` keys that the camera device can pass as part of the capture session initialization. ### Method Signature `List> getAvailableSessionKeys()` ``` -------------------------------- ### Get Output Configurations Source: https://developer.android.com/reference/android/hardware/camera2/params/ExtensionSessionConfiguration Retrieves the list of OutputConfiguration objects associated with the capture session. This list cannot be null. ```java public List getOutputConfigurations () ``` -------------------------------- ### Get Available Capture Request Keys Source: https://developer.android.com/reference/android/hardware/camera2/CameraCharacteristics Returns a list of keys that are supported by this CameraDevice for querying with a CaptureRequest. ```APIDOC ## getAvailableCaptureRequestKeys() ### Description Returns the list of keys supported by this `CameraDevice` for querying with a `CaptureRequest`. ### Method Signature `List> getAvailableCaptureRequestKeys()` ``` -------------------------------- ### Get Capture Latency Source: https://developer.android.com/reference/android/hardware/camera2/CameraExtensionSession.StillCaptureLatency Retrieve the capture latency in milliseconds. This is measured from the start of capture until processing begins, as defined by `ExtensionCaptureCallback.onCaptureStarted` and `ExtensionCaptureCallback.onCaptureProcessStarted`. ```java public long getCaptureLatency () ``` -------------------------------- ### Example: Transitions In and Out of Settings Override Source: https://developer.android.com/reference/android/hardware/camera2/CaptureRequest Demonstrates the transitions when enabling and disabling CONTROL_SETTINGS_OVERRIDE. Shows how zoom values are affected during these transitions. ```text Request 1 (zoom=1.0x, override=OFF) Request 2 (zoom=1.2x, override=OFF) Request 3 (zoom=1.4x, override=ZOOM) -> Result 1 (zoom=1.0x, override=OFF) Request 4 (zoom=1.6x, override=ZOOM) -> Result 2 (zoom=1.4x, override=ZOOM) Request 5 (zoom=1.8x, override=OFF) -> Result 3 (zoom=1.6x, override=ZOOM) -> Result 4 (zoom=1.6x, override=OFF) -> Result 5 (zoom=1.8x, override=OFF) ``` -------------------------------- ### Get Processing Latency Source: https://developer.android.com/reference/android/hardware/camera2/CameraExtensionSession.StillCaptureLatency Obtain the estimated post-processing latency in milliseconds. This duration spans from when the processed frame starts processing until it is returned to the client. ```java public long getProcessingLatency () ``` -------------------------------- ### prepare Source: https://developer.android.com/reference/android/hardware/camera2/CameraConstrainedHighSpeedCaptureSession Pre-allocate all buffers for an output Surface. ```APIDOC ## prepare ### Description Pre-allocate all buffers for an output Surface. ### Method `void prepare(Surface surface)` ### Parameters * **surface** (Surface) - The output Surface for which to pre-allocate buffers. ``` -------------------------------- ### SessionConfiguration Constructor (int, List, Executor, CameraCaptureSession.StateCallback) Source: https://developer.android.com/reference/android/hardware/camera2/params/SessionConfiguration Creates a new SessionConfiguration with session type, output configurations, an executor for callbacks, and a state callback. ```APIDOC ## SessionConfiguration Added in API level 28 ```java public SessionConfiguration (int sessionType, List outputs, Executor executor, CameraCaptureSession.StateCallback cb) ``` Create a new `SessionConfiguration`. Parameters --- `sessionType` | `int`: The session type. Value is one of the following: * `SESSION_REGULAR` * `SESSION_HIGH_SPEED` `outputs` | `List`: A list of output configurations for the capture session. This value cannot be `null`. `executor` | `Executor`: The executor which should be used to invoke the callback. In general it is recommended that camera operations are not done on the main (UI) thread. This value cannot be `null`. Callback and listener events are dispatched through this `Executor`, providing an easy way to control which thread is used. To dispatch events through the main thread of your application, you can use `Context.getMainExecutor()`. Otherwise, provide an `Executor` that dispatches to an appropriate thread. `cb` | `CameraCaptureSession.StateCallback`: A state callback interface implementation. This value cannot be `null`. **See also:** * `SESSION_REGULAR` * `SESSION_HIGH_SPEED` * `CameraDevice.createCaptureSession(SessionConfiguration)` ``` -------------------------------- ### get Source: https://developer.android.com/reference/android/hardware/camera2/CaptureRequest Gets a capture request field value. ```APIDOC ## get ### Description Get a capture request field value. ### Method ` T` get(Key key) ### Parameters #### Path Parameters - **key** (Key) - Required - The key for the field to retrieve. ### Returns The value of the requested field, or `null` if the key is not present in this request. ``` -------------------------------- ### USECASE_PREVIEW Constant Source: https://developer.android.com/reference/android/hardware/camera2/params/RecommendedStreamConfigurationMap Represents the recommended stream configuration for preview. Must include ImageFormat.PRIVATE and ImageFormat.YUV_420_888 output formats. ```java public static final int USECASE_PREVIEW ``` -------------------------------- ### Get Supported Extension Sizes Source: https://developer.android.com/reference/android/hardware/camera2/CameraExtensionCharacteristics Retrieves a list of output sizes compatible with a specific extension and class for repeating requests. Note that device-specific extensions may only support a subset of resolutions. `SurfaceTexture` is guaranteed at least one size for backward compatibility. Starting with Android `Build.VERSION_CODES.UPSIDE_DOWN_CAKE`, `SurfaceView` also supports the same resolutions as `SurfaceTexture` and requires `SurfaceHolder.setFixedSize(int, int)` to set resolution. ```java public List getExtensionSupportedSizes (int extension, Class klass) ``` -------------------------------- ### Sensor Frame Duration Source: https://developer.android.com/reference/android/hardware/camera2/CaptureRequest Specifies the duration from the start of frame readout to the start of the next frame readout. ```APIDOC ## Key: SENSOR_FRAME_DURATION ### Description Duration from start of frame readout to start of next frame readout. ### Type Long ``` -------------------------------- ### Zoom Ratio vs. Crop Region Example Source: https://developer.android.com/reference/android/hardware/camera2/CaptureRequest Illustrates two ways to achieve 2.0x zoom: using zoomRatio with a full crop region, or using the default zoomRatio with a specific crop region. The default zoomRatio is 1.0. ```java zoomRatio = 2.0, scaler.cropRegion = (0, 0, 2000, 1500) ``` ```java zoomRatio = 1.0 (default), scaler.cropRegion = (500, 375, 1500, 1125) ``` -------------------------------- ### USECASE_PREVIEW Source: https://developer.android.com/reference/android/hardware/camera2/params/RecommendedStreamConfigurationMap The recommended stream configuration map for use case preview must contain a subset of efficient, non-stalling configurations that include both ImageFormat.PRIVATE and ImageFormat.YUV_420_888 output formats. ```APIDOC ## USECASE_PREVIEW Added in API level 29 ```java public static final int USECASE_PREVIEW ``` Constant Value: 0 (0x00000000) ``` -------------------------------- ### Monochrome Camera Shading Map Example Source: https://developer.android.com/reference/android/hardware/camera2/CaptureResult Example definition of a lens shading map for a monochrome camera. For monochrome cameras, all 2x2 channels must have the same values. ```text android.lens.info.shadingMapSize = [ 4, 3 ] android.statistics.lensShadingMap = [ 1.3, 1.3, 1.3, 1.3, 1.2, 1.2, 1.2, 1.2, 1.1, 1.1, 1.1, 1.1, 1.3, 1.3, 1.3, 1.3, 1.2, 1.2, 1.2, 1.2, 1.1, 1.1, 1.1, 1.1, 1.0, 1.0, 1.0, 1.0, 1.2, 1.2, 1.2, 1.2, 1.3, 1.3, 1.3, 1.3, 1.2, 1.2, 1.2, 1.2, 1.2, 1.2, 1.2, 1.2, 1.3, 1.3, 1.3, 1.3 ] ``` -------------------------------- ### createExtensionSession(ExtensionSessionConfiguration extensionConfiguration) Source: https://developer.android.com/reference/android/hardware/camera2/CameraDevice Initializes a specific device-specific extension augmented camera capture session. ```APIDOC ## createExtensionSession(ExtensionSessionConfiguration extensionConfiguration) ### Description Initialize a specific device-specific extension augmented camera capture session. ### Method void ### Endpoint N/A (SDK Method) ### Parameters - **extensionConfiguration** (ExtensionSessionConfiguration) - Required - The configuration for the extension session. ### Request Example N/A ### Response N/A ``` -------------------------------- ### Get Camera Device ID Source: https://developer.android.com/reference/android/hardware/camera2/CameraDevice Get the unique ID of this camera device. This ID can be used to query camera characteristics. This method can be called even if the device is closed. ```java public abstract String getId () ``` -------------------------------- ### SessionConfiguration Constructor (int, List) Source: https://developer.android.com/reference/android/hardware/camera2/params/SessionConfiguration Creates a new SessionConfiguration with a specified session type and a list of output configurations. This configuration can be used to query camera device support and characteristics before creating a capture session. ```APIDOC ## SessionConfiguration Added in API level 35 ```java public SessionConfiguration (int sessionType, List outputs) ``` Create a new `SessionConfiguration` with sessionType and output configurations. The SessionConfiguration objects created by this constructor can be used by `CameraDeviceSetup.isSessionConfigurationSupported` and `CameraDeviceSetup.getSessionCharacteristics` to query a camera device's feature combination support and session specific characteristics. For the SessionConfiguration object to be used to create a capture session, `setStateCallback(Executor, StateCallback)` must be called to specify the state callback function, and any incomplete OutputConfigurations must be completed via `OutputConfiguration.addSurface` or `OutputConfiguration.setSurfacesForMultiResolutionOutput` as appropriate. Parameters --- `sessionType` | `int`: The session type. Value is one of the following: * `SESSION_REGULAR` * `SESSION_HIGH_SPEED` `outputs` | `List`: A list of output configurations for the capture session. This value cannot be `null`. **See also:** * `SESSION_REGULAR` * `SESSION_HIGH_SPEED` * `CameraDevice.createCaptureSession(SessionConfiguration)` * `CameraDeviceSetup.isSessionConfigurationSupported` * `CameraDeviceSetup.getSessionCharacteristics` ``` -------------------------------- ### Get Supported Input Sizes for a Format Source: https://developer.android.com/reference/android/hardware/camera2/params/StreamConfigurationMap Get the supported input sizes for a given image format. The format must be one returned by `getInputFormats()`; otherwise, `null` is returned. ```java public Size[] getInputSizes (int format) ``` -------------------------------- ### SENSOR_FRAME_DURATION Source: https://developer.android.com/reference/android/hardware/camera2/CaptureResult This key represents the duration from the start of frame readout to the start of the next frame readout in nanoseconds. It is an optional key and is fully supported on devices with a HARDWARE_LEVEL_FULL hardware level. ```APIDOC ## SENSOR_FRAME_DURATION ### Description Duration from start of frame readout to start of next frame readout. This value is used to determine the maximum frame rate that can be supported by a camera subsystem. The duration is capped to `max(duration, exposureTime + overhead)`. ### Key `public static final Key SENSOR_FRAME_DURATION` ### Units Nanoseconds ### Parameters This key does not take parameters. ### Request Body This key is part of the capture request and its value is a Long representing the duration in nanoseconds. ### Response This key is part of the capture request, not a response. ### See Also * `CaptureRequest.CONTROL_AE_MODE` * `CaptureRequest.CONTROL_MODE` * `CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL` * `CameraCharacteristics.SENSOR_INFO_MAX_FRAME_DURATION` ``` -------------------------------- ### Pre-allocate Buffers for an Output Surface Source: https://developer.android.com/reference/android/hardware/camera2/CameraCaptureSession Use this method to pre-allocate buffers for a given output Surface before submitting any capture requests. This can help reduce startup latency and prevent stuttering, especially with large buffers. The Surface must not have been used as a capture target previously in the current or prior sessions. For LEGACY devices, pre-allocation is not supported and the callback is invoked immediately. ```java public abstract void prepare (Surface surface) ``` -------------------------------- ### Lens Shading Correction Map Example Source: https://developer.android.com/reference/android/hardware/camera2/CaptureResult Example definition of a lens shading map for a Bayer pattern camera. The map contains coefficients to correct for vignetting and color shading. ```java public static final Key STATISTICS_LENS_SHADING_CORRECTION_MAP ``` ```text width,height = [ 4, 3 ] values = [ 1.3, 1.2, 1.15, 1.2, 1.2, 1.2, 1.15, 1.2, 1.1, 1.2, 1.2, 1.2, 1.3, 1.2, 1.3, 1.3, 1.2, 1.2, 1.25, 1.1, 1.1, 1.1, 1.1, 1.0, 1.0, 1.0, 1.0, 1.0, 1.2, 1.3, 1.25, 1.2, 1.3, 1.2, 1.2, 1.3, 1.2, 1.15, 1.1, 1.2, 1.2, 1.1, 1.0, 1.2, 1.3, 1.15, 1.2, 1.3 ] ``` -------------------------------- ### Create ExtensionSessionConfiguration Source: https://developer.android.com/reference/android/hardware/camera2/params/ExtensionSessionConfiguration Use this constructor to create a new ExtensionSessionConfiguration. Specify the extension type, a list of output configurations, an executor for callbacks, and a state callback listener. ```java public ExtensionSessionConfiguration (int extension, List outputs, Executor executor, CameraExtensionSession.StateCallback listener) ``` -------------------------------- ### Get Physical Camera Capture Results (Deprecated) Source: https://developer.android.com/reference/android/hardware/camera2/TotalCaptureResult Use this method for logical multi-camera devices to get capture results from underlying physical cameras. This method is deprecated and should be replaced by `getPhysicalCameraTotalResults()`. ```java public Map getPhysicalCameraResults () ``` -------------------------------- ### CameraCaptureSession Constructor Source: https://developer.android.com/reference/android/hardware/camera2/CameraCaptureSession Initializes a new CameraCaptureSession. ```APIDOC ## CameraCaptureSession ### Description Initializes a new CameraCaptureSession. ### Method public CameraCaptureSession () ### Parameters None ``` -------------------------------- ### InputConfiguration Constructor (API 31) Source: https://developer.android.com/reference/android/hardware/camera2/params/InputConfiguration Creates an input configuration with the specified format and a collection of multi-resolution input stream information. This constructor is available from API level 31. ```APIDOC ## InputConfiguration (API 31) ### Description Create an input configuration with the format and a list of multi-resolution input stream info. Use `CameraCharacteristics.SCALER_MULTI_RESOLUTION_STREAM_CONFIGURATION_MAP` to query supported multi-resolution input formats. To do reprocessing with variable resolution input, the application calls `ImageWriter.queueInputImage` using an image from an `ImageReader` or `MultiResolutionImageReader`. See `CameraDevice.createReprocessCaptureRequest(TotalCaptureResult)` for more details on camera reprocessing. ### Parameters - `multiResolutionInputs` (Collection): A group of multi-resolution input info for the specified format. This value cannot be `null`. - `format` (int): Format of the input buffers. One of ImageFormat or PixelFormat constants. ### See Also - `ImageFormat` - `PixelFormat` - `CameraCharacteristics.SCALER_MULTI_RESOLUTION_STREAM_CONFIGURATION_MAP` ``` -------------------------------- ### Get Stall Duration for Class and Size Source: https://developer.android.com/reference/android/hardware/camera2/params/RecommendedStreamConfigurationMap Get the stall duration in nanoseconds for a specific class and size combination. This is applicable for classes with supported output sizes. Throws IllegalArgumentException if the class or size is not supported. ```java public long getOutputStallDuration (Class klass, Size size) ``` -------------------------------- ### createExtensionSession Source: https://developer.android.com/reference/android/hardware/camera2/CameraDevice Initializes a specific device-specific extension augmented camera capture session. This method sets up the internal processing pipeline for extension-augmented preview and multi-frame still capture. It also handles the lifecycle of previous sessions. ```APIDOC ## createExtensionSession ### Description Initialize a specific device-specific extension augmented camera capture session. Extension sessions can be used to enable device-specific operation modes like `CameraExtensionCharacteristics.EXTENSION_NIGHT` or `CameraExtensionCharacteristics.EXTENSION_HDR`. These modes are less flexible than the full camera API, but enable access to more sophisticated processing algorithms that can capture multi-frame bursts to generate single output images. To query for available extensions on this device call `CameraExtensionCharacteristics.getSupportedExtensions()`. This method will also trigger the setup of the internal processing pipeline for extension augmented preview and multi-frame still capture. If a prior CameraCaptureSession already exists when this method is called, the previous session will no longer be able to accept new capture requests and will be closed. Any in-progress capture requests made on the prior session will be completed before it's closed. The CameraExtensionSession will be active until the client either calls CameraExtensionSession.close() or creates a new camera capture session. In both cases all internal resources will be released, continuous repeating requests stopped and any pending multi-frame capture requests flushed. Note that the CameraExtensionSession currently supports at most wo multi frame capture surface formats: ImageFormat.JPEG will be supported by all extensions and ImageFormat.YUV_420_888 may or may not be supported. Clients must query the multi-frame capture format support using `CameraExtensionCharacteristics.getExtensionSupportedSizes(int,int)`. For repeating requests CameraExtensionSession supports only `SurfaceTexture` as output. Clients can query the supported resolution for the repeating request output using `getExtensionSupportedSizes(..., Class)`. At the very minimum the initialization expects either one valid output surface for repeating or one valid output for high-quality single requests registered in the outputs argument of the extension configuration argument. At the maximum the initialization will accept two valid output surfaces, one for repeating and the other for single requests. Additional unsupported surfaces passed to ExtensionSessionConfiguration will cause an `IllegalArgumentException` to be thrown. ### Method ```java public void createExtensionSession (ExtensionSessionConfiguration extensionConfiguration) ``` ### Parameters #### Path Parameters - **extensionConfiguration** (`ExtensionSessionConfiguration`) - Required - extension configuration. This value cannot be `null`. ### Throws - `IllegalArgumentException` - If both the preview and still capture surfaces are not set or invalid, or if any of the registered surfaces do not meet the device-specific extension requirements such as dimensions and/or (output format)/(surface type), or if the extension is not supported, or if any of the output configurations select a dynamic range different from `DynamicRangeProfiles.STANDARD`, or if any of the output configurations sets a stream use case different from `CameraMetadata.SCALER_AVAILABLE_STREAM_USE_CASES_DEFAULT`. - `UnsupportedOperationException` - if the camera has been opened in shared mode - `CameraAccessException` ### See Also - `CameraExtensionCharacteristics.getSupportedExtensions` - `CameraExtensionCharacteristics.getExtensionSupportedSizes` ``` -------------------------------- ### Get Extension-Specific Camera Keys Source: https://developer.android.com/reference/android/hardware/camera2/CameraExtensionCharacteristics Returns a set of `CameraCharacteristics` keys that have extension-specific values. Applications can query these values using the `get(int, CameraCharacteristics.Key)` API. Throws `IllegalArgumentException` if the extension type is not supported. ```java public Set> getKeys (int extension) ``` -------------------------------- ### SENSOR_ROLLING_SHUTTER_SKEW Source: https://developer.android.com/reference/android/hardware/camera2/CaptureResult Represents the duration between the start of exposure for the first row and the start of exposure for the row after the last row of the image sensor. This is crucial for understanding rolling shutter effects and frame readout times. Units are in Nanoseconds. ```APIDOC ## SENSOR_ROLLING_SHUTTER_SKEW ### Description Duration between the start of exposure for the first row of the image sensor, and the start of exposure for one past the last row of the image sensor. This is the exposure time skew between the first and `(last+1)` row exposure start times. The first row and the last row are the first and last rows inside of the `android.sensor.info.activeArraySize`. For typical camera sensors that use rolling shutters, this is also equivalent to the frame readout time. If the image sensor is operating in a binned or cropped mode due to the current output target resolutions, it's possible this skew is reported to be larger than the exposure time, for example, since it is based on the full array even if a partial array is read out. Be sure to scale the number to cover the section of the sensor actually being used for the outputs you care about. So if your output covers N rows of the active array of height H, scale this value by N/H to get the total skew for that viewport. _Note:_ Prior to Android 11, this field was described as measuring duration from first to last row of the image sensor, which is not equal to the frame readout time for a rolling shutter sensor. Implementations generally reported the latter value, so to resolve the inconsistency, the description has been updated to range from (first, last+1) row exposure start, instead. ### Units Nanoseconds ### Range of valid values >= 0 and < `StreamConfigurationMap.getOutputMinFrameDuration(int, Size)`. ### Optional The value for this key may be `null` on some devices. ### Limited capability Present on all camera devices that report being at least `HARDWARE_LEVEL_LIMITED` devices in the `android.info.supportedHardwareLevel` key ### See also: * `CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL` * `CameraCharacteristics.SENSOR_INFO_ACTIVE_ARRAY_SIZE` ``` -------------------------------- ### InputConfiguration Constructor (API 23) Source: https://developer.android.com/reference/android/hardware/camera2/params/InputConfiguration Creates an input configuration with the specified width, height, and format. This constructor is available from API level 23. ```APIDOC ## InputConfiguration (API 23) ### Description Create an input configuration with the width, height, and user-defined format. Images of a user-defined format are accessible by applications. Use `CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP` to query supported input formats. ### Parameters - `width` (int): Width of the input buffers. - `height` (int): Height of the input buffers. - `format` (int): Format of the input buffers. One of ImageFormat or PixelFormat constants. ### See Also - `ImageFormat` - `PixelFormat` - `CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP` ``` -------------------------------- ### prepare Source: https://developer.android.com/reference/android/hardware/camera2/CameraCaptureSession Pre-allocates all buffers for a given output Surface. This method should be called before the Surface is used as a target for a request to ensure buffers are ready, potentially reducing latency and stuttering. Note that this may increase memory consumption and delay the first output. ```APIDOC ## prepare (Surface surface) ### Description Pre-allocate all buffers for an output Surface. This method can be used to perform buffer pre-allocation, which may reduce latency and improve frame rate smoothness, especially for bursts. It should be called before the Surface is used as a target for a request. ### Method ```java public abstract void prepare (Surface surface) ``` ### Parameters #### Path Parameters - **surface** (Surface) - Required - The output Surface for which buffers should be pre-allocated. Must be one of the output Surfaces used to create this session. ### Throws - **CameraAccessException** - if the camera device is no longer connected or has encountered a fatal error. - **IllegalArgumentException** - if the Surface is invalid, not part of this Session, or has already been used as a target of a CaptureRequest in this session or immediately prior sessions. - **IllegalStateException** - if this session is no longer active, either because the session was explicitly closed, a new session has been created or the camera device has been closed. ### See Also - `StateCallback.onSurfacePrepared` ``` -------------------------------- ### get Source: https://developer.android.com/reference/android/hardware/camera2/CameraExtensionCharacteristics Gets an extension specific camera characteristics field value. 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. ```APIDOC ## get Added in API level 35 ```java public T get (int extension, Key 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’s 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 #### Path Parameters - **extension** (int) - Required - The extension type. Value is either `0` or a combination of `EXTENSION_AUTOMATIC`, `EXTENSION_FACE_RETOUCH`, `EXTENSION_BOKEH`, `EXTENSION_HDR`, `EXTENSION_NIGHT`. - **key** (Key) - Required - 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. ``` -------------------------------- ### finalizeOutputConfigurations Source: https://developer.android.com/reference/android/hardware/camera2/CameraCaptureSession Finalizes output configurations by including deferred and/or extra Surfaces. This method is used to speed up camera startup by deferring certain output configurations until their Surfaces are ready, and can be called when multiple surfaces share the same OutputConfiguration. ```APIDOC ## finalizeOutputConfigurations ### Description Finalize the output configurations that now have their deferred and/or extra Surfaces included. This method can be used to speed up camera startup time by deferring output configurations until their Surfaces are ready. It can also be called when multiple surfaces share the same OutputConfiguration and one of the surfaces becomes available after the CameraCaptureSession is created. ### Method ```java public abstract void finalizeOutputConfigurations (List outputConfigs) ``` ### Parameters #### Path Parameters - `outputConfigs` (List) - Required - A list of `OutputConfigurations` that have had `addSurface` invoked with a valid output Surface after `CameraDevice.createCaptureSessionByOutputConfigurations`. ### Throws - `CameraAccessException` - if the camera device is no longer connected or has encountered a fatal error. - `IllegalArgumentException` - for invalid output configurations, including ones where the source of the Surface is no longer valid or the Surface is from a unsupported source. Or if one of the output configuration was already finished with an included surface in a prior call. - `IllegalStateException` - if this session is no longer active, either because the session was explicitly closed, a new session has been created, or the camera device has been closed. ``` -------------------------------- ### SENSOR_FRAME_DURATION Source: https://developer.android.com/reference/android/hardware/camera2/CaptureRequest Duration from start of frame readout to start of next frame readout. This key is used to control the frame duration, influencing the maximum frame rate achievable by the camera subsystem. It is effective only when auto-exposure or control modes are set to OFF. ```APIDOC ## SENSOR_FRAME_DURATION ### Description Duration from start of frame readout to start of next frame readout. This key controls the frame duration, which is a critical factor in determining the maximum frame rate supported by the camera subsystem. The value is measured in nanoseconds. ### Method Not applicable (this is a key-value pair for capture requests). ### Parameters This key does not take parameters directly but is part of a `CaptureRequest` object. #### Key Details - **Key**: `SENSOR_FRAME_DURATION` - **Type**: `Long` - **Added in API level**: 21 - **Units**: Nanoseconds - **Optional**: Yes, the value may be `null` on some devices. - **Capability**: Present on all camera devices that report `HARDWARE_LEVEL_FULL`. ### Request Example ```json { "SENSOR_FRAME_DURATION": 33333333 } ``` ### Response This key is part of the request, not the response. ### Notes - The frame duration is capped to `max(duration, exposureTime + overhead)`. - Prior to Android 13, the description differed, measuring from exposure start to next exposure start, not sensor readout intervals. - This control is only effective if `android.control.aeMode` or `android.control.mode` is set to OFF. ``` -------------------------------- ### RecommendedStreamConfigurationMap Source: https://developer.android.com/reference/android/hardware/camera2/params/package-summary Immutable class to store the recommended stream configurations to set up `Surfaces` for creating a `capture session` with `android.hardware.camera2.CameraDevice.createCaptureSession(SessionConfiguration)`. ```APIDOC ## Class: RecommendedStreamConfigurationMap ### Description Provides recommended stream configurations for setting up `Surfaces` when creating a capture session. ### Usage Helps in choosing optimal stream settings for camera capture sessions. ``` -------------------------------- ### SessionConfiguration Source: https://developer.android.com/reference/android/hardware/camera2/params/package-summary A helper class that aggregates all supported arguments for capture session initialization. ```APIDOC ## Class: SessionConfiguration ### Description Aggregates all arguments required for initializing a camera capture session. ### Usage Centralizes configuration parameters for creating camera sessions. ``` -------------------------------- ### getSequenceId Source: https://developer.android.com/reference/android/hardware/camera2/CaptureResult Gets the sequence ID for this capture result. ```APIDOC ## getSequenceId ### Description Gets the sequence ID for this capture result. ### Method getSequenceId ### Response #### Success Response (200) - **sequenceId** (Integer) - The sequence ID. #### Response Example { "example": "{\"sequenceId\": 1}" } ``` -------------------------------- ### getId() Source: https://developer.android.com/reference/android/hardware/camera2/CameraDevice Gets the unique ID of this camera device. ```APIDOC ## getId() ### Description Get the ID of this camera device. ### Method String ### Endpoint N/A (SDK Method) ### Parameters None ### Request Example N/A ### Response - **String** - The unique identifier for the camera device. ``` -------------------------------- ### USECASE_RECORD Source: https://developer.android.com/reference/android/hardware/camera2/params/RecommendedStreamConfigurationMap The recommended stream configuration map for recording must contain a subset of efficient video configurations including the ImageFormat.PRIVATE output format for at least all supported profiles. High speed configurations if supported will be available. ```APIDOC ## USECASE_RECORD Added in API level 29 ```java public static final int USECASE_RECORD ``` Constant Value: 1 (0x00000001) ``` -------------------------------- ### getBlue Method Source: https://developer.android.com/reference/android/hardware/camera2/params/RggbChannelVector Gets the blue component of the RggbChannelVector. ```APIDOC ## getBlue Method ### Description Get the blue component. ### Returns - **float** - a floating point value (guaranteed to be finite) ``` -------------------------------- ### getDevice Source: https://developer.android.com/reference/android/hardware/camera2/CameraConstrainedHighSpeedCaptureSession Get the camera device that this session is created for. ```APIDOC ## getDevice ### Description Get the camera device that this session is created for. ### Method `CameraDevice getDevice()` ``` -------------------------------- ### Create Fixed-Resolution InputConfiguration Source: https://developer.android.com/reference/android/hardware/camera2/params/InputConfiguration Use this constructor to create an input configuration for fixed-resolution image buffers. Query `CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP` for supported formats. ```java public InputConfiguration (int width, int height, int format) ``` -------------------------------- ### ExtensionSessionConfiguration Source: https://developer.android.com/reference/android/hardware/camera2/params/package-summary A class that aggregates all supported arguments for `CameraExtensionSession` initialization. ```APIDOC ## Class: ExtensionSessionConfiguration ### Description Aggregates all necessary arguments for initializing a `CameraExtensionSession`. ### Usage Used to configure advanced camera sessions with specific extensions. ``` -------------------------------- ### Get Valid Output Formats for Input Source: https://developer.android.com/reference/android/hardware/camera2/params/StreamConfigurationMap Gets the supported output image formats for a given reprocessing input format. Only formats returned by this method are allowed as output targets when the input format is specified. Returns an empty array if no output format is supported. ```java public int[] getValidOutputFormatsForInput (int inputFormat) ``` -------------------------------- ### get Source: https://developer.android.com/reference/android/hardware/camera2/CaptureResult Retrieves a specific metadata entry from the capture result. ```APIDOC ## get ### Description Retrieves a specific metadata entry from the capture result. ### Method get ### Parameters #### Path Parameters - **key** (Key) - Required - The key of the metadata entry to retrieve. ### Response #### Success Response (200) - **value** (Object) - The metadata entry corresponding to the provided key. #### Response Example { "example": "{\"value\": \"some_metadata_value\"}" } ``` -------------------------------- ### InputConfiguration Public Methods Source: https://developer.android.com/reference/android/hardware/camera2/params/InputConfiguration Public methods available for the InputConfiguration class. ```APIDOC ## equals(Object obj) ### Description Check if this InputConfiguration is equal to another InputConfiguration. ### Parameters #### Path Parameters - **obj** (Object) - Required - The object to compare with. ### Returns - **boolean** - True if the InputConfigurations are equal, false otherwise. ## getFormat() ### Description Get the format of this input configuration. ### Returns - **int** - The format of the input configuration. ## getHeight() ### Description Get the height of this input configuration. ### Returns - **int** - The height of the input configuration. ## getWidth() ### Description Get the width of this input configuration. ### Returns - **int** - The width of the input configuration. ## hashCode() ### Description Returns a hash code value for the object. ### Returns - **int** - A hash code value for this object. ## isMultiResolution() ### Description Whether this input configuration is of multi-resolution. ### Returns - **boolean** - True if the configuration is multi-resolution, false otherwise. ## toString() ### Description Return this `InputConfiguration` as a string representation. ### Returns - **String** - A string representation of the InputConfiguration. ``` -------------------------------- ### getRowCount Source: https://developer.android.com/reference/android/hardware/camera2/params/LensShadingMap Gets the number of rows in this lens shading map. ```APIDOC ## getRowCount ### Description Get the number of rows in this map. ### Method `getRowCount` ### Returns - **int** - The number of rows. ``` -------------------------------- ### createCaptureSession Source: https://developer.android.com/reference/android/hardware/camera2/CameraDevice Creates a new CameraCaptureSession using a SessionConfiguration helper object. This session determines the set of potential output Surfaces for the camera device for each capture request. The configuration process can take time, and a callback is provided for completion. Existing sessions are closed when a new one is created. ```APIDOC ## createCaptureSession ### Description Creates a new `CameraCaptureSession` using a `SessionConfiguration` helper object that aggregates all supported parameters. The active capture session determines the set of potential output Surfaces for the camera device for each capture request. Once the `CameraCaptureSession` is created, requests can be submitted with `capture`, `captureBurst`, `setRepeatingRequest`, or `setRepeatingBurst`. ### Method ```java public void createCaptureSession (SessionConfiguration config) ``` ### Parameters #### Request Body - **config** (SessionConfiguration) - Required - A `SessionConfiguration` object containing parameters for the capture session, including output surfaces and state callbacks. ### Response #### Success Response (onConfigured) - The `CameraCaptureSession.StateCallback.onConfigured` callback is invoked when the session configuration is complete and the session is ready to capture data. ### Throws - **IllegalArgumentException**: If called with a `SessionConfiguration` lacking state callbacks or valid output surfaces, with exceptions for deferred `SurfaceView` or `SurfaceTexture` outputs. ``` -------------------------------- ### getColumnCount Source: https://developer.android.com/reference/android/hardware/camera2/params/LensShadingMap Gets the number of columns in this lens shading map. ```APIDOC ## getColumnCount ### Description Get the number of columns in this map. ### Method `getColumnCount` ### Returns - **int** - The number of columns. ``` -------------------------------- ### USECASE_SNAPSHOT Constant Source: https://developer.android.com/reference/android/hardware/camera2/params/RecommendedStreamConfigurationMap Represents the recommended stream configuration for still capture. Must include ImageFormat.JPEG output format and a configuration with size approximately equal to the sensor active array size. ```java public static final int USECASE_SNAPSHOT ``` -------------------------------- ### Get Keys Source: https://developer.android.com/reference/android/hardware/camera2/CameraCharacteristics Returns a list of all keys contained within this map. ```APIDOC ## getKeys() ### Description Returns a list of the keys contained in this map. ### Method Signature `List> getKeys()` ``` -------------------------------- ### Create Multi-Resolution InputConfiguration Source: https://developer.android.com/reference/android/hardware/camera2/params/InputConfiguration Use this constructor to create an input configuration for multi-resolution image buffers. Query `CameraCharacteristics.SCALER_MULTI_RESOLUTION_STREAM_CONFIGURATION_MAP` for supported formats. This configuration is used for reprocessing with variable resolution input. ```java public InputConfiguration (Collection multiResolutionInputs, int format) ``` -------------------------------- ### getKeys Source: https://developer.android.com/reference/android/hardware/camera2/CaptureResult Gets a list of all available metadata keys in this capture result. ```APIDOC ## getKeys ### Description Gets a list of all available metadata keys in this capture result. ### Method getKeys ### Response #### Success Response (200) - **keys** (List) - A list of metadata keys. #### Response Example { "example": "{\"keys\": [\"FLASH_STATE\", \"SENSOR_TIMESTAMP\"]}" } ``` -------------------------------- ### Capability Constructor Source: https://developer.android.com/reference/android/hardware/camera2/params/Capability Creates a new Capability object with the specified mode, maximum streaming size, and zoom ratio range. ```APIDOC ## Capability(int mode, Size maxStreamingSize, Range zoomRatioRange) ### Description Creates a new Capability object. ### Parameters * **mode** (int) - Required - The supported mode for this capability. * **maxStreamingSize** (Size) - Required - The maximum streaming dimension of this capability. * **zoomRatioRange** (Range) - Required - The zoom ratio range of this capability. ``` -------------------------------- ### getCameraId Source: https://developer.android.com/reference/android/hardware/camera2/CaptureResult Gets the unique identifier of the camera that produced this capture result. ```APIDOC ## getCameraId ### Description Gets the unique identifier of the camera that produced this capture result. ### Method getCameraId ### Response #### Success Response (200) - **cameraId** (String) - The ID of the camera. #### Response Example { "example": "{\"cameraId\": \"0\"}" } ``` -------------------------------- ### Get Recommended Stream Configurations for Preview Use Case Source: https://developer.android.com/reference/android/hardware/camera2/params/RecommendedStreamConfigurationMap Retrieve the recommended stream configurations for the preview use case from CameraCharacteristics. This object can then be used to set up Surfaces for creating a capture session. ```Java CameraCharacteristics characteristics = cameraManager.getCameraCharacteristics(cameraId); RecommendedStreamConfigurationMap configs = characteristics.getRecommendedStreamConfigurationMap( RecommendedStreamConfigurationMap.USECASE_PREVIEW); ``` -------------------------------- ### USECASE_VIDEO_SNAPSHOT Source: https://developer.android.com/reference/android/hardware/camera2/params/RecommendedStreamConfigurationMap The recommended stream configuration map for use case video snapshot must only contain a subset of efficient liveshot configurations including ImageFormat.JPEG output format. The sizes will match at least the maximum resolution of usecase record and will not cause any preview glitches. ```APIDOC ## USECASE_VIDEO_SNAPSHOT Added in API level 29 ```java public static final int USECASE_VIDEO_SNAPSHOT ``` Constant Value: 2 (0x00000002) ``` -------------------------------- ### Get InputConfiguration Width Source: https://developer.android.com/reference/android/hardware/camera2/params/InputConfiguration Retrieves the width of the input buffers for this configuration. ```java public int getWidth () ``` -------------------------------- ### Get InputConfiguration Height Source: https://developer.android.com/reference/android/hardware/camera2/params/InputConfiguration Retrieves the height of the input buffers for this configuration. ```java public int getHeight () ``` -------------------------------- ### USECASE_RECORD Constant Source: https://developer.android.com/reference/android/hardware/camera2/params/RecommendedStreamConfigurationMap Represents the recommended stream configuration for recording. Must include ImageFormat.PRIVATE output format for all supported profiles, and may include high speed configurations. ```java public static final int USECASE_RECORD ``` -------------------------------- ### getInputSurface Source: https://developer.android.com/reference/android/hardware/camera2/CameraConstrainedHighSpeedCaptureSession Get the input Surface associated with a reprocessable capture session. ```APIDOC ## getInputSurface ### Description Get the input Surface associated with a reprocessable capture session. ### Method `Surface getInputSurface()` ``` -------------------------------- ### toString() Source: https://developer.android.com/reference/android/hardware/camera2/params/InputConfiguration Returns a string representation of the InputConfiguration object. The format includes width, height, format, and a multi-resolution flag. ```APIDOC ## toString() ### Description Returns this `InputConfiguration` as a string representation. ### Method ```java public String toString () ``` ### Returns * `String` - A string representation of `InputConfiguration` in the format `"InputConfiguration(w:%d, h:%d, format:%d, isMultiResolution:%d)"`. ``` -------------------------------- ### get Source: https://developer.android.com/reference/android/hardware/camera2/CaptureResult Retrieves a specific capture result field value using its Key. ```APIDOC ## get(Key key) ### Description Get a capture result field value. ### Method `get` ### Parameters #### Path Parameters - **key** (Key) - Required - The key for the desired capture result field. ``` -------------------------------- ### getCameraAudioRestriction() Source: https://developer.android.com/reference/android/hardware/camera2/CameraDevice Gets the currently applied global camera audio restriction mode. ```APIDOC ## getCameraAudioRestriction() ### Description Get currently applied global camera audio restriction mode. ### Method int ### Endpoint N/A (SDK Method) ### Parameters None ### Request Example N/A ### Response - **int** - The current audio restriction mode. ``` -------------------------------- ### Create a new Capability object Source: https://developer.android.com/reference/android/hardware/camera2/params/Capability Use this constructor to create a new Capability object, specifying the supported mode, maximum streaming size, and zoom ratio range. ```java public Capability(int mode, Size maxStreamingSize, Range zoomRatioRange) ``` -------------------------------- ### getHighSpeedVideoSizesFor Source: https://developer.android.com/reference/android/hardware/camera2/params/RecommendedStreamConfigurationMap Gets the supported video sizes for a given high-speed FPS range. ```APIDOC ## getHighSpeedVideoSizesFor ### Description Get the supported video sizes for an input high speed FPS range. ### Method GET ### Endpoint /streamConfigurationMap/highSpeedVideoSizesFor ### Parameters #### Query Parameters - **fpsRange** (Range) - Required - One of the FPS ranges returned by `getHighSpeedVideoFpsRanges()`. ### Returns - **Set** - A non-modifiable set of video sizes to create high-speed capture sessions. This value may be null. ### Throws - **IllegalArgumentException** - If the input FPS range does not exist in the return value of `getHighSpeedVideoFpsRanges()`. ``` -------------------------------- ### prepare Source: https://developer.android.com/reference/android/hardware/camera2/CameraCaptureSession Prepare for a capture. This method can be used to pre-allocate resources for a capture, potentially reducing latency for subsequent captures. ```APIDOC ## prepare ### Description Prepare for a capture. This method can be used to pre-allocate resources for a capture, potentially reducing latency for subsequent captures. ### Method `public abstract void prepare(int templateType)` ### Parameters #### Path Parameters - `templateType` (int) - Required - The capture template type to prepare for (e.g., `CameraMetadata.REQUEST_TYPE_STILL_CAPTURE`). ``` -------------------------------- ### OutputConfiguration Source: https://developer.android.com/reference/android/hardware/camera2/params/package-summary A class for describing camera output, which contains a `Surface` and its specific configuration for creating capture session. ```APIDOC ## Class: OutputConfiguration ### Description Describes the configuration for a camera output, including the target `Surface` and session-specific settings. ### Usage Used to define where and how camera output data should be directed. ``` -------------------------------- ### getTimestampNanos Method Source: https://developer.android.com/reference/android/hardware/camera2/params/LensIntrinsicsSample Gets the timestamp of the sample in nanoseconds. The timestamp is comparable to android.sensor.timestamp. ```java public long getTimestampNanos () ``` -------------------------------- ### Get Keys Source: https://developer.android.com/reference/android/hardware/camera2/CameraExtensionCharacteristics Returns the CameraCharacteristics keys that have extension-specific values for a given extension. ```APIDOC ## getKeys(int extension) ### Description Returns the `CameraCharacteristics` keys that have extension-specific values. ### Method Signature `Set> getKeys(int extension)` ```