Understand calibration and check a camera projection

Project known camera-space points into pixels using supplied intrinsics.

Exercise brief·Intermediate·3 min read

Opening the Python editor…

Requirements and learning goals

Before you start

  • Basic coordinate geometry
  • Python 3; no camera required

You will be able to

  • Distinguish intrinsics from extrinsics
  • Check projection numerically
  • Identify what a real calibration must measure

The browser exercise above works without extra setup. The project brief below assumes the listed prerequisites and gives you a task and checks to perform. Need a guided first project?

Camera calibration connects image pixels to geometry. describe the lens and image projection; extrinsics describe the camera position and orientation. You need both to turn a detection into a location in your room. Here you will check a simple projection before trusting a camera-derived robot target.

Check the actual camera mode before applying intrinsics. A different resolution or crop can invalidate a calibration that worked in the twin.

Two calibrations, two jobs

Lens distortion adds another correction. Store intrinsics, extrinsics, and distortion parameters with the image resolution and a calibration ID.

For an ideal pinhole camera, a point (X, Y, Z) in camera coordinates projects to u = fx*X/Z + cx and v = fy*Y/Z + cy. This lesson uses optical axes: right, down, forward. cameras use a different viewing convention, so convert explicitly at that boundary.

Try a projection check

Save this as projection.py and run python3 projection.py. These supplied values describe an ideal camera. Passing the assertions checks the projection formula; it does not calibrate a physical camera.

fx = fy = 600.0
cx, cy = 320.0, 240.0
 
def project(x, y, z):
    if z <= 0:
        raise ValueError("point is behind camera")
    return fx*x/z + cx, fy*y/z + cy
 
assert project(0, 0, 2) == (320, 240)
assert project(1, 0, 2) == (620, 240)
print("Projection checks passed")

The center ray projects to the principal point. Moving right in camera coordinates moves right in the image.

Checkpoint 1 of 2

Using the supplied values, what does project(0, 1, 4) return?

Commit to an answer. Every choice explains itself.

Optional extension: measure a real calibration

Collect calibration-board views covering the image, estimate lens parameters, and check held-out reprojection error. Then estimate the camera's pose against surveyed world points. Use OpenCV's calibration functions, including distortion correction. This requires additional images and surveyed measurements; the next ray exercise supplies a synthetic camera pose so you can continue without hardware.

Check and extend

Validate world-position estimates at several distances and image corners. A small image reprojection error alone does not prove accurate world .

Checkpoint 2 of 2

A calibration estimates the focal length as 540 pixels, but the true value is 600. The camera is 2 meters above the floor with image center 320. How does the floor x error at pixel 520 compare with the error at pixel 320?

Commit to an answer. Every choice explains itself.

Common snag: changing resolution, cropping, focus, or camera mounting while retaining old calibration. Map detections back to calibrated image coordinates, or update intrinsics consistently. Optional extension: move the camera slightly and measure the resulting world-position error before recalibrating.

Can you do each of these?

  • Distinguish intrinsics from extrinsics
  • Check projection numerically
  • Identify what a real calibration must measure

0 of 2 checkpoints solved. Try checkpoint 1

Previous: Build a twin with a measurement contract
All lessons in this topic
  1. 1. Build a twin with a measurement contract
  2. 2. Understand calibration and check a camera projection
  3. 3. Turn a camera pixel into a world ray
  4. 4. Locate a detected object in the twin
  5. 5. Validate a robot goal with a dry-run adapter

Ask Wendy

Answers about Wendy and WendyOS

What would you like to know?

Ask about devices, development, and deployment.

Check linked docs for technical details.