Skip to content

Calibrate camera's intrinsic/extristric, and build stereo depth camera with OpenCV python.

Notifications You must be signed in to change notification settings

DIYer22/calibrating

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

calibrating: A Python Library for Camera Calibration

Calibrate camera's intrinsic/extristric, and build stereo depth camera with OpenCV python.

stereo-checkboard

depth

▮ Features

  • 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

▮ Install

pip3 install calibrating

▮ Run Example

Example images are captured by paired_stereo_and_depth_cams:
paired_stereo_and_depth_cams_1

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 (中文注释)

▮ Stereo

Run stereo example:

python3 calibrating/calibrating/stereo_camera.py

After a while, your browser will open:

Another stereo depth example:

python3 calibrating/example/test_depth_accuracy.py

your browser will pop up a visual web page like this
depth

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
Loading

▮ 3D reconstruction

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 

image instant ngp
Reconstruction effect of instat-ngp using ChArUco boards

▮ Multiple Boards

Multiple calibration boards in one image, run example code:

python calibrating/multi_boards.py

14~DICT_4X4_1000_start0

visualization example of multiple boards

About

Calibrate camera's intrinsic/extristric, and build stereo depth camera with OpenCV python.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages