# CaptureResultWrapper

Artifact: [androidx.camera:camera-common](https://developer.android.com/jetpack/androidx/releases/camera) [View Source](https://cs.android.com/search?q=file:androidx/camera/common/CaptureResultWrapper.kt+class:androidx.camera.common.CaptureResultWrapper) Added in [1.7.0-rc02](https://developer.android.com/jetpack/androidx/releases/camera#1.7.0-rc02)

*** ** * ** ***


```
public interface CaptureResultWrapper extends CaptureResultMetadata
```

<br />

Known direct subclasses [FakeCaptureResult](https://developer.android.com/reference/androidx/camera/common/testing/FakeCaptureResult)

|---|---|
| `https://developer.android.com/reference/androidx/camera/common/testing/FakeCaptureResult` | A fake implementation of `https://developer.android.com/reference/androidx/camera/common/CaptureResultWrapper` for testing. |

*** ** * ** ***

A wrapper interface providing compatibility-focused access to `https://developer.android.com/reference/android/hardware/camera2/CaptureResult.html` and custom metadata.

Use this interface to query the results of a single image capture, including sensor exposure, lens status, and 3A states.

Since this interface extends `https://developer.android.com/reference/androidx/camera/common/Metadata`, it supports querying both standard `https://developer.android.com/reference/android/hardware/camera2/CaptureResult.Key.html`s and custom `https://developer.android.com/reference/androidx/camera/common/Metadata.Key`s.

To access the underlying native `https://developer.android.com/reference/android/hardware/camera2/CaptureResult.html` (if available), use the `https://developer.android.com/reference/androidx/camera/common/UnsafeWrapper#unwrapAs(java.lang.Class)` extension function:

```
val nativeResult = resultMetadata.unwrapAs<CaptureResult>()
```

**Note:** This interface is not stable for inheritance. Implementations should not be created directly by clients. For testing, use the fakes in the `androidx.camera.common.testing` package, such as `FakeCaptureResult`.

```kotlin
import androidx.camera.common.CameraId
import androidx.camera.common.CaptureRequestWrappers
import androidx.camera.common.CaptureResultWrapper
import androidx.camera.common.CaptureResultWrappers

val cameraId = CameraId("0")
val captureRequest = CaptureRequestWrappers.wrap(captureResult.request)

// Wrap a native CaptureResult into a CaptureResultWrapper.
val resultWrapper: CaptureResultWrapper =
    CaptureResultWrappers.wrap(
        captureResult = captureResult,
        cameraId = cameraId,
        captureRequest = captureRequest,
    )

// Query standard Camera2 result keys:
val lensState = resultWrapper[CaptureResult.LENS_STATE]
val frameNumber = resultWrapper.frameNumber
val originatingRequest = resultWrapper.captureRequest
```

```kotlin
import androidx.camera.common.CameraFrameNumber
import androidx.camera.common.CameraId
import androidx.camera.common.CaptureResultWrapper
import androidx.camera.common.Metadata
import androidx.camera.common.testing.FakeCaptureRequest
import androidx.camera.common.testing.FakeCaptureResult

val customKey = Metadata.Key<String>("com.example.custom_result_data")
val fakeRequest = FakeCaptureRequest()

// Create a FakeCaptureResult for unit testing without requiring a real camera device.
val fakeResult: CaptureResultWrapper =
    FakeCaptureResult(
        cameraId = CameraId("0"),
        frameNumber = CameraFrameNumber(42L),
        captureRequest = fakeRequest,
        resultParameters =
            mapOf(
                CaptureResult.LENS_STATE to CaptureResult.LENS_STATE_STATIONARY,
                CaptureResult.CONTROL_AE_STATE to CaptureResult.CONTROL_AE_STATE_CONVERGED,
            ),
        resultMetadata = mapOf(customKey to "test_result_value"),
    )

// Query values and verify assertions in unit tests:
val lensState = fakeResult[CaptureResult.LENS_STATE]
val frameNumber = fakeResult.frameNumber
val customValue = fakeResult[customKey]
```

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/camera/common/CaptureResultMetadata` |   |

## Summary

| ### Public methods |
|---|---|
| `abstract @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/camera/common/CameraId` | `https://developer.android.com/reference/androidx/camera/common/CaptureResultWrapper#getCameraId()()` The `https://developer.android.com/reference/androidx/camera/common/CameraId` of the camera that produced this result. |
| `abstract @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/camera/common/CaptureRequestWrapper` | `https://developer.android.com/reference/androidx/camera/common/CaptureResultWrapper#getCaptureRequest()()` The `https://developer.android.com/reference/androidx/camera/common/CaptureRequestWrapper` that generated this capture result. |
| `abstract @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/camera/common/CameraFrameNumber` | `https://developer.android.com/reference/androidx/camera/common/CaptureResultWrapper#getFrameNumber()()` The `https://developer.android.com/reference/androidx/camera/common/CameraFrameNumber` associated with this result. |
| `abstract @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/List.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/hardware/camera2/CaptureResult.Key.html<@https://developer.android.com/reference/androidx/annotation/NonNull ?>>` | `https://developer.android.com/reference/androidx/camera/common/CaptureResultWrapper#getKeys()()` List of all `https://developer.android.com/reference/android/hardware/camera2/CaptureResult.Key.html`s supported by this capture result. |

### Inherited methods

From [androidx.camera.common.CaptureResultMetadata](https://developer.android.com/reference/androidx/camera/common/CaptureResultMetadata) `abstract T` `<T extends https://developer.android.com/reference/java/lang/Object.html> https://developer.android.com/reference/androidx/camera/common/CaptureResultMetadata#get(android.hardware.camera2.CaptureResult.Key)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/hardware/camera2/CaptureResult.Key.html<@https://developer.android.com/reference/androidx/annotation/NonNull T> key)`

Retrieves the value of the specified `https://developer.android.com/reference/android/hardware/camera2/CaptureResult.Key.html`.
`default @https://developer.android.com/reference/androidx/annotation/NonNull T` `<T extends https://developer.android.com/reference/java/lang/Object.html> https://developer.android.com/reference/androidx/camera/common/CaptureResultMetadata#getOrDefault(android.hardware.camera2.CaptureResult.Key,kotlin.Any)(
@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/hardware/camera2/CaptureResult.Key.html<@https://developer.android.com/reference/androidx/annotation/NonNull T> key,
@https://developer.android.com/reference/androidx/annotation/NonNull T default
)`

Retrieves the value of the specified `https://developer.android.com/reference/android/hardware/camera2/CaptureResult.Key.html`, or returns `https://developer.android.com/reference/androidx/camera/common/CaptureResultMetadata#getOrDefault(android.hardware.camera2.CaptureResult.Key,kotlin.Any)` if the key is not present or its value is null.
From [androidx.camera.common.Metadata](https://developer.android.com/reference/androidx/camera/common/Metadata) `abstract T` `<T extends https://developer.android.com/reference/java/lang/Object.html> https://developer.android.com/reference/androidx/camera/common/Metadata#get(androidx.camera.common.Metadata.Key)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/camera/common/Metadata.Key<@https://developer.android.com/reference/androidx/annotation/NonNull T> key)`

Retrieves the value associated with the specified `https://developer.android.com/reference/androidx/camera/common/Metadata.Key`.
`abstract @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/Set.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/camera/common/Metadata.Key<@https://developer.android.com/reference/androidx/annotation/NonNull ?>>` `https://developer.android.com/reference/androidx/camera/common/Metadata#getMetadataKeys()()`

The set of all custom `https://developer.android.com/reference/androidx/camera/common/Metadata.Key`s currently available in this container.
`default @https://developer.android.com/reference/androidx/annotation/NonNull T` `<T extends https://developer.android.com/reference/java/lang/Object.html> https://developer.android.com/reference/androidx/camera/common/Metadata#getOrDefault(androidx.camera.common.Metadata.Key,kotlin.Any)(
@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/camera/common/Metadata.Key<@https://developer.android.com/reference/androidx/annotation/NonNull T> key,
@https://developer.android.com/reference/androidx/annotation/NonNull T default
)`

Retrieves the value associated with the specified `https://developer.android.com/reference/androidx/camera/common/Metadata.Key`, or returns `https://developer.android.com/reference/androidx/camera/common/Metadata#getOrDefault(androidx.camera.common.Metadata.Key,kotlin.Any)` if the key is not present.
From [androidx.camera.common.UnsafeWrapper](https://developer.android.com/reference/androidx/camera/common/UnsafeWrapper) `abstract T` `<T extends https://developer.android.com/reference/java/lang/Object.html> https://developer.android.com/reference/androidx/camera/common/UnsafeWrapper#unwrapAs(java.lang.Class)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Class.html<@https://developer.android.com/reference/androidx/annotation/NonNull T> type)`

Attempts to unwrap this object into the specified underlying `https://developer.android.com/reference/androidx/camera/common/UnsafeWrapper#unwrapAs(java.lang.Class)`.

## Public methods

### getCameraId

Added in [1.7.0-rc02](https://developer.android.com/jetpack/androidx/releases/camera#1.7.0-rc02)

```
abstract @NonNull CameraId getCameraId()
```

The `https://developer.android.com/reference/androidx/camera/common/CameraId` of the camera that produced this result.

### getCaptureRequest

Added in [1.7.0-rc02](https://developer.android.com/jetpack/androidx/releases/camera#1.7.0-rc02)

```
abstract @NonNull CaptureRequestWrapper getCaptureRequest()
```

The `https://developer.android.com/reference/androidx/camera/common/CaptureRequestWrapper` that generated this capture result.

This represents the request settings that were active when this result was produced.

### getFrameNumber

Added in [1.7.0-rc02](https://developer.android.com/jetpack/androidx/releases/camera#1.7.0-rc02)

```
abstract @NonNull CameraFrameNumber getFrameNumber()
```

The `https://developer.android.com/reference/androidx/camera/common/CameraFrameNumber` associated with this result.

The frame number is a unique, monotonically increasing identifier for the frame.

### getKeys

Added in [1.7.0-rc02](https://developer.android.com/jetpack/androidx/releases/camera#1.7.0-rc02)

```
abstract @NonNull List<@NonNull CaptureResult.Key<@NonNull ?>> getKeys()
```

List of all `https://developer.android.com/reference/android/hardware/camera2/CaptureResult.Key.html`s supported by this capture result.

The list of all `https://developer.android.com/reference/android/hardware/camera2/CaptureResult.Key.html`s that are supported and can be queried from this result.

| See also |
|---|---|
| `https://developer.android.com/reference/android/hardware/camera2/CaptureResult.html#getKeys()` |   |