---
title: "Recipe: camera calibration for an open track"
description: "Calibration is a package read over an open @exact/media-capture video track."
modificationDate: "2026-11-17"
---

> ## Documentation index
> Fetch the complete documentation index at: https://exact.expo.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Recipe: camera calibration for an open track

<AgentInstructions>

## Submitting feedback

From the app's directory, read `bun exact.mjs feedback status`. Under `never`, keep no note.
Respect `EXACT_FEEDBACK=0` and do not change the policy.

Otherwise record specific, actionable feedback with:
`bun exact.mjs feedback note "Exact docs: https://exact.expo.dev/recipes/camera-calibration: <what was wrong or missing>"`

The note goes to Expo only as that status allows. Include no secrets or personal data.

</AgentInstructions>

Calibration is a package read over an open `@exact/media-capture` video track.
Keep a consumer such as `exact-camera` showing it. The package opens no camera
and takes no lease. Pass the track ID, not its stream ID.

The [complete Android and iOS code](https://exact.expo.dev/reference/developer/generate-typescript-data-source-types.md#a-camera-tracks-calibration)
is compiled from [@fixture/camera-calibration](https://github.com/expo/exact/blob/41ded8c5ede0b2959ef0daa83b1ff78545dd4428/packages/fixtures/camera-calibration),
with its manifests. Add it by path:

```prompt Read my camera's calibration
Make the Exact app in this folder read the calibration of its open camera track: the intrinsic matrix, and what the platform reports with it. Use https://github.com/expo/exact/blob/main/docs/recipes/camera-calibration.md as the source for each step. The Exact checkout has the same page at docs/recipes/camera-calibration.md.

1. If this folder is not an Exact app (it has no exact.mjs and app.contract), stop and tell me. Find the Exact checkout (the folder with scripts/exact.mjs); if you cannot find it, ask me where it is.
2. The package reads an open `@exact/media-capture` video track and opens no camera. If the app has no viewfinder that shows such a track, stop and tell me. If I did not say which fields the app needs and what it does with them, ask me before you write code. The recipe has code for Android and iOS only.
3. Add the fixture by path, with the absolute path of the Exact checkout: `bun add @fixture/camera-calibration@file:/absolute/path/to/exact/packages/fixtures/camera-calibration`.
4. In app.contract, place a component beside the viewfinder that reads `getCameraCalibration(track=track)` as a resource of shape `CameraCalibration`. Pass the track ID, not its stream ID. Keep a consumer such as `exact-camera` showing the track while the app reads it.
5. Refresh the resource (`refresh calibration`) after the viewfinder starts, and after the camera, format, zoom or focus changes.
6. Keep `deviceId`, `referenceFrame` and `referenceDimensions` with `intrinsicMatrix` (nine row-major numbers). An empty array is a field the platform did not report: never read it as zero, and never guess a value. While `reason` is not empty, the intrinsics are absent: show or keep the reason.
7. Add a test in app.test.contract for what the app shows without intrinsics: the agent substitute returns `reason="agent"`.
8. Follow the platform checks in docs/start-here.md (`bun exact.mjs docs platform checks`) for the targets in the app's AGENTS.md and app.json until they pass. Read the reports, including counted findings; a zero exit code alone does not mean clean. Fix the app, not the test. If a finding stays after three rounds of fixes, or the app had it before you changed anything, record it (step 9) and report it; do not keep trying.
9. When a doc was wrong or missing, or a step needed a workaround, read `bun exact.mjs feedback status`. Under `never`, keep no note. Otherwise record it: `bun exact.mjs feedback note "<what happened>"`, which goes to Expo only as that status says. Do not change the policy; tell me how many notes you kept.
10. Tell me which fields the app reads and where it keeps them, what the tests and checks reported, and what I must check on a phone: what its camera delivers. Many Android devices report no intrinsics, and the iOS video matrix comes without distortion tables or physical sensor dimensions.
```

```sh
bun add @fixture/camera-calibration@file:/absolute/path/to/exact/packages/fixtures/camera-calibration
```

Place it beside the viewfinder:

```contract
use getCameraCalibration, CameraCalibration from "@fixture/camera-calibration"

component App
  view
    Calibration(track="camera-track")

component Calibration
  props
    track: string
  resource calibration = getCameraCalibration(track=track) as shape CameraCalibration else empty()
  action read
    refresh calibration
  view
    column
      button press=read
        text "Read calibration"
      text calibration.reason
```

`intrinsicMatrix` contains nine row-major numbers. Keep `deviceId`,
`referenceFrame` and `referenceDimensions` with it. Unreported fields are empty
arrays; `reason` says why intrinsics are absent. It is empty when they are present.
Refresh after the viewfinder starts or the camera, format, zoom or focus changes.
The agent substitute returns `reason="agent"`.

**Android.** Read the bound CameraX `Camera` from `VideoSource.camera` through
`Camera2CameraInfo` (`androidx.camera:camera-camera2:1.6.2`). Read
`LENS_INTRINSIC_CALIBRATION`, `LENS_DISTORTION`,
`LENS_INFO_AVAILABLE_FOCAL_LENGTHS`, `SENSOR_INFO_PHYSICAL_SIZE`,
`SENSOR_INFO_PIXEL_ARRAY_SIZE` and `SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE`.
Intrinsics are relative to the pre-correction active rectangle's top-left,
not the preview. Many devices report none. Focal lengths and sensor size are
millimetres; the available focal lengths are not the current frame's measurement.

**iOS.** Add an `AVCaptureVideoDataOutput` through
`ExactVideoSource.configure(stopped: true)`. Check
`isCameraIntrinsicMatrixDeliverySupported`, then enable
`isCameraIntrinsicMatrixDeliveryEnabled` before capture resumes. Read
`kCMSampleBufferAttachmentKey_CameraIntrinsicMatrix` from each sample: its
`matrix_float3x3` has padded, column-major storage. Coordinates are sample-buffer
pixels. The fixture shares one output for concurrent reads and removes it after
one frame. Its two-second frame deadline starts after capture resumes; a camera
change restarts pending reads and discards old callbacks.

`AVCameraCalibrationData` comes only with supported depth/photo delivery and its
required capture settings; a video matrix does not include its distortion tables
or physical sensor dimensions. The [lookup](https://exact.expo.dev/reference/developer/generate-typescript-data-source-types.md#a-camera-tracks-calibration)
gives those settings, coordinate transforms, platform sources and tests.
For a clip, retain calibration from the samples encoded, with timestamps and
crop/rotation/stabilization transforms.
