Calibrate a virtual camera
A virtual camera, whose true K differs from its spec sheet as real ones do, photographs a flat checkerboard. Zhang’s method fits one homography per view, solves for K, and refines everything by least squares. Change the photos and see what makes a calibration right, and what only makes it look right.
Photos of the board
Board: 8 × 6 inner corners, 108 mm squares, 1.2 to 3 m away. The virtual lens has no distortion.
Where the corners fall in the 1616 × 1240 image, one color per view. Good calibrations cover the whole image, corners included.
Try this
- With 12 views tilted up to 30°, K comes out within a pixel or two of the truth, including the principal point the spec sheet got wrong.
- Drag the tilt down to 5°. The reprojection error stays under half a pixel, but f is now far off. A small error is needed, not enough.
- Set the tilt to 0. There is no answer at all: flat-on views give the same two equations again and again.
- Try 3 views with 2 px of corner noise, then 30 views. More good views make the answer steadier; the refinement step helps most when the closed form is already close.
Notebook
Work with the same script in cells, like Jupyter, right here in the browser. Edit any cell and run it. Nothing is saved: Reset brings a cell back, and Download .ipynb keeps your edited version for VS Code or Jupyter.
The Python script: calib_zhang.py
This is the script the page runs. Run it yourself with python3 calib_zhang.py.