Markdown Converter
Agent skill for markdown-converter
**projector-calib** is a Rust-based interactive calibration tool for measuring projector intrinsic parameters and lens distortion coefficients. The tool uses an **inverse distortion workflow** where users adjust parameters representing physical lens distortion, and the program computes the exact mat
Sign in to like and favorite skills
projector-calib is a Rust-based interactive calibration tool for measuring projector intrinsic parameters and lens distortion coefficients. The tool uses an inverse distortion workflow where users adjust parameters representing physical lens distortion, and the program computes the exact mathematical inverse using OpenCV's iterative Newton-Raphson solver.
Target Resolution: 1920x1080 (hardcoded)
License: MIT (Copyright 2025 Lin Hsiang-Jui)
Repository: https://github.com/NEWSLabNTU/projector-calib
The tool applies inverse distortion (undistortion) as pre-warp for projector calibration:
opencv::calib3d::init_undistort_rectify_mapWhy inverse? The Brown-Conrady distortion model is NOT self-inverse. Forward distortion approximations (using
-k1 for lens with +k1) fail for large distortions. OpenCV's init_undistort_rectify_map uses iterative Newton-Raphson to compute the exact inverse.
The tool performs joint calibration of camera matrix and distortion coefficients:
s) and translation (tx, ty) are user-adjustablefx = fy = s × width, cx = width/2 + tx, cy = height/2 + typhysical_size_meters) is optional and set via config filesrc/ main.rs - Main loop, key handling, tracing initialization config.rs - CalibrationParams struct, JSON serialization display.rs - Display management, help overlay, hints distortion.rs - Inverse distortion using OpenCV (ImageWarper) pattern.rs - Pattern generation (chessboard, etc.) docs/ math.org - Mathematical formulation system_design.org - Architecture and workflow roadmap.org - Development phases and testing Makefile - Build targets (build, run, test, check, format, lint, clean) Cargo.toml - Dependencies and build profile README.md - User documentation LICENSE - MIT License
Uses OpenCV's
init_undistort_rectify_map for exact inverse computation:
calib3d::init_undistort_rectify_map( &camera_matrix, // [fx, 0, cx; 0, fy, cy; 0, 0, 1] &dist_coeffs, // [k1, k2, p1, p2, k3] &no_array(), // R (identity) &no_array(), // New camera matrix (same as input) Size::new(width, height), CV_32FC1, &mut map_x, &mut map_y, )?;
Critical: User provides LENS distortion parameters. OpenCV computes the inverse for pre-warping.
Auto-created on first run. Contains:
scale, tx, ty, k1, k2, k3, p1, p2fx, fy, cx, cyphysical_size_metersExternal edits are detected via file modification time. User is prompted to press
L to reload.
+/-, arrow keysW/S, E/D, R/FT/G, Y/H[/] (adjust step size),/. (pattern cell size)TAB, Shift+TABI (toggle help), L (reload config), 0 (reset), SPACE (save), ESC (quit)Uses
tracing crate for structured logging:
info!() for user-facing messagesdebug!() for detailed debugging (step changes, pattern switches)error!() for errorsDefault level:
info. Override with RUST_LOG=debug or RUST_LOG=trace.
Uses Rust 2024 features:
if let Ok(x) = foo() && let Some(y) = bar() { ... }Must pass
make lint without warnings:
cargo +nightly fmt --check (formatting)cargo clippy --profile release-with-debug -- -D warnings (clippy)Use
#[allow(dead_code)] only for intentionally unused items kept for future use.
Uses
release-with-debug profile (defined in Cargo.toml):
make build # Build with release-with-debug profile make run # Build and run in fullscreen
make test # Run tests make check # Run cargo check make format # Format code with rustfmt make lint # Check formatting and run clippy make clean # Clean build artifacts
Adding a new keyboard command:
process_key() in src/main.rssrc/display.rsdocs/system_design.orgModifying distortion computation:
compute_distortion_maps() in src/distortion.rsdocs/math.org with mathematical changesdocs/roadmap.orgChanging patterns:
PatternGenerator in src/pattern.rsPatternType enum variantsrc/main.rsAlways update:
docs/system_design.org for architectural changesdocs/roadmap.org for completed featuresDocumentation in
docs/ uses Emacs Org-mode (.org files):
* Level 1, ** Level 2, etc.#+BEGIN_SRC rust ... #+END_SRC- for unordered, 1. for ordered*text*, Italic: /text/, Code: ~text~Never modify without explicit user request:
LICENSE - MIT License, Copyright Lin Hsiang-JuiCargo.toml edition field (must stay "2024")Always update together:
src/main.rs key bindings + src/display.rs help text + README.md controlssrc/distortion.rs implementation + docs/math.org formulationcalib3d is required for init_undistort_rectify_mapSystemTime, handle errors gracefullycargo fmt (formatting)docs/math.orgdocs/roadmap.orgmake lint? → Test before committingThis tool prioritizes: