Calibrate camera's intrinsic/extristric, and build stereo depth camera with OpenCV python.
- High-level API that simplifies calibration steps
- Object-oriented Pythonic code style
- Rich visualization to verify the calibration effect. e.g. stereo-rectify-vis, reproject-depth-vis
- Very easy to install and run the example with example images
- Mature stereo module for correctly converting disparity to depth map that aligned with the left camera
- Provide camera internal and external parameters standard, which can be exported as
.yaml
- Decoupling the feature extraction and calibration process, support both checkboard and markers(
cv2.aruco
) - Support occluded markers like ArUco and ChArUco, and multiple calibration boards in one image
- Draw various calibration board images
- Automatically ignore non-compliant images or markers
- Convert to NeRF format json for 3D reconstruction
- LiDAR-camera extrinsic calibration without chessboard, see lidar2cam_by_PnP example
pip3 install calibrating
Example images are captured by paired_stereo_and_depth_cams:
pip3 install calibrating
# Prepare example data(100MB): checkboard images of paired stereo and depth cameras
git clone https://github.com/yl-data/calibrating_example_data
# Prepare example code
git clone https://github.com/DIYer22/calibrating
# Run checkboard example
python3 calibrating/example/checkboard_example.py
Finally, your browser will open stereo-rectify-vis, reproject-depth-vis
Detailed example code with comments: example/checkboard_example.py
Or Chinese Version: example/checkboard_example_cn.py (中文注释)
Run stereo example:
python3 calibrating/calibrating/stereo_camera.py
After a while, your browser will open:
- stereo-rectify-vis
- StereoSGBM-depth-vis: Which shows
undistort_img1
,unrectify_depth
. The example disparity is computed bycv2.StereoSGBM
.
Another stereo depth example:
python3 calibrating/example/test_depth_accuracy.py
your browser will pop up a visual web page like this
Mermaid flowchart of calbrating.Stereo.get_depth(img1, img2)
flowchart
subgraph "Stereo.get_depth(img1, img2)"
input(Input: \nimg1\nimg2)--> undistort
undistort-->rectify
undistort --> stereo_re
subgraph StereoMatching
end
rectify --> StereoMatching
StereoMatching --disparity--> disp_to_depth
disp_to_depth --depth--> unrectify
unrectify --> stereo_re("Output: \n undistort_img1 \n unrectify_depth")
end
Convert to NeRF format json for 3D reconstruction.
Usage:
# Convert Cam object's intrinsic/extristric to NeRF fromat json
# Note:
# - When collecting images for reconstruction
# - should fix the calibration board and object, and move the camera
cam.convert_to_nerf_json("transforms.json")
Example of converting ChArUco images to NeRF's transforms.json:
python calibrating/reconstruction_with_board.py
Reconstruction effect of instat-ngp using ChArUco boards
Multiple calibration boards in one image, run example code:
python calibrating/multi_boards.py
visualization example of multiple boards