Skip to main content

A tool to generate chessboard patterns for OpenCV camera calibration

Project description

OpenCV Chessboard Generator

PyPI version Python versions License: MIT

A Python tool to generate high-quality chessboard patterns for OpenCV camera calibration.

Features

  • 🎯 Customizable grid dimensions (rows × columns)
  • 📏 Configurable square size in centimeters
  • 🖨️ Print-ready output with exact DPI settings
  • 👁️ Preview before saving
  • 📦 Easy to use Python API and CLI

Installation

Install from PyPI:

pip install opencv-chessboard-generator

Usage

Command Line Interface

After installation, run the interactive CLI:

chessboard-generator

Follow the prompts to specify:

  • Number of inner corner columns (e.g., 6)
  • Number of inner corner rows (e.g., 9)
  • Square size in centimeters (default: 3.0)
  • DPI resolution for printing (default: 300)

Python API

from chessboard_generator import ChessboardGenerator

# Create a chessboard with 6x9 inner corners, 3cm squares, 300 DPI
generator = ChessboardGenerator(rows=9, cols=6, square_size_cm=3.0, dpi=300)

# Save to file
generator.save("my_chessboard.png")

# Or preview before saving
generator.preview()

Recommended Settings for A3 Paper

For A3 paper (29.7 × 42 cm), we recommend:

  • 13×8 inner corners (landscape orientation)
  • Square size: 3.0 cm
  • DPI: 300
generator = ChessboardGenerator(rows=8, cols=13, square_size_cm=3.0, dpi=300)
generator.save("chessboard_a3.png")

Printing Instructions

⚠️ IMPORTANT: For accurate camera calibration, print settings matter!

  1. Print at EXACTLY the specified DPI (no scaling)
  2. Disable "Fit to page" in print settings
  3. Use 100% scaling
  4. Mount the printed chessboard on a flat, rigid surface
  5. Measure the printed squares to verify they match your specified size

OpenCV Integration

After generating your chessboard, use it with OpenCV:

import cv2

# For a 6×9 inner corners chessboard
pattern_size = (6, 9)
square_size = 3.0  # cm

# Find chessboard corners in your calibration images
ret, corners = cv2.findChessboardCorners(image, pattern_size)

Requirements

  • Python >= 3.7
  • OpenCV >= 4.5.0
  • NumPy >= 1.19.0

License

MIT License

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Development

For development setup and automated releases with GitHub Actions, see:

Author

Batuhan ÖKMEN (batuhanokmen@gmail.com)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

opencv_chessboard_generator-1.0.7.tar.gz (6.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

opencv_chessboard_generator-1.0.7-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

File details

Details for the file opencv_chessboard_generator-1.0.7.tar.gz.

File metadata

File hashes

Hashes for opencv_chessboard_generator-1.0.7.tar.gz
Algorithm Hash digest
SHA256 78d201ac7c976bac7e2c26127a431481f648738ffa671af6b673f59456611b5e
MD5 a3098392a787731ee386a7779cfbf0c4
BLAKE2b-256 73aa471117d4acdacfd251391e6796d23f7dad333c45daf400d5eb0792a2149c

See more details on using hashes here.

File details

Details for the file opencv_chessboard_generator-1.0.7-py3-none-any.whl.

File metadata

File hashes

Hashes for opencv_chessboard_generator-1.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 d9ce3e013246e86b2b076669b012364367e68528ca4cd66b82116601b3fe6da5
MD5 ee8c1e5a7fabccdc58a85cfff1e6d2cd
BLAKE2b-256 1de6c04bebe950ffee6abfd161ff173aa788dd2cbe5a49631cf35b82bac6d07b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page