# 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)

*** ** * ** ***


```
interface CaptureResultWrapper : CaptureResultMetadata
```

<br />

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

|---|---|
| `https://developer.android.com/reference/kotlin/androidx/camera/common/testing/FakeCaptureResult` | A fake implementation of `https://developer.android.com/reference/kotlin/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/kotlin/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/kotlin/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/kotlin/androidx/camera/common/UnsafeWrapper#unwrapAs(java.lang.Class)` extension function:

```kotlin
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/kotlin/androidx/camera/common/CaptureResultMetadata` |   |

## Summary

| ### Public properties |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/camera/common/CameraId` | `https://developer.android.com/reference/kotlin/androidx/camera/common/CaptureResultWrapper#cameraId()` The `https://developer.android.com/reference/kotlin/androidx/camera/common/CameraId` of the camera that produced this result. |
| `https://developer.android.com/reference/kotlin/androidx/camera/common/CaptureRequestWrapper` | `https://developer.android.com/reference/kotlin/androidx/camera/common/CaptureResultWrapper#captureRequest()` The `https://developer.android.com/reference/kotlin/androidx/camera/common/CaptureRequestWrapper` that generated this capture result. |
| `https://developer.android.com/reference/kotlin/androidx/camera/common/CameraFrameNumber` | `https://developer.android.com/reference/kotlin/androidx/camera/common/CaptureResultWrapper#frameNumber()` The `https://developer.android.com/reference/kotlin/androidx/camera/common/CameraFrameNumber` associated with this result. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/android/hardware/camera2/CaptureResult.Key.html<*>>` | `https://developer.android.com/reference/kotlin/androidx/camera/common/CaptureResultWrapper#keys()` List of all `https://developer.android.com/reference/android/hardware/camera2/CaptureResult.Key.html`s supported by this capture result. |

### Inherited functions

From [androidx.camera.common.CaptureResultMetadata](https://developer.android.com/reference/kotlin/androidx/camera/common/CaptureResultMetadata) `operator T?` `<T : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html> https://developer.android.com/reference/kotlin/androidx/camera/common/CaptureResultMetadata#get(android.hardware.camera2.CaptureResult.Key)(key: https://developer.android.com/reference/android/hardware/camera2/CaptureResult.Key.html<T>)`

Retrieves the value of the specified `https://developer.android.com/reference/android/hardware/camera2/CaptureResult.Key.html`.
`open T` `<T : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html> https://developer.android.com/reference/kotlin/androidx/camera/common/CaptureResultMetadata#getOrDefault(android.hardware.camera2.CaptureResult.Key,kotlin.Any)(key: https://developer.android.com/reference/android/hardware/camera2/CaptureResult.Key.html<T>, default: T)`

Retrieves the value of the specified `https://developer.android.com/reference/android/hardware/camera2/CaptureResult.Key.html`, or returns `https://developer.android.com/reference/kotlin/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/kotlin/androidx/camera/common/Metadata) `operator T?` `<T : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html> https://developer.android.com/reference/kotlin/androidx/camera/common/Metadata#get(androidx.camera.common.Metadata.Key)(key: https://developer.android.com/reference/kotlin/androidx/camera/common/Metadata.Key<T>)`

Retrieves the value associated with the specified `https://developer.android.com/reference/kotlin/androidx/camera/common/Metadata.Key`.
`open T` `<T : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html> https://developer.android.com/reference/kotlin/androidx/camera/common/Metadata#getOrDefault(androidx.camera.common.Metadata.Key,kotlin.Any)(key: https://developer.android.com/reference/kotlin/androidx/camera/common/Metadata.Key<T>, default: T)`

Retrieves the value associated with the specified `https://developer.android.com/reference/kotlin/androidx/camera/common/Metadata.Key`, or returns `https://developer.android.com/reference/kotlin/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/kotlin/androidx/camera/common/UnsafeWrapper) `T?` `<T : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html> https://developer.android.com/reference/kotlin/androidx/camera/common/UnsafeWrapper#unwrapAs(java.lang.Class)(type: https://developer.android.com/reference/java/lang/Class.html<T>)`

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

### Inherited properties

From [androidx.camera.common.Metadata](https://developer.android.com/reference/kotlin/androidx/camera/common/Metadata) `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-set/index.html<https://developer.android.com/reference/kotlin/androidx/camera/common/Metadata.Key<*>>` `https://developer.android.com/reference/kotlin/androidx/camera/common/Metadata#metadataKeys()`

The set of all custom `https://developer.android.com/reference/kotlin/androidx/camera/common/Metadata.Key`s currently available in this container.

## Public properties

### cameraId

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

```
val cameraId: CameraId
```

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

### captureRequest

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

```
val captureRequest: CaptureRequestWrapper
```

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

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

### frameNumber

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

```
val frameNumber: CameraFrameNumber
```

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

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

### keys

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

```
val keys: List<CaptureResult.Key<*>>
```

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()` |   |