4.3 KiB
4.3 KiB
AGENTS.md
Guide for coding agents working in this repository.
Project Overview
- Domain: Computer vision experiments with ArUco / ChArUco and camera calibration
- Language: Python
- Python version: 3.13+ (see
.python-version,pyproject.toml) - Env/deps manager:
uv - Test runner:
pytest - Lint/format:
ruff - Packaging mode: workspace scripts (
[tool.uv] package = false)
High-Signal Files
find_aruco_points.py: live marker detection + frame overlaysfind_extrinsic_object.py: pose estimation with known object pointscali.py: charuco calibration and parquet outputcapture.py: webcam frame capture helperrun_capture.py: multi-port gstreamer recorder CLI (click)scripts/uv_to_object_points.py: UV -> 3D conversion scripttest_cam_props.py: camera property probe test/script- Shell helpers:
gen.sh,cvt_all_pdfs.sh,dump_and_play.sh
Setup
uv sync
Creates .venv and installs dependencies from pyproject.toml.
Build / Lint / Test Commands
No compile step. “Build” usually means running generation/util scripts.
Lint
uv run ruff check .
uv run ruff check . --fix
Format
uv run ruff format .
Tests
Full suite:
uv run pytest -q
Single test file (important):
uv run pytest test_cam_props.py -q
Single test function:
uv run pytest test_cam_props.py::test_props -q
Keyword filter:
uv run pytest -k "props" -q
Script sanity checks
uv run python -m py_compile *.py scripts/*.py
uv run python run_capture.py --help
uv run python scripts/uv_to_object_points.py --help
Runtime/Tooling Notes
- Prefer
uv run python <script>.pyfor all local execution. scripts/uv_to_object_points.pyalso supports script-mode execution directly.- Shell scripts require system tools:
gen.sh: expectsMarkerPrinter.pyfrom OpenCV contrib generator contextcvt_all_pdfs.sh: needs ImageMagick (magick)dump_and_play.sh: needsgst-launch-1.0
Code Style (Observed Conventions)
Follow existing style in touched files; keep edits narrow.
Imports
- Keep imports at top of module.
- Common pattern: stdlib + third-party; ordering is not perfectly strict.
- Do not do broad import reordering unless asked.
Formatting
- 4-space indentation
- Predominantly double quotes
- Script-oriented functions; avoid unnecessary abstractions
Types
- Type hints are common in core numeric/geometry scripts.
- Existing usage includes:
- builtin generics (
list[int],tuple[float, float]) TypedDicttyping.castnumpy.typingand jaxtyping aliases
- builtin generics (
- Preserve/improve types when touching typed code.
Naming
snake_case: functions, variablesPascalCase: classesUPPER_SNAKE_CASE: constants/config
Error Handling / Logging
loguruis the preferred logger.- Use
logger.warning(...)for recoverable detection/runtime issues. - Raise explicit exceptions for invalid inputs in utility code.
CLI / Entrypoints
clickis used for CLI scripts.- Use
if __name__ == "__main__":entrypoints. - Keep side effects in
main()when possible.
CV / Numeric Practices
- Be explicit about array shapes where relevant.
- Normalize/reshape OpenCV outputs before downstream operations.
- Keep calibration/dictionary constants near top-level config.
Testing Guidance
- Repo is hardware-heavy; avoid adding camera-dependent tests unless requested.
- Prefer extracting pure logic and testing that logic.
- Use pytest naming:
test_*.py,test_*.
Dependency Management (uv)
uv add <package>
uv add --dev <package>
uv remove <package>
uv sync
Prefer checking in both pyproject.toml and uv.lock for reproducibility.
Cursor / Copilot Rules Check
.cursor/rules/: not present.cursorrules: not present.github/copilot-instructions.md: not present
No repository-specific Cursor/Copilot rule files currently exist.
Agent Workflow Checklist
Before coding:
- Read this file and target scripts.
- Run
uv syncif env may be stale. - Check whether task depends on camera/hardware.
After coding:
- Run focused checks first.
- Run
uv run ruff check .. - Run
uv run pytest -q(or explain hardware-related skips). - Keep edits minimal and task-scoped.