Git Product home page Git Product logo

procam-calibration's Introduction

procam-calibration

This repository provides python scripts to calibrate projector-camera system using a chessboard and structured light (the gray codes).

Calibration script command:

python ./calibrate.py 720 1280 8 11 24 1 -black_thr 40 -white_thr 5

Requirement

  • Python
    • Python 3 is recommended
  • OpenCV
    • python -m pip install opencv-python opencv-contrib-python
  • Printed chessboard
    • You can find PDF here

How to use

Step 1 : Generate gray code patterns

Open your terminal and type the following command.

python gen_graycode_imgs.py <projector_pixel_height> <projector_pixel_width> [-graycode_step <graycode_step(default=1)>]

# example
python gen_graycode_imgs.py 768 1024 -graycode_step 1

Generated images will be stored in ./graycode_pattern/.

graycode_step is an option to specify the pixel size of bits in the gray code images. If you get moire pattern in the captured images in the next step, increase this variable.

Step 2 : Project and capture the gray code patterns

Set up your system and place a chessboard in front of the projector and camera. Then, project the gray code patterns generated in the previous step from the projector to it and capture it from the camera.

Although minimum required shot is one, it is recommended to capture more than 5 times with different attitudes of the chessboard to improve the calibration accuracy.

Captured images must be saved as ./capture_*/graycode_*.(png/jpg).

Step 3 : Calibrate projector & camera parameters

After saving the captured images, run the following command.

python calibrate.py <projector_pixel_height> <projector_pixel_width> <num_chess_corners_vert> <num_chess_corners_hori> <chess_block_size> <graycode_step> [-black_thr <black_thr(default=40)>] [-white_thr <white_thr(default=5)>][-camera <camera_parameter_json>]

# example (you can test this command in the sample_data directory)
python ../calibrate.py 768 1024 9 7 75 1 -black_thr 40 -white_thr 5

chess_block_size means the length (mm cm m) of a block on the chessboard. The translation vectors will be calculated with the units of length used here.

black_threashold is a threashold to determine whether a camera pixel captures projected area or not. white_threashold is a threashold to specify the robustness of gray code decoding. To avoid decoding errors, increase these variables.

camera_paramter_json is a json file, in which internal camera paramters (projection matrix P, camera distortion, and image size) are written. By indicating this option, the intrinsic camera parameters will be fixed when compute the initial solution of the camera attitudes. See "camera_config.json" as an example.

Calibration result will be displayed on your terminal and saved in ./calibration_result.xml (with cv::FileStorage format).

Additional Resource

This software calculates local homographies at around chessboard corners to estimate corresponding projector pixels with subpixel accuracy. This algorithm is based on the following paper.

MORENO, Daniel; TAUBIN, Gabriel. Simple, accurate, and robust projector-camera calibration. In: 3D Imaging, Modeling, Processing, Visualization and Transmission (3DIMPVT), 2012 Second International Conference on. IEEE, 2012. p. 464-471.

procam-calibration's People

Contributors

kamino410 avatar marc-wittwer avatar takmin avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.