This guide covers camera calibration in PyPTV, from basic concepts to advanced techniques.
Camera calibration is the process of determining the intrinsic and extrinsic parameters of your camera system. This is essential for accurate 3D particle tracking.
PyPTV uses a modern conda environment (environment.yml
) and separates tests into headless (tests/
) and GUI (tests_gui/
) categories. See the README for details.
Before starting calibration:
Place calibration images in your cal/
directory:
your_experiment/
├── parameters_Run1.yaml
├── cal/
│ ├── cam1.tif
│ ├── cam2.tif
│ ├── cam3.tif
│ ├── cam4.tif
│ └── target_coordinates.txt
└── img/
└── ...
In your YAML file, set up the calibration section:
num_cams: 4
cal_ori:
chfield: 0
fixp_name: cal/target_coordinates.txt
img_cal_name:
- cal/cam1.tif
- cal/cam2.tif
- cal/cam3.tif
- cal/cam4.tif
img_ori: [] # Will be filled during calibration
pair_flag: false
tiff_flag: true
cal_splitter: false
Create a target coordinate file (cal/target_coordinates.txt
) with known 3D points:
# point_id X Y Z
1 -25.0 -25.0 0.0
2 25.0 -25.0 0.0
3 25.0 25.0 0.0
4 -25.0 25.0 0.0
python -m pyptv
.ori
filesFor improved accuracy with large measurement volumes:
multi_planes:
n_planes: 3
plane_name:
- img/calib_a_cam
- img/calib_b_cam
- img/calib_c_cam
For splitter-based stereo systems:
cal_ori:
cal_splitter: true
# Additional splitter-specific parameters
You can specify manual orientation points in the YAML:
man_ori:
nr: [3, 5, 72, 73, 3, 5, 72, 73, 1, 5, 71, 73, 1, 5, 71, 73]
man_ori_coordinates:
camera_0:
point_1: {x: 1009.0, y: 608.0}
point_2: {x: 979.0, y: 335.0}
# ... more points
camera_1:
point_1: {x: 1002.0, y: 609.0}
# ... more points
Good calibration typically shows:
Check calibration quality by:
Problem: Points not detected automatically Solution:
detect_plate
sectionProblem: High calibration residuals Solution:
Problem: Inconsistent results between cameras Solution:
Fine-tune detection in the detect_plate
section:
detect_plate:
gvth_1: 40 # Threshold for camera 1
gvth_2: 40 # Threshold for camera 2
gvth_3: 40 # Threshold for camera 3
gvth_4: 40 # Threshold for camera 4
min_npix: 25 # Minimum pixel count
max_npix: 400 # Maximum pixel count
size_cross: 3 # Cross correlation size
sum_grey: 100 # Minimum sum of grey values
tol_dis: 500 # Distance tolerance
Successful calibration generates:
cal/
├── cam1.tif.ori # Camera 1 calibration parameters
├── cam2.tif.ori # Camera 2 calibration parameters
├── cam3.tif.ori # Camera 3 calibration parameters
├── cam4.tif.ori # Camera 4 calibration parameters
├── cam1.tif.addpar # Additional parameters (distortion, etc.)
├── cam2.tif.addpar
├── cam3.tif.addpar
└── cam4.tif.addpar
These files contain the intrinsic and extrinsic camera parameters needed for 3D reconstruction.