Camera calibration & rectification
These tools correct problems introduced by the camera and lens — distortion and misalignment — before the PIV analysis runs. They're different from Spatial calibration (px → mm), which just converts pixel units to physical units after the fact.
| Tool | Corrects |
|---|---|
| Camera calibration (undistortion) | Lens distortion (barrel/pincushion effects) using a photographed marker board. |
| Image rectification | Misalignment between the camera's image plane and your target coordinate system / laser sheet. |
Setting up a marker board
Both calibration and rectification are done by photographing a printed ChArUco board (a checkerboard combined with ArUco markers). Configure it via Image settings → Camera calibration → Setup / define / generate marker board:
| Field | Meaning |
|---|---|
| Board type | Currently only ChArUco DICT_4X4_1000. |
| Origin color | Color of the top-left checker (Black/White) — must match your printed board. |
| Rows / Columns | Checkerboard dimensions (default 14 × 21; with the default 12 mm checkers, the board fits A4 landscape). |
| Checker size / Marker size | Physical size of the checkers and the ArUco markers printed on them. |
Click Guess parameters to have PIVlab estimate these from a photo, or Generate Charuco board to produce a printable board matching your settings. Save it as TIFF (300 dpi) or as print-ready PDF. In the PDF, all checkers and markers have their exact size in mm. Print either file at 100 % scaling.
The PDF also suits printing on transparent material, e.g. an acrylic plate that is seen from both sides in stereo PIV.
What to tell the print shop reference
The PDF is in CMYK (black = 100 % K) with 5 mm bleed. White is the spot colour weiss (overprint) in the top layer weiss; it does not overlap the other colours. The suggested file name contains the board size, e.g. …_300x290mm_plus_5mm_bleed.pdf.
A generated board carries a QR code in place of the central 2 × 2 checkers that holds all of these parameters. It is also read when the board is seen from behind. With the Calibration overlay of the image acquisition, PIVlab reads that code from the live image and fills the fields above by itself, so the board's dimensions and scale do not have to be entered by hand.
The left and bottom margins show the axes of the results (default axes of the calibration, also for stereo PIV), as seen from camera 1 with the board upright in the image: x points to the right, y up and z out of the board, toward the camera (⊙). The two ticks and the 0 mark the row and the column line through the inner checker corner at the bottom left. The board only sets the directions: the origin of the results is the bottom left of the image. Seen from behind, the board and its axes appear mirrored.
Choosing the checker size
How large the checkers should be, and the limits tips
Design the board for the camera image, not for the paper: the board should fill the camera image, and one checker should cover about 60–130 pixels in the image. More and smaller checkers do not make the calibration more accurate — in tests with synthetic images of a real camera, a board with about 120 corners calibrated as well as one with 1700. Small checkers only make the marker detection fail.
where c is the checker size [mm], W the width of the field of view [mm] and N the image width [px].
Example: a camera with 1936 px image width looking at a 520 mm wide field of view has 0.27 mm/px, so the checkers should be about 16–35 mm, i.e. a board with about 15–30 columns.
| Checker in the image | Detection |
|---|---|
| below about 20 px | Markers are not detected. |
| 20–60 px | Works with sharp images. With blur or image noise the marker detection becomes unreliable. |
| 60–130 px | Recommended. Reliable also with slightly blurred or noisy images. |
| above about 200 px | Still accurate, but each image has only few corners. Keep at least about 6 × 9 checkers on the board. |
- A board can have at most 2000 checkers (rows × columns); the generator refuses larger boards. A board that fills the image therefore cannot have arbitrarily small checkers. On cameras with more than about 30 megapixels this forces checkers larger than 130 px, which is fine.
- The board may extend beyond the image edges: each corner is identified by its neighbouring markers, so partly visible boards are used.
Camera calibration (lens undistortion)
Open via Image settings → Camera calibration → Camera calibration (undistortion).
- Click Load target images and select several photos of your marker board from different angles/positions.
- If your camera uses a Scheimpflug adapter (tilted sensor), enable Scheimpflug, tilt (deg) first and enter the tilt angle of the adapter (tilt about the vertical image axis, without sign). With 0, PIVlab estimates the tilt from the target images, which is usually inaccurate.
- Click Estimate cam parameters to detect the markers and compute the lens model.
- Save parameters to reuse this calibration later, or Load parameters to bring back a previous one.
Checking the result
| Button | Shows |
|---|---|
| Show reprojection errors | How well the model fits — should be below 1 pixel for a valid calibration. |
| Show camera positions | Where the camera was relative to the board in each calibration image. |
| Show lens distortion | A visualization of the detected lens distortion. |
Applying it
Set Output image size — undistorting an image curves its straight edges, so you choose how to handle the resulting black borders: Cut away black borders, keep the Same size as input image, or Include black borders in full. Then tick Enable camera calibration to actually apply the undistortion to your images.
Image rectification
Open via Image settings → Camera calibration → Image rectification / alignment (you need images loaded first). Rectification aligns the image with your target coordinate system by photographing the marker board positioned inside the laser sheet, aligned with the plane you actually want to measure.
- Click Load target image and select that photo.
- Use Show detected markers, Show rectified board and Show camera position to check the detection before committing.
- Set Upscaling (1× or 2×) — upscaling reduces artifacts from image interpolation during rectification, at the cost of slower analysis.
- Tick Enable image rectification to apply it.
pivlab.preprocess(imgs, Camera="my_session.mat") — see
Command line (API).