Python implementations of selected projects and examples from slambook.
This repository contains a teaching-first Python package for the core slambook
concepts. The legacy root scripts remain in place while the migrated importable
modules and examples live under slam/ and examples/.
If you are using this repo as a Python-first companion to slambook, start with the core environment and the chapters that need no large datasets:
uv sync --extra core --extra test --frozen
uv run python -m pytest
uv run python examples/ch3_geometry/transforms.py
uv run python examples/ch4_lie/exp_log.py
uv run python examples/ch6_optimization/curve_fitting.py
uv run python examples/ch10_bundle_adjustment/scipy_bal.py \
--bal examples/ch10_bundle_adjustment/tiny_bal.txt \
--fix-cameras
uv run python examples/ch11_pose_graph/optimize_pose_graph.py \
--g2o examples/ch11_pose_graph/tiny_pose_graph.g2oThen add slambook sample images under data/slambook/ and continue with the
camera, visual odometry, loop closure, and dense mapping examples listed below.
Large datasets are intentionally not committed; see docs/datasets.md for the
expected layouts.
For mainland China, sync the same environment with a uv mirror:
UV_DEFAULT_INDEX=https://pypi.tuna.tsinghua.edu.cn/simple uv sync --extra core --extra test --frozen
uv run python -m pytestThis repo documents the uv workflow only. Sync once for the dependency group
you need, then use uv run ... for normal commands.
Core educational dependencies:
uv sync --extra core --frozenCore dependencies plus tests:
uv sync --extra core --extra test --frozen
uv run python -m pytestIn mainland China, a PyPI mirror can be used with the checked-in lockfile:
UV_DEFAULT_INDEX=https://pypi.tuna.tsinghua.edu.cn/simple uv sync --extra core --extra test --frozen
uv run python -m pytestOptional dependency groups are defined for 3D/evaluation tools, modern matchers, and reference backends:
uv sync --extra 3d --frozen
uv sync --extra modern --frozen
uv sync --extra backend --frozen
uv sync --all-extras --frozenImporting slam does not require optional modern backends.
See docs/status.md for the chapter-by-chapter status table.
See docs/datasets.md for expected local dataset layouts.
See docs/validation.md for the latest local validation notes.
See docs/notes.md for organized notes from the legacy scripts.
See CONTEXT.md for the migration glossary and notation conventions.
Representative migrated examples:
uv run python examples/ch7_feature_vo/pose_estimation_2d2d.py \
--image0 data/slambook/ch7/1.png \
--image1 data/slambook/ch7/2.png \
--matcher orb
uv run python examples/ch10_bundle_adjustment/scipy_bal.py \
--bal examples/ch10_bundle_adjustment/tiny_bal.txt \
--fix-cameras
uv run python examples/ch13_dense_mapping/rgbd_fusion.py \
--color-dir data/slambook/ch13/color \
--depth-dir data/slambook/ch13/depth \
--pose-file data/slambook/ch13/pose.txt \
--intrinsics FX FY CX CY \
--output outputs/ch13_cloud.plyValidation and benchmark helpers live under examples/reference/:
uv run python examples/reference/validate_upstream_samples.py \
--upstream-root data/slambook-upstream \
--work-dir /tmp/slambook-python-validation
uv run python examples/reference/benchmark_report.py \
pose-graph \
--g2o examples/ch11_pose_graph/tiny_pose_graph.g2o \
--solve \
--output /tmp/slambook-python-validation/pose_graph_report.jsonOptional backend integration checks are kept outside the default pytest path:
uv sync --all-extras --frozen
uv run python -m pytest tests_optionalWith a uv mirror:
UV_DEFAULT_INDEX=https://pypi.tuna.tsinghua.edu.cn/simple uv sync --all-extras --frozen
uv run python -m pytest tests_optionalOn macOS, FAISS and PyCOLMAP can load duplicate OpenMP runtimes in the same pytest process. If Python aborts while importing optional native backends, run the optional suite with:
KMP_DUPLICATE_LIB_OK=TRUE uv run python -m pytest tests_optionalThe original root-level scripts are kept under legacy/ as the historical
baseline during the migration:
legacy/pose_estimation_2d2d.pylegacy/pose_estimation_3d2d.pylegacy/flann_based_matcher.pylegacy/ransac_test.pylegacy/simStereoCamera.pylegacy/testRefine.pylegacy/utils.py
New code should use importable modules under slam/ and runnable examples under
examples/.
