From 816d11a5f56f96d55bc177afd76980b38c7763d5 Mon Sep 17 00:00:00 2001 From: crosstyan Date: Fri, 6 Feb 2026 17:02:42 +0800 Subject: [PATCH] Refactor code structure for improved readability and maintainability --- .python-version | 1 + .vscode/settings.json | 4 +- AGENTS.md | 180 +++ dlt.md => docs/dlt.md | 0 find_aruco_points_with_image.ipynb | 30 +- pyproject.toml | 30 + scripts/uv_to_object_points.py | 255 ++++ uv.lock | 1725 ++++++++++++++++++++++++++++ 8 files changed, 2219 insertions(+), 6 deletions(-) create mode 100644 .python-version create mode 100644 AGENTS.md rename dlt.md => docs/dlt.md (100%) create mode 100644 pyproject.toml create mode 100644 scripts/uv_to_object_points.py create mode 100644 uv.lock diff --git a/.python-version b/.python-version new file mode 100644 index 0000000..24ee5b1 --- /dev/null +++ b/.python-version @@ -0,0 +1 @@ +3.13 diff --git a/.vscode/settings.json b/.vscode/settings.json index cf1cd61..5cbad84 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,6 +1,6 @@ { "python.analysis.typeCheckingMode": "standard", "python.analysis.autoImportCompletions": true, - "python-envs.defaultEnvManager": "ms-python.python:system", + "python-envs.defaultEnvManager": "ms-python.python:uv", "python-envs.pythonProjects": [] -} \ No newline at end of file +} diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 0000000..3a2d578 --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,180 @@ +# 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 overlays +- `find_extrinsic_object.py`: pose estimation with known object points +- `cali.py`: charuco calibration and parquet output +- `capture.py`: webcam frame capture helper +- `run_capture.py`: multi-port gstreamer recorder CLI (`click`) +- `scripts/uv_to_object_points.py`: UV -> 3D conversion script +- `test_cam_props.py`: camera property probe test/script +- Shell helpers: `gen.sh`, `cvt_all_pdfs.sh`, `dump_and_play.sh` + +## Setup + +```bash +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 + +```bash +uv run ruff check . +uv run ruff check . --fix +``` + +### Format + +```bash +uv run ruff format . +``` + +### Tests + +Full suite: + +```bash +uv run pytest -q +``` + +Single test file (important): + +```bash +uv run pytest test_cam_props.py -q +``` + +Single test function: + +```bash +uv run pytest test_cam_props.py::test_props -q +``` + +Keyword filter: + +```bash +uv run pytest -k "props" -q +``` + +### Script sanity checks + +```bash +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