Skip to content

ArnobTurja2002Ghosh/openCVChArUco

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

46 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🧠 openCV ChArUco

openCV ChArUco is an open-source Python project built with OpenCV that focuses on detecting and calibrating cameras using ChArUco markers — a hybrid of ArUco and chessboard markers. The goal is to make it easy for others to learn about marker-based camera calibration, pose estimation, and 3D vision techniques using real-world tools.

This project is intended both for self-learning and to help others understand and experiment with OpenCV's ChArUco tools. Contributions are welcome!


📸 Features

  • Detect ChArUco boards using OpenCV's cv2.aruco module
  • Calibrate cameras using ChArUco board detection
  • Visualize marker corners and IDs in a folder named detectedMarkersDrawn (the user can create the folder manually before running the script or the script will itself create the folder when running)
  • Save and load camera calibration parameters for reuse
  • Save the pose estimation from each scene as a json file in the CameraShaders folder
    • Before running the script the user must ensure that there is a file called camShader.json in the CameraShaders folder because this one file provides a template to the script for writing all the json files for pose estimation
    • A feature of this OpenCV project, setting it apart from other ChArUco-related projects, is that you can manufacture a viewing transformation in OpenGL using the numbers from a json file. Now this feature needs a huge explanation! For starters, please refer to this documentation.
  • Crop images
  • Undistort images
  • Convert colored images to binary images

📦 Dependencies

  • Python 3.8+
  • OpenCV 4.8.1 (opencv-contrib-python)
  • NumPy

Install with:

pip install opencv-contrib-python==4.8.1.78 numpy

🚀 Getting Started

images

  1. Create a folder called calibration_images which contains all the raw Nikon photos, with nef extension, of a 14*7 ChArUco board to be used used for camera calibration.
  2. Run calibration
python calibrate.py --calibrate images

The above command tells the script to calibrate using the images in the calibration_images folder.

colors

  1. Use the Colors directory included with this repository. It is included to give you an idea of the structure of the Colors folder. Feel free to replace the images, just be aware of the folder structure and the file format. But just for the sake of getting started, just ensure the Colors folder - nothing else to do in this step.
  2. Run calibration
python calibrate.py --calibrate colors

which tells the script to calibrate using the png images in the Colors directory.

paired

  1. Create a folder called pairedImages and refer to pairedImages1, included with this repository, to understand the structure of this folder. If you want you can just rename the pairedImages1 to pairedImages and jump to the next step - that works too. Just be aware of the naming scheme that:
  • _0.nef tells the script that you want to use the image for calibration, i.e. it is a photo of a ChArUco board
  • _1.nef tells the script that you do not want to use the image for calibration.
  1. Run calibration
python calibrate.py --calibrate paired

If the script runs successfully, you will see two folders:

  1. detectedMarkersDrawn containing images with detected markers, corners and axes drawn
  2. undistorted_images containing undistorted images

🔧 Configuration

Check calibrate.py to modify:

  • ChArUco board size (number of squares)
  • Marker size vs square size
  • ArUco dictionary (DICT_4X4_50, DICT_5X5_100, etc.). For now it is hard-coded to cv2.aruco.DICT_4X4_250.

🤝 Contributing

Contributions are welcome!

If you're interested in adding features (Refer to the Issues for bugs and prospective features in this project), improving usability, or expanding documentation, feel free to open a pull request. Keep the educational purpose in mind: code clarity and comments are appreciated.

Any question regarding this project (even if it is an ELI5 question) can be shot to arnobg2002@gmail.com via email or Arnob1 via LinkedIn.


📄 License

This project is licensed under the GNU General Public License (GPL-3.0).

That means:

  • ✅ You can use, modify, and share the code freely.
  • ✅ You must credit the original source.
  • ❌ If you distribute modified versions, they must also be open-sourced under the same license.
  • ❌ You cannot make it closed-source or proprietary.

This helps ensure that all versions of the project remain open and accessible to the community.


🙋‍♂️ Acknowledgements

This project was built with the help of the following articles, guides, and community answers:


Happy learning and posing! 🎯

About

Marker-based computer vision with OpenCV ArUco module

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages