# C201 Prompts: AI Assistant Prompts for Calibrating a Stereo Rig

> Copy-paste prompts for an AI assistant from the C201 camera calibration course: write a Kalibr target.yaml, plan a calibration recording, audit coverage, choose a fisheye model, review a Kalibr result, convert a camchain to OpenCV, compare two calibrations and read mrcal's diagnostics. Each states its inputs, the tool it targets, how to check the output and the field guide page it relies on.

Page: https://egocam.ai/university/c201/prompts/

These prompts hand one practical job each to an AI assistant (Claude, ChatGPT, Gemini or another). Paste your own files and values where the square brackets are. Each prompt states what it needs, which tool it targets, how to check what comes back, and the field guide page whose facts it relies on.

An assistant can misread a transform's direction or invent a threshold as easily as a person can. The prompts tell it not to, and every one ends with a check you run yourself. Treat the output as a draft until that check passes.

## Write a Kalibr target.yaml for my Aprilgrid

- **Inputs:** the grid's tag counts and your measurements of the printed board.
- **Tool:** Kalibr.
- **Relies on:** [target.yaml](https://egocam.ai/kalibr/kalibr-file-reference/#targetyaml-the-calibration-board) and [Measuring a printed target](https://egocam.ai/kalibr/kalibr-file-reference/#measuring-a-printed-target).
- **How to check:** `tagSpacing` lies between 0 and 1, every length has a decimal point, and after a calibration the target block at the end of `results-cam.txt` shows the same numbers.

```text
Write a Kalibr target.yaml for an Aprilgrid. Kalibr's format has target_type 'aprilgrid',
tagCols and tagRows (tag counts), tagSize (one tag's width across its black border, in
metres) and tagSpacing (the gap between tags divided by tagSize: a ratio, not a length).
Lengths must be written with a decimal point.

My printed grid has [COLS] tags across and [ROWS] tags down. My measurements:
- across [N] tags and the [N-1] gaps between them: [LENGTH] mm
- one tag's outer black edge: [TAG] mm
- one gap between neighbouring tags: [GAP] mm

Use the long measurement to cross-check the other two: n tags and n-1 gaps span
tagSize x (n + (n-1) x tagSpacing). Show the arithmetic, say if the measurements disagree,
and give the final YAML. Do not round to the size I asked the printer for.
```

## Plan my calibration recording

- **Inputs:** each lens's field of view, the image resolution, the target and the distance between the cameras.
- **Tool:** Kalibr or mrcal.
- **Relies on:** [Calibration Targets and Calibration Sequences](https://egocam.ai/calibration/targets-and-calibration-sequences/#recording-the-camera-sequence) and [Lesson 2](https://egocam.ai/university/c201/lesson-2-targets-and-recording/).
- **How to check:** the plan has close-ups and tilted views for each camera, covers the image corners and edges, includes shared views, and cites a source for every number in it. Compare it with the [checklist](https://egocam.ai/university/c201/checklist/#during-recording).

```text
Plan a camera calibration recording for my fisheye stereo pair. Rig: [lens field of view,
resolution, distance between the lenses]. Target: [Aprilgrid or chessboard, its size].
Tool: [Kalibr or mrcal].

Follow these sourced rules and cite which one each step serves:
- Kalibr's multiple-camera guide: the cameras stay fixed and the target moves; lower the
  camera rate to around 4 Hz while capturing.
- mrcal's choreography study: close-ups matter most; head-on views give poor results, with
  diminishing returns at about 45 degrees of tilt; about 100 frames before returns diminish
  (a synthetic result for one lens); avoid extreme close-ups where the lens is non-central.
- mrcal's guide: get close-ups for each camera individually, and also joint views both
  cameras see, from just far enough out.
- The target must reach every part of both images, the corners above all.

Give me an ordered list of board positions and motions, and a way to confirm coverage while
recording. Do not invent distances, frame counts or tolerances that are not in these rules;
where my rig needs a number the rules do not give, say so.
```

## Audit the coverage of my calibration images

- **Inputs:** a folder of calibration images per camera, and the target's layout.
- **Tool:** OpenCV (`cv2.aruco`), before running Kalibr or mrcal.
- **Relies on:** [Calibration Targets and Calibration Sequences](https://egocam.ai/calibration/targets-and-calibration-sequences/#prompts-you-can-give-an-ai) (this prompt is adapted from the one there) and [Judging a Calibration, check 1](https://egocam.ai/calibration/judging-a-calibration/#check-1-coverage-and-the-shape-of-the-residuals).
- **How to check:** run the script on a few images where you can see the board by eye, and confirm the plotted corners land on it. Compare its coverage map with the corner plot in Kalibr's `report-cam.pdf`.

```text
Write a Python script with OpenCV (cv2.aruco) that audits a folder of calibration images
before I calibrate. For each camera: detect the Aprilgrid or ChArUco corners in every image,
plot all detected corners on one image-sized canvas, report the fraction of a 5 x 5 grid of
image cells with no corners at all, and estimate each view's board tilt from its homography.
Flag recordings with no corners in the image corners, or with almost only head-on views.
For a stereo pair, also count the frames in which both cameras detected the board at the
same timestamp. My target: [type, rows, columns, tag or square size]. My folders: [paths].
```

## Choose a camera model for my lens

- **Inputs:** the lens datasheet (field of view, projection if stated) and what your pipeline reads.
- **Tool:** Kalibr, OpenCV or mrcal.
- **Relies on:** [Lens Projections and Distortion](https://egocam.ai/lens-physics/projections-and-distortion/#which-model-for-which-lens) and [Calibration Tools Compared](https://egocam.ai/calibration/calibration-tools-compared/#camera-models-across-tools).
- **How to check:** the recommended model appears in the field guide's model table for your lens type and in the tool's own model list, and your pipeline can read it.

```text
Recommend a calibration model for each camera of my stereo rig. Lens: [datasheet field of
view, stated projection if any]. Calibration tool: [Kalibr, OpenCV or mrcal]. My downstream
pipeline reads: [e.g. OpenCV fisheye / Kannala-Brandt, double sphere, pinhole + radtan].

Use only these facts:
- Usenko, Demmel and Cremers (2018): a pinhole model with distortion performs suboptimally
  beyond about 120 degrees; Kannala-Brandt applied after a pinhole projection (Kalibr
  pinhole-equi, OpenCV fisheye) has a singularity at 90 degrees off axis, unsuitable near
  180 degrees; double sphere was within 1% of KB 8's reprojection error on lenses from
  122 to 195 degrees.
- Kalibr's models: pinhole-radtan, pinhole-equi, pinhole-fov, omni-none, omni-radtan,
  eucm-none, ds-none. mrcal fits one model to all cameras in a run.
- Use the model the pipeline consumes.
Give the model name exactly as the tool spells it, and say what I lose if the pipeline's
model differs from the best-fitting one.
```

## Review my Kalibr camera calibration

- **Inputs:** `results-cam.txt`, `camchain.yaml`, `target.yaml`, your measured lens spacing and a description of the report's plots.
- **Tool:** Kalibr.
- **Relies on:** [results-cam.txt](https://egocam.ai/kalibr/kalibr-file-reference/#results-camtxt-camera-calibration), [report-cam.pdf](https://egocam.ai/kalibr/kalibr-file-reference/#report-campdf-camera-calibration) and [Lesson 4](https://egocam.ai/university/c201/lesson-4-reading-the-result/).
- **How to check:** go through each point the assistant raises against the files yourself. It must not have applied any pass mark; the field guide's sources give none.

```text
Here are my Kalibr results-cam.txt, camchain.yaml and target.yaml for a stereo pair, my
caliper measurement of the distance between the two lenses ([X] m), and what the report
shows: [corner plot coverage, polar error shape, observation graph].
Kalibr's conventions: T_cn_cnm1 under cam1 is T_c1_c0 and maps cam0 coordinates to cam1
coordinates; translations are in metres; the reprojection error line gives a mean and a
standard deviation in x and y, in pixels; "+-" values are parameter standard deviations.

Check, and show your working:
1. The target block in results-cam.txt matches target.yaml.
2. The reprojection error means are close to zero and the spreads are similar for both cameras.
3. Which parameters have large standard deviations relative to their values.
4. The baseline norm of T_cn_cnm1 against my measured spacing, as a percentage.
5. Each intrinsics and distortion_coeffs list has the right length for its model.
6. What the plots I described suggest about coverage and model fit.
Do not apply pass/fail thresholds; no calibration tool publishes one. List what looks
inconsistent and why, most serious first.

[paste results-cam.txt]
[paste camchain.yaml]
[paste target.yaml]
```

## Convert my Kalibr camchain to OpenCV format

- **Inputs:** a Kalibr `camchain.yaml` for a stereo pair.
- **Tool:** OpenCV (`cv2` and `cv2.fisheye`).
- **Relies on:** the [Kalibr workflow's conversion prompt](https://egocam.ai/kalibr/kalibr-workflow/#convert-kalibr-output-to-opencv-or-ros-camera_info), [camera_model and intrinsics](https://egocam.ai/kalibr/kalibr-file-reference/#camera_model-and-intrinsics) and [How Kalibr names transforms](https://egocam.ai/kalibr/kalibr-file-reference/#how-kalibr-names-transforms).
- **How to check:** the norm of the converted T equals the baseline norm in `results-cam.txt`; projecting a few 3D points with Kalibr's model and with the converted OpenCV model gives the same pixels.

```text
Convert this Kalibr camchain.yaml for a stereo pair into OpenCV camera matrices and
distortion vectors, plus the R and T that cv2.stereoRectify (or cv2.fisheye.stereoRectify)
expects. Kalibr's pinhole intrinsics are [fu, fv, pu, pv]. radtan coefficients are
[k1, k2, p1, p2]. equidistant coefficients are [k1, k2, k3, k4] of the Kannala-Brandt
model, which OpenCV implements in cv2.fisheye. T_cn_cnm1 under cam1 maps cam0 coordinates
to cam1 coordinates; OpenCV's stereo R and T bring points from the first camera's frame to
the second's.
For each camera, say which OpenCV model you used and why. If a camera uses omni, ds or eucm,
tell me there is no exact equivalent instead of approximating silently. Write Python that
loads the YAML, builds the matrices, and checks the conversion by projecting ten 3D points
with both the Kalibr formulas and OpenCV and printing the pixel differences.

[paste camchain.yaml]
```

## Compare two calibrations of the same camera

- **Inputs:** two calibrations of one camera from independent recordings.
- **Tool:** Python with OpenCV, or mrcal's `mrcal-show-projection-diff` if both were solved in mrcal.
- **Relies on:** [Judging a Calibration, check 4](https://egocam.ai/calibration/judging-a-calibration/#check-4-repeatability-across-recordings) (this prompt is adapted from the one on that page).
- **How to check:** comparing a calibration with itself gives zero everywhere; for two mrcal models, the script's map agrees in shape with `mrcal-show-projection-diff`.

```text
Write a Python script that compares two camera calibrations of the same camera in pixel
space: grid the image, unproject each grid point with model A, project it with model B, and
plot a heat map of the pixel difference, with the largest differences and where they sit.
Accept OpenCV pinhole or fisheye models, or a Kalibr camchain.yaml. Do not compare the
parameters one by one: high-order distortion coefficients can differ widely while the
projections stay nearly identical. Include a self-test that compares a model with itself.

[paste or describe model A and model B]
```

## Read my mrcal diagnostics and tell me what to record next

- **Inputs:** screenshots or descriptions of `mrcal-show-projection-uncertainty`, `mrcal-show-projection-diff` and `mrcal-show-residuals-board-observation`, and the fitted board warp.
- **Tool:** mrcal.
- **Relies on:** [Judging a Calibration](https://egocam.ai/calibration/judging-a-calibration/#check-2-projection-uncertainty-in-pixels), [Calibration Tools Compared](https://egocam.ai/calibration/calibration-tools-compared/#prompts-you-can-give-an-ai) and the [lab, part B](https://egocam.ai/university/c201/lab/#part-b-optional-judge-the-intrinsics-with-mrcal).
- **How to check:** each recommendation names the plot region that motivates it; record what it suggests and confirm the uncertainty map improves there.

```text
Here are mrcal's diagnostics for one camera of my stereo pair: the projection uncertainty
map, the cross-validation diff between two independent dances, the worst board
observations' residuals, and the fitted calobject_warp: [describe or attach].
mrcal's documentation says: where uncertainty is poor, more chessboard observations are
needed in that area; if the models fit, the cross-validation diff is about the sum of the
two uncertainties, and far above double the uncertainty suggests model errors; residuals
should show no pattern.
Tell me whether the evidence points to too little coverage, a lens model that is too
simple, a warped or unstable board, non-central behaviour from close-ups, or a sync or
rolling-shutter problem, and what to record next. Say which plot supports each conclusion.
```

## Sources

- Field guide: [Kalibr File Reference](https://egocam.ai/kalibr/kalibr-file-reference/), [Kalibr Workflow](https://egocam.ai/kalibr/kalibr-workflow/), [Calibration Targets and Calibration Sequences](https://egocam.ai/calibration/targets-and-calibration-sequences/), [Judging a Calibration](https://egocam.ai/calibration/judging-a-calibration/), [Lens Projections and Distortion](https://egocam.ai/lens-physics/projections-and-distortion/), [Calibration Tools Compared](https://egocam.ai/calibration/calibration-tools-compared/).
- Kalibr wiki, ETH Zurich ASL: [multiple-camera calibration](https://github.com/ethz-asl/kalibr/wiki/multiple-camera-calibration), [calibration targets](https://github.com/ethz-asl/kalibr/wiki/calibration-targets) and [YAML formats](https://github.com/ethz-asl/kalibr/wiki/Yaml-formats).
- Kogan, D. mrcal: [how to calibrate](https://mrcal.secretsauce.net/how-to-calibrate.html), [optimal choreography](https://mrcal.secretsauce.net/tour-choreography.html) and [cross-validation](https://mrcal.secretsauce.net/tour-cross-validation.html).
- Usenko, V., Demmel, N. and Cremers, D. (2018). [The double sphere camera model](https://arxiv.org/abs/1807.08957v1). *3DV*.
- OpenCV [calib3d module reference](https://docs.opencv.org/4.x/d9/d0c/group__calib3d.html).
