visloc 0.4.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- visloc-0.4.0/Cargo.toml +284 -0
- visloc-0.4.0/PKG-INFO +158 -0
- visloc-0.4.0/README.md +139 -0
- visloc-0.4.0/bindings/python/.gitignore +4 -0
- visloc-0.4.0/bindings/python/Cargo.lock +574 -0
- visloc-0.4.0/bindings/python/Cargo.toml +33 -0
- visloc-0.4.0/bindings/python/README.md +139 -0
- visloc-0.4.0/bindings/python/src/arrays.rs +108 -0
- visloc-0.4.0/bindings/python/src/camera.rs +214 -0
- visloc-0.4.0/bindings/python/src/colmap.rs +475 -0
- visloc-0.4.0/bindings/python/src/lib.rs +37 -0
- visloc-0.4.0/bindings/python/src/localization.rs +428 -0
- visloc-0.4.0/bindings/python/src/pose.rs +244 -0
- visloc-0.4.0/bindings/python/src/trajectory.rs +483 -0
- visloc-0.4.0/bindings/python/tests/conftest.py +36 -0
- visloc-0.4.0/bindings/python/tests/test_camera.py +91 -0
- visloc-0.4.0/bindings/python/tests/test_colmap.py +133 -0
- visloc-0.4.0/bindings/python/tests/test_localization.py +110 -0
- visloc-0.4.0/bindings/python/tests/test_pose.py +79 -0
- visloc-0.4.0/bindings/python/tests/test_trajectory.py +138 -0
- visloc-0.4.0/crates/core/Cargo.toml +19 -0
- visloc-0.4.0/crates/core/README.md +541 -0
- visloc-0.4.0/crates/core/src/geometry/mod.rs +11 -0
- visloc-0.4.0/crates/core/src/geometry/pose.rs +46 -0
- visloc-0.4.0/crates/core/src/geometry/projection.rs +9 -0
- visloc-0.4.0/crates/core/src/geometry/se3.rs +212 -0
- visloc-0.4.0/crates/core/src/geometry/sim3.rs +304 -0
- visloc-0.4.0/crates/core/src/geometry/so3.rs +48 -0
- visloc-0.4.0/crates/core/src/lib.rs +10 -0
- visloc-0.4.0/crates/core/src/optimizer/mod.rs +4 -0
- visloc-0.4.0/crates/core/src/types/camera.rs +1964 -0
- visloc-0.4.0/crates/core/src/types/frame.rs +58 -0
- visloc-0.4.0/crates/core/src/types/localization.rs +182 -0
- visloc-0.4.0/crates/core/src/types/map.rs +562 -0
- visloc-0.4.0/crates/core/src/types/mod.rs +15 -0
- visloc-0.4.0/crates/io/Cargo.toml +29 -0
- visloc-0.4.0/crates/io/README.md +541 -0
- visloc-0.4.0/crates/io/src/calibration.rs +190 -0
- visloc-0.4.0/crates/io/src/colmap/mod.rs +1730 -0
- visloc-0.4.0/crates/io/src/descriptors.rs +173 -0
- visloc-0.4.0/crates/io/src/euroc.rs +810 -0
- visloc-0.4.0/crates/io/src/external_deep.rs +271 -0
- visloc-0.4.0/crates/io/src/images.rs +604 -0
- visloc-0.4.0/crates/io/src/imu_csv.rs +190 -0
- visloc-0.4.0/crates/io/src/insv.rs +465 -0
- visloc-0.4.0/crates/io/src/kitti.rs +90 -0
- visloc-0.4.0/crates/io/src/kitti_imu.rs +385 -0
- visloc-0.4.0/crates/io/src/lib.rs +21 -0
- visloc-0.4.0/crates/io/src/query_features.rs +51 -0
- visloc-0.4.0/crates/io/src/sensors.rs +110 -0
- visloc-0.4.0/crates/io/src/two_view_matches.rs +101 -0
- visloc-0.4.0/crates/io/tests/calibration.rs +144 -0
- visloc-0.4.0/crates/io/tests/colmap.rs +669 -0
- visloc-0.4.0/crates/io/tests/colmap_camera_export.rs +160 -0
- visloc-0.4.0/crates/io/tests/colmap_export.rs +616 -0
- visloc-0.4.0/crates/io/tests/common_images.rs +396 -0
- visloc-0.4.0/crates/io/tests/descriptors.rs +41 -0
- visloc-0.4.0/crates/io/tests/external_deep.rs +124 -0
- visloc-0.4.0/crates/io/tests/fixtures/colmap_text/cameras.txt +4 -0
- visloc-0.4.0/crates/io/tests/fixtures/colmap_text/images.txt +7 -0
- visloc-0.4.0/crates/io/tests/fixtures/colmap_text/points3D.txt +4 -0
- visloc-0.4.0/crates/io/tests/fixtures/descriptors/landmarks.txt +3 -0
- visloc-0.4.0/crates/io/tests/fixtures/descriptors/with_unknown_landmark.txt +4 -0
- visloc-0.4.0/crates/io/tests/fixtures/query_features/query_features.txt +3 -0
- visloc-0.4.0/crates/io/tests/fixtures/two_view_matches/matches.txt +4 -0
- visloc-0.4.0/crates/io/tests/images.rs +65 -0
- visloc-0.4.0/crates/io/tests/kitti.rs +107 -0
- visloc-0.4.0/crates/io/tests/kitti_imu.rs +163 -0
- visloc-0.4.0/crates/io/tests/query_features.rs +49 -0
- visloc-0.4.0/crates/io/tests/sensors.rs +84 -0
- visloc-0.4.0/crates/io/tests/two_view_matches.rs +56 -0
- visloc-0.4.0/crates/vision/Cargo.toml +64 -0
- visloc-0.4.0/crates/vision/README.md +541 -0
- visloc-0.4.0/crates/vision/examples/match_bench.rs +77 -0
- visloc-0.4.0/crates/vision/examples/sift_vlfeat_bench.rs +75 -0
- visloc-0.4.0/crates/vision/examples/two_view_verify_bench.rs +130 -0
- visloc-0.4.0/crates/vision/src/dense_stereo.rs +356 -0
- visloc-0.4.0/crates/vision/src/distortion.rs +303 -0
- visloc-0.4.0/crates/vision/src/dpvo/correlation.rs +753 -0
- visloc-0.4.0/crates/vision/src/dpvo/mod.rs +152 -0
- visloc-0.4.0/crates/vision/src/dpvo/native_cuda_correlation.rs +3 -0
- visloc-0.4.0/crates/vision/src/dpvo/npz.rs +707 -0
- visloc-0.4.0/crates/vision/src/dpvo/onnx_session.rs +553 -0
- visloc-0.4.0/crates/vision/src/dpvo/patchify.rs +201 -0
- visloc-0.4.0/crates/vision/src/dpvo/softagg.rs +414 -0
- visloc-0.4.0/crates/vision/src/features/deep.rs +1168 -0
- visloc-0.4.0/crates/vision/src/features/global_descriptor_onnx.rs +294 -0
- visloc-0.4.0/crates/vision/src/features/lightglue_onnx.rs +470 -0
- visloc-0.4.0/crates/vision/src/features/mod.rs +554 -0
- visloc-0.4.0/crates/vision/src/features/sift.rs +4396 -0
- visloc-0.4.0/crates/vision/src/features/superpoint_onnx.rs +823 -0
- visloc-0.4.0/crates/vision/src/lib.rs +30 -0
- visloc-0.4.0/crates/vision/src/matching/gpu.rs +427 -0
- visloc-0.4.0/crates/vision/src/matching/hamming.rs +177 -0
- visloc-0.4.0/crates/vision/src/matching/ivf.rs +499 -0
- visloc-0.4.0/crates/vision/src/matching/mod.rs +627 -0
- visloc-0.4.0/crates/vision/src/matching/mutual_softmax.rs +362 -0
- visloc-0.4.0/crates/vision/src/matching/quantized.rs +245 -0
- visloc-0.4.0/crates/vision/src/optical_flow/config.rs +285 -0
- visloc-0.4.0/crates/vision/src/optical_flow/fast.rs +175 -0
- visloc-0.4.0/crates/vision/src/optical_flow/feature_bridge.rs +133 -0
- visloc-0.4.0/crates/vision/src/optical_flow/lssd.rs +219 -0
- visloc-0.4.0/crates/vision/src/optical_flow/mod.rs +23 -0
- visloc-0.4.0/crates/vision/src/optical_flow/pyramid.rs +198 -0
- visloc-0.4.0/crates/vision/src/optical_flow/tracker.rs +487 -0
- visloc-0.4.0/crates/vision/src/place_recognition/mod.rs +1046 -0
- visloc-0.4.0/crates/vision/src/pnp/generalized.rs +1148 -0
- visloc-0.4.0/crates/vision/src/pnp/gp3p.rs +1396 -0
- visloc-0.4.0/crates/vision/src/pnp/gr6p.rs +2072 -0
- visloc-0.4.0/crates/vision/src/pnp/gr6p_data.rs +977 -0
- visloc-0.4.0/crates/vision/src/pnp/mod.rs +478 -0
- visloc-0.4.0/crates/vision/src/pnp/p3p.rs +432 -0
- visloc-0.4.0/crates/vision/src/ransac/mod.rs +1147 -0
- visloc-0.4.0/crates/vision/src/stereo.rs +127 -0
- visloc-0.4.0/crates/vision/src/stereo_bootstrap.rs +771 -0
- visloc-0.4.0/crates/vision/src/stereo_vo.rs +4531 -0
- visloc-0.4.0/crates/vision/src/two_view/colmap_verification.rs +1032 -0
- visloc-0.4.0/crates/vision/src/two_view/correspondence_graph.rs +1624 -0
- visloc-0.4.0/crates/vision/src/two_view/five_point.rs +1260 -0
- visloc-0.4.0/crates/vision/src/two_view/fundamental.rs +240 -0
- visloc-0.4.0/crates/vision/src/two_view/homography.rs +547 -0
- visloc-0.4.0/crates/vision/src/two_view/mod.rs +1523 -0
- visloc-0.4.0/crates/vision/src/two_view/rescue.rs +503 -0
- visloc-0.4.0/crates/vision/src/two_view/spherical.rs +187 -0
- visloc-0.4.0/crates/vision/src/vocab_tree/hkm.rs +396 -0
- visloc-0.4.0/crates/vision/src/vocab_tree/index.rs +815 -0
- visloc-0.4.0/crates/vision/src/vocab_tree/mod.rs +56 -0
- visloc-0.4.0/crates/vision/src/vocab_tree/pair_generator.rs +241 -0
- visloc-0.4.0/crates/vision/tests/dpvo_onnx_parity.rs +744 -0
- visloc-0.4.0/crates/vision/tests/lightglue_onnx_parity.rs +202 -0
- visloc-0.4.0/pipelines/fusion/Cargo.toml +21 -0
- visloc-0.4.0/pipelines/fusion/README.md +541 -0
- visloc-0.4.0/pipelines/fusion/src/gnss_interpolation.rs +195 -0
- visloc-0.4.0/pipelines/fusion/src/lib.rs +866 -0
- visloc-0.4.0/pipelines/fusion/tests/gnss_interpolation.rs +108 -0
- visloc-0.4.0/pipelines/fusion/tests/priors.rs +525 -0
- visloc-0.4.0/pipelines/localization/Cargo.toml +21 -0
- visloc-0.4.0/pipelines/localization/README.md +541 -0
- visloc-0.4.0/pipelines/localization/src/binary_index.rs +1030 -0
- visloc-0.4.0/pipelines/localization/src/correspondence.rs +499 -0
- visloc-0.4.0/pipelines/localization/src/keyframe_retrieval.rs +308 -0
- visloc-0.4.0/pipelines/localization/src/lib.rs +1625 -0
- visloc-0.4.0/pipelines/localization/src/map_merge.rs +1006 -0
- visloc-0.4.0/pipelines/localization/src/odom_correction.rs +802 -0
- visloc-0.4.0/pipelines/localization/src/wheel_calibration.rs +1159 -0
- visloc-0.4.0/pipelines/localization/src/wheel_gyro.rs +426 -0
- visloc-0.4.0/pipelines/tracking/Cargo.toml +22 -0
- visloc-0.4.0/pipelines/tracking/README.md +541 -0
- visloc-0.4.0/pipelines/tracking/src/lib.rs +362 -0
- visloc-0.4.0/pipelines/tracking/src/motion.rs +1581 -0
- visloc-0.4.0/pipelines/tracking/src/report.rs +571 -0
- visloc-0.4.0/pipelines/tracking/src/tracker.rs +2595 -0
- visloc-0.4.0/pipelines/tracking/src/trajectory.rs +2715 -0
- visloc-0.4.0/pyproject.toml +33 -0
- visloc-0.4.0/python/visloc/__init__.py +51 -0
- visloc-0.4.0/python/visloc/_visloc.pyi +317 -0
- visloc-0.4.0/python/visloc/py.typed +0 -0
visloc-0.4.0/Cargo.toml
ADDED
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
[package]
|
|
2
|
+
name = "visloc-rs"
|
|
3
|
+
version = "0.4.0"
|
|
4
|
+
edition = "2021"
|
|
5
|
+
rust-version = "1.88"
|
|
6
|
+
license = "MIT OR Apache-2.0"
|
|
7
|
+
description = "Visual localization foundation library using SfM / visual maps."
|
|
8
|
+
readme = "README.md"
|
|
9
|
+
documentation = "https://docs.rs/visloc-rs"
|
|
10
|
+
homepage = "https://github.com/rsasaki0109/visloc-rs"
|
|
11
|
+
repository = "https://github.com/rsasaki0109/visloc-rs"
|
|
12
|
+
# Allowlist the published package: the repository also carries ~80 MB of
|
|
13
|
+
# benchmark evidence, docs media, and work logs that would push the crate
|
|
14
|
+
# far past crates.io's size limit and are useless to a dependent build.
|
|
15
|
+
include = [
|
|
16
|
+
"/src/**",
|
|
17
|
+
"/examples/**",
|
|
18
|
+
"/configs/**",
|
|
19
|
+
"/README.md",
|
|
20
|
+
"/LICENSE-APACHE",
|
|
21
|
+
"/LICENSE-MIT",
|
|
22
|
+
]
|
|
23
|
+
keywords = ["visual-localization", "sfm", "colmap", "pnp", "slam"]
|
|
24
|
+
categories = ["computer-vision", "science::robotics"]
|
|
25
|
+
|
|
26
|
+
[package.metadata.docs.rs]
|
|
27
|
+
all-features = true
|
|
28
|
+
|
|
29
|
+
[workspace]
|
|
30
|
+
members = [
|
|
31
|
+
"crates/core",
|
|
32
|
+
"crates/vision",
|
|
33
|
+
"crates/io",
|
|
34
|
+
"crates/gsplat-core",
|
|
35
|
+
"crates/gsplat-render",
|
|
36
|
+
"crates/gsplat-train",
|
|
37
|
+
"crates/sift-gpu",
|
|
38
|
+
"crates/ba-gpu",
|
|
39
|
+
"crates/mvs",
|
|
40
|
+
"crates/dpvo-cuda-runtime",
|
|
41
|
+
"crates/gsplat-cuda",
|
|
42
|
+
"pipelines/localization",
|
|
43
|
+
"pipelines/tracking",
|
|
44
|
+
"pipelines/mapping",
|
|
45
|
+
"pipelines/slam",
|
|
46
|
+
"pipelines/fusion",
|
|
47
|
+
"pipelines/basalt",
|
|
48
|
+
"pipelines/objects",
|
|
49
|
+
]
|
|
50
|
+
# Standalone crates with their own Cargo.lock: the pyo3/maturin Python
|
|
51
|
+
# bindings (an extension-module cdylib must not join `cargo test --workspace`
|
|
52
|
+
# linking or the MSRV/deny/package gates), the WebAssembly browser VIO (its
|
|
53
|
+
# wasm-bindgen/wgpu tree and a nightly threaded build), and the ROS 2 nodes
|
|
54
|
+
# (their DDS dependency tree stays out of the root lockfile).
|
|
55
|
+
exclude = ["bindings/python", "bindings/sfm-web", "bindings/splat-web", "bindings/wasm", "ros2/visloc-ros2"]
|
|
56
|
+
resolver = "2"
|
|
57
|
+
|
|
58
|
+
# Build-level speed lever for the real-time VI-SLAM push: fat LTO,
|
|
59
|
+
# single codegen unit, and no unwind tables, layered on top of the
|
|
60
|
+
# default `release` profile without changing it (other binaries/tests
|
|
61
|
+
# keep the historical release profile). Build with
|
|
62
|
+
# `cargo build --profile release-rt ...`; output lands in
|
|
63
|
+
# `target/release-rt/` instead of `target/release/`. This is a pure
|
|
64
|
+
# codegen change -- it must not alter any algorithm's output, so any use
|
|
65
|
+
# of it is verified bit-identical (VIO trajectory hash) against the
|
|
66
|
+
# `release` profile before being adopted for real measurements.
|
|
67
|
+
[profile.release-rt]
|
|
68
|
+
inherits = "release"
|
|
69
|
+
lto = "fat"
|
|
70
|
+
codegen-units = 1
|
|
71
|
+
panic = "abort"
|
|
72
|
+
|
|
73
|
+
# Debug builds and tests optimize the dependencies (nalgebra, faer, image,
|
|
74
|
+
# ...) but not the workspace crates, which keep full debug info and
|
|
75
|
+
# overflow checks. On 4 cores this halves the `visloc-slam` unit tests
|
|
76
|
+
# (293 s -> 154 s) and cuts `mono_inertial_synthetic` from 79 s to 55 s,
|
|
77
|
+
# with no slower cold build. `ros2/visloc-ros2` does the same.
|
|
78
|
+
[profile.dev.package."*"]
|
|
79
|
+
opt-level = 2
|
|
80
|
+
|
|
81
|
+
[workspace.package]
|
|
82
|
+
version = "0.4.0"
|
|
83
|
+
edition = "2021"
|
|
84
|
+
rust-version = "1.88"
|
|
85
|
+
license = "MIT OR Apache-2.0"
|
|
86
|
+
description = "Visual localization foundation library using SfM / visual maps."
|
|
87
|
+
readme = "README.md"
|
|
88
|
+
documentation = "https://docs.rs/visloc-rs"
|
|
89
|
+
homepage = "https://github.com/rsasaki0109/visloc-rs"
|
|
90
|
+
repository = "https://github.com/rsasaki0109/visloc-rs"
|
|
91
|
+
keywords = ["visual-localization", "sfm", "colmap", "pnp", "slam"]
|
|
92
|
+
categories = ["computer-vision", "science::robotics"]
|
|
93
|
+
|
|
94
|
+
[workspace.dependencies]
|
|
95
|
+
nalgebra = "0.33"
|
|
96
|
+
rand = { version = "0.8", features = ["small_rng"] }
|
|
97
|
+
rayon = "1"
|
|
98
|
+
sha2 = "0.11"
|
|
99
|
+
thiserror = "2"
|
|
100
|
+
bytemuck = { version = "1", features = ["derive"] }
|
|
101
|
+
pollster = "1"
|
|
102
|
+
wgpu = "30"
|
|
103
|
+
wide = "0.7"
|
|
104
|
+
|
|
105
|
+
[features]
|
|
106
|
+
default = []
|
|
107
|
+
image-io = ["visloc-io/image-io"]
|
|
108
|
+
# Compile-time opt-in for the Basalt timing sidecar and instrumentation.
|
|
109
|
+
# The environment variable is intentionally ignored by the canonical/default
|
|
110
|
+
# build; use `--features basalt-timing-breakdown` to enable it.
|
|
111
|
+
basalt-timing-breakdown = ["visloc-basalt/basalt-timing-breakdown"]
|
|
112
|
+
# Capacity-only LM Householder/GEMV workspace reuse is opt-in. The default
|
|
113
|
+
# keeps the historical per-factor allocation path available for parity and
|
|
114
|
+
# regression isolation; enabling this feature changes ownership only.
|
|
115
|
+
basalt-lm-workspace-reuse = ["visloc-basalt/basalt-lm-workspace-reuse"]
|
|
116
|
+
# Phase-27: pass-through to enable in-Rust SuperPoint ONNX inference
|
|
117
|
+
# in the vision crate. Combine with `image-io` for the EuRoC demo
|
|
118
|
+
# wiring (`--feature-extractor superpoint-onnx --superpoint-onnx-model
|
|
119
|
+
# <path>`). See `docs/superpoint_onnx_runtime_plan.md`.
|
|
120
|
+
onnx-inference = ["visloc-vision/onnx-inference", "visloc-slam/onnx-inference", "visloc-objects/onnx-inference", "dep:ndarray"]
|
|
121
|
+
# As above, but with the CUDA execution provider (GPU SuperPoint inference,
|
|
122
|
+
# CPU fallback). See `crates/vision/Cargo.toml` for the runtime requirements.
|
|
123
|
+
onnx-cuda = ["onnx-inference", "visloc-vision/onnx-cuda"]
|
|
124
|
+
# Adds the exact GPU descriptor matcher (`--gpu-matcher-dll`). See
|
|
125
|
+
# `crates/vision/Cargo.toml`; a missing kernel library falls back to the CPU.
|
|
126
|
+
gpu-matcher = ["visloc-vision/gpu-matcher"]
|
|
127
|
+
# wgpu SfM acceleration (SIFT extraction, batched matching, global bundle
|
|
128
|
+
# adjustment) for the SfM examples, e.g. `colmap ... --SiftExtraction.use_gpu 1`.
|
|
129
|
+
# Same toolchain boundary as the gsplat GPU crates (Rust >= 1.85), opt-in.
|
|
130
|
+
gpu = ["dep:visloc-sift-gpu", "visloc-sift-gpu/gpu", "dep:visloc-ba-gpu", "visloc-ba-gpu/gpu"]
|
|
131
|
+
# Opt-in global allocator swap (mimalloc) for allocation-heavy binaries
|
|
132
|
+
# such as the Basalt VI-SLAM demos, whose LM trial loop allocates a
|
|
133
|
+
# scratch buffer per factor per trial. Purely a runtime allocator swap;
|
|
134
|
+
# must not change any algorithm's output (verified bit-identical via VIO
|
|
135
|
+
# trajectory hash before being adopted for real measurements).
|
|
136
|
+
mimalloc-global = ["dep:mimalloc"]
|
|
137
|
+
# Best-effort OS thread priority hints (above-normal for the online demo's
|
|
138
|
+
# frontend/decode/estimator threads, below-normal for its mapper thread) so
|
|
139
|
+
# the real-time VI-SLAM demo keeps up under CPU contention from other
|
|
140
|
+
# processes on a shared machine. Purely a scheduler hint via the small
|
|
141
|
+
# `thread-priority` crate; every call ignores its `Result`, so an
|
|
142
|
+
# unsupported platform or missing OS privilege silently no-ops. Must not and
|
|
143
|
+
# does not change any algorithm's output (verified bit-identical via VIO
|
|
144
|
+
# trajectory/MargData hash before being adopted for real measurements). See
|
|
145
|
+
# `pipelines/basalt/src/rt_priority.rs`.
|
|
146
|
+
basalt-rt-priority = ["visloc-basalt/basalt-rt-priority"]
|
|
147
|
+
|
|
148
|
+
[dependencies]
|
|
149
|
+
nalgebra = { workspace = true }
|
|
150
|
+
serde_json = { version = "1", features = ["float_roundtrip"] }
|
|
151
|
+
sha2 = { workspace = true }
|
|
152
|
+
memmap2 = "0.9"
|
|
153
|
+
visloc-core = { path = "crates/core", version = "0.4.0" }
|
|
154
|
+
visloc-vision = { path = "crates/vision", version = "0.4.0" }
|
|
155
|
+
visloc-io = { path = "crates/io", version = "0.4.0" }
|
|
156
|
+
visloc-localization = { path = "pipelines/localization", version = "0.4.0" }
|
|
157
|
+
visloc-tracking = { path = "pipelines/tracking", version = "0.4.0" }
|
|
158
|
+
visloc-mapping = { path = "pipelines/mapping", version = "0.4.0" }
|
|
159
|
+
visloc-slam = { path = "pipelines/slam", version = "0.4.0" }
|
|
160
|
+
visloc-fusion = { path = "pipelines/fusion", version = "0.4.0" }
|
|
161
|
+
visloc-basalt = { path = "pipelines/basalt", version = "0.4.0" }
|
|
162
|
+
visloc-objects = { path = "pipelines/objects", version = "0.4.0" }
|
|
163
|
+
ndarray = { version = "0.17", optional = true }
|
|
164
|
+
visloc-sift-gpu = { path = "crates/sift-gpu", version = "0.4.0", optional = true }
|
|
165
|
+
visloc-ba-gpu = { path = "crates/ba-gpu", version = "0.4.0", optional = true }
|
|
166
|
+
mimalloc = { version = "0.1", optional = true }
|
|
167
|
+
|
|
168
|
+
[[example]]
|
|
169
|
+
name = "colmap"
|
|
170
|
+
path = "examples/colmap.rs"
|
|
171
|
+
required-features = ["image-io"]
|
|
172
|
+
|
|
173
|
+
[[example]]
|
|
174
|
+
name = "multi_session_place_recognition_kitti_demo"
|
|
175
|
+
path = "examples/multi_session_place_recognition_kitti_demo.rs"
|
|
176
|
+
required-features = ["image-io"]
|
|
177
|
+
|
|
178
|
+
[[example]]
|
|
179
|
+
name = "multi_session_stereo_metric_merge_kitti_demo"
|
|
180
|
+
path = "examples/multi_session_stereo_metric_merge_kitti_demo.rs"
|
|
181
|
+
required-features = ["image-io"]
|
|
182
|
+
|
|
183
|
+
[[example]]
|
|
184
|
+
name = "localize_from_common_image"
|
|
185
|
+
path = "examples/localize_from_common_image.rs"
|
|
186
|
+
required-features = ["image-io"]
|
|
187
|
+
|
|
188
|
+
[[example]]
|
|
189
|
+
name = "track_image_sequence_from_common_images"
|
|
190
|
+
path = "examples/track_image_sequence_from_common_images.rs"
|
|
191
|
+
required-features = ["image-io"]
|
|
192
|
+
|
|
193
|
+
[[example]]
|
|
194
|
+
name = "track_timestamped_image_sequence_with_gnss_prior"
|
|
195
|
+
path = "examples/track_timestamped_image_sequence_with_gnss_prior.rs"
|
|
196
|
+
required-features = ["image-io"]
|
|
197
|
+
|
|
198
|
+
[[example]]
|
|
199
|
+
name = "load_kitti_image_sequence"
|
|
200
|
+
path = "examples/load_kitti_image_sequence.rs"
|
|
201
|
+
required-features = ["image-io"]
|
|
202
|
+
|
|
203
|
+
[[example]]
|
|
204
|
+
name = "deep_localization_demo"
|
|
205
|
+
path = "examples/deep_localization_demo.rs"
|
|
206
|
+
required-features = ["image-io"]
|
|
207
|
+
|
|
208
|
+
[[example]]
|
|
209
|
+
name = "euroc_online_slam_vi_image_demo"
|
|
210
|
+
path = "examples/euroc_online_slam_vi_image_demo/main.rs"
|
|
211
|
+
required-features = ["image-io"]
|
|
212
|
+
|
|
213
|
+
[[example]]
|
|
214
|
+
name = "relocalization_7scenes_demo"
|
|
215
|
+
path = "examples/relocalization_7scenes_demo.rs"
|
|
216
|
+
required-features = ["image-io"]
|
|
217
|
+
|
|
218
|
+
[[example]]
|
|
219
|
+
name = "multi_session_lifelong_demo"
|
|
220
|
+
path = "examples/multi_session_lifelong_demo.rs"
|
|
221
|
+
required-features = ["image-io"]
|
|
222
|
+
|
|
223
|
+
[[example]]
|
|
224
|
+
name = "superpoint_onnx_throughput"
|
|
225
|
+
path = "examples/superpoint_onnx_throughput.rs"
|
|
226
|
+
required-features = ["image-io", "onnx-inference"]
|
|
227
|
+
|
|
228
|
+
[[example]]
|
|
229
|
+
name = "yolox_track_demo"
|
|
230
|
+
path = "examples/yolox_track_demo.rs"
|
|
231
|
+
required-features = ["image-io", "onnx-inference"]
|
|
232
|
+
|
|
233
|
+
[[example]]
|
|
234
|
+
name = "deep_frontend_onnx_demo"
|
|
235
|
+
path = "examples/deep_frontend_onnx_demo.rs"
|
|
236
|
+
required-features = ["image-io", "onnx-inference"]
|
|
237
|
+
|
|
238
|
+
[[example]]
|
|
239
|
+
name = "deep_stereo_slam"
|
|
240
|
+
path = "examples/deep_stereo_slam.rs"
|
|
241
|
+
required-features = ["image-io", "onnx-inference"]
|
|
242
|
+
|
|
243
|
+
[[example]]
|
|
244
|
+
name = "vpr_global_descriptor_demo"
|
|
245
|
+
path = "examples/vpr_global_descriptor_demo.rs"
|
|
246
|
+
required-features = ["image-io", "onnx-inference"]
|
|
247
|
+
|
|
248
|
+
[[example]]
|
|
249
|
+
name = "learned_retrieval_candidates"
|
|
250
|
+
path = "examples/learned_retrieval_candidates.rs"
|
|
251
|
+
|
|
252
|
+
[[example]]
|
|
253
|
+
name = "materialize_learned_rig_candidates"
|
|
254
|
+
path = "examples/materialize_learned_rig_candidates.rs"
|
|
255
|
+
|
|
256
|
+
[[example]]
|
|
257
|
+
name = "admit_learned_rig_rotation_cycles"
|
|
258
|
+
path = "examples/admit_learned_rig_rotation_cycles.rs"
|
|
259
|
+
|
|
260
|
+
[[example]]
|
|
261
|
+
name = "euroc_dpvo_vo_demo"
|
|
262
|
+
path = "examples/euroc_dpvo_vo_demo.rs"
|
|
263
|
+
required-features = ["image-io", "onnx-inference"]
|
|
264
|
+
|
|
265
|
+
[[example]]
|
|
266
|
+
name = "basalt_euroc_vio_demo"
|
|
267
|
+
path = "examples/basalt_euroc_vio_demo.rs"
|
|
268
|
+
|
|
269
|
+
[[example]]
|
|
270
|
+
name = "fixed_sift_descriptor_probe"
|
|
271
|
+
path = "examples/fixed_sift_descriptor_probe.rs"
|
|
272
|
+
required-features = ["image-io"]
|
|
273
|
+
|
|
274
|
+
[[example]]
|
|
275
|
+
name = "vlfeat_detector_diagnostic"
|
|
276
|
+
path = "examples/vlfeat_detector_diagnostic.rs"
|
|
277
|
+
required-features = ["image-io"]
|
|
278
|
+
|
|
279
|
+
[dev-dependencies]
|
|
280
|
+
# 7-Scenes relocalization benchmark needs raw 16-bit depth PNGs (mm); the io
|
|
281
|
+
# crate's grayscale loader normalizes to [0,1] and loses metric depth, so the
|
|
282
|
+
# example reads depth directly. Pinned to the io crate's image version.
|
|
283
|
+
image = { version = "=0.25.5", default-features = false, features = ["png"] }
|
|
284
|
+
rayon = "1"
|
visloc-0.4.0/PKG-INFO
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: visloc
|
|
3
|
+
Version: 0.4.0
|
|
4
|
+
Classifier: Programming Language :: Rust
|
|
5
|
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
6
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
7
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
8
|
+
Classifier: Topic :: Scientific/Engineering :: Image Recognition
|
|
9
|
+
Requires-Dist: numpy>=1.21
|
|
10
|
+
Requires-Dist: pytest>=7 ; extra == 'test'
|
|
11
|
+
Provides-Extra: test
|
|
12
|
+
Summary: Python bindings for visloc-rs: cameras, SE(3) poses, COLMAP IO, map-based localization, and trajectory evaluation.
|
|
13
|
+
Home-Page: https://github.com/rsasaki0109/visloc-rs
|
|
14
|
+
License: MIT OR Apache-2.0
|
|
15
|
+
Requires-Python: >=3.9
|
|
16
|
+
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
|
|
17
|
+
Project-URL: Repository, https://github.com/rsasaki0109/visloc-rs
|
|
18
|
+
|
|
19
|
+
# visloc (Python bindings)
|
|
20
|
+
|
|
21
|
+
Python bindings for [visloc-rs](https://github.com/rsasaki0109/visloc-rs), a
|
|
22
|
+
pure-Rust visual localization / SfM library, built with
|
|
23
|
+
[pyo3](https://pyo3.rs) and [maturin](https://www.maturin.rs). Arrays go in and
|
|
24
|
+
out as NumPy arrays; no GPU features are compiled in.
|
|
25
|
+
|
|
26
|
+
The bindings cover the stable-intent surface of the Rust crates
|
|
27
|
+
(`docs/api_stability.md`):
|
|
28
|
+
|
|
29
|
+
| Python | Rust |
|
|
30
|
+
| --- | --- |
|
|
31
|
+
| `Camera` (COLMAP models + Double Sphere): `project`, `unproject`, `normalize`, `calibration_matrix` | `visloc_core::types::Camera` |
|
|
32
|
+
| `Pose` (alias `SE3`): rotation / quaternion / translation, `compose` (`@`), `inverse`, `transform`, `exp` / `log`, `camera_center` | `visloc_core::geometry::{SE3, Pose}` |
|
|
33
|
+
| `Reconstruction`, `Image`: COLMAP text + binary read/write, cameras / images / points3D as NumPy arrays | `visloc_io::colmap` |
|
|
34
|
+
| `localize`: 2-D keypoints + descriptors against a map with per-point descriptors (brute-force matching, PnP + RANSAC, refinement) | `visloc_localization::LocalizationPipeline` |
|
|
35
|
+
| `estimate_pose_pnp_ransac`: pose from 2D-3D correspondences | `visloc_vision::ransac::PnPRansac` |
|
|
36
|
+
| `evaluate_ate`, `evaluate_rpe`, `umeyama_alignment`: trajectory evaluation with SE(3) / Sim(3) alignment | `visloc_tracking::{PoseTrajectory, umeyama_similarity_transform}` |
|
|
37
|
+
|
|
38
|
+
Conventions match the Rust library and COLMAP: a camera pose is the
|
|
39
|
+
**world-to-camera** transform `T_cw` (`x_cam = R x_world + t`), quaternions are
|
|
40
|
+
`(w, x, y, z)` unless `scalar_first=False`, and pixel coordinates follow the
|
|
41
|
+
camera model's principal point.
|
|
42
|
+
|
|
43
|
+
## Build and install
|
|
44
|
+
|
|
45
|
+
Requirements: a Rust toolchain (the repository pins it in `rust-toolchain.toml`),
|
|
46
|
+
Python >= 3.9, and NumPy.
|
|
47
|
+
|
|
48
|
+
```sh
|
|
49
|
+
cd bindings/python
|
|
50
|
+
python -m venv .venv && . .venv/bin/activate
|
|
51
|
+
pip install maturin pytest numpy
|
|
52
|
+
|
|
53
|
+
# Editable development install into the active virtualenv:
|
|
54
|
+
maturin develop --release
|
|
55
|
+
|
|
56
|
+
# Or build a wheel:
|
|
57
|
+
maturin build --release --out dist && pip install dist/*.whl
|
|
58
|
+
|
|
59
|
+
# Tests (use the repository's COLMAP fixtures when present):
|
|
60
|
+
pytest -q
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
This crate is intentionally **not** a member of the root Cargo workspace (it is
|
|
64
|
+
listed under `[workspace] exclude` and has its own `Cargo.lock`): a pyo3
|
|
65
|
+
extension module leaves libpython symbols to be resolved at import time, so it
|
|
66
|
+
must not take part in `cargo test --workspace` at the repository root. Run
|
|
67
|
+
`cargo fmt` / `cargo clippy -- -D warnings` from this directory.
|
|
68
|
+
|
|
69
|
+
## Examples
|
|
70
|
+
|
|
71
|
+
### Cameras and poses
|
|
72
|
+
|
|
73
|
+
```python
|
|
74
|
+
import numpy as np
|
|
75
|
+
import visloc
|
|
76
|
+
|
|
77
|
+
camera = visloc.Camera("OPENCV", 640, 480, [500, 500, 320, 240, -0.1, 0.01, 0.0, 0.0])
|
|
78
|
+
pose = visloc.Pose.from_quaternion([1, 0, 0, 0], [0.0, 0.0, 0.5]) # world-to-camera
|
|
79
|
+
|
|
80
|
+
world_points = np.random.default_rng(0).uniform(-1, 1, (100, 3)) + [0, 0, 5]
|
|
81
|
+
pixels = camera.project(world_points, pose=pose) # (100, 2), NaN where not visible
|
|
82
|
+
rays = camera.unproject(pixels) # (100, 3) unit camera-frame rays
|
|
83
|
+
|
|
84
|
+
relative = pose.inverse() @ visloc.Pose.exp([0.1, 0, 0, 0, 0.05, 0])
|
|
85
|
+
print(relative.matrix(), relative.quaternion(), pose.camera_center())
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### COLMAP models
|
|
89
|
+
|
|
90
|
+
```python
|
|
91
|
+
model = visloc.Reconstruction.read("sparse/0") # binary if cameras.bin exists, else text
|
|
92
|
+
print(model) # Reconstruction(cameras=..., images=..., points3d=...)
|
|
93
|
+
|
|
94
|
+
xyz = model.points3d # (M, 3) float64
|
|
95
|
+
ids = model.point3d_ids # (M,) uint64, aligned with xyz
|
|
96
|
+
for image_id, image in model.images.items():
|
|
97
|
+
T_cw = image.pose.matrix() # 4x4 world-to-camera
|
|
98
|
+
uv = image.keypoints # (N, 2)
|
|
99
|
+
observed = image.point3d_ids # (N,) int64, -1 = untriangulated
|
|
100
|
+
|
|
101
|
+
model.write_binary("sparse_out") # or write_text(...)
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Models can also be built from NumPy data with `add_camera`, `add_image`
|
|
105
|
+
(`visloc.Image(id, camera_id, pose, keypoints, point3d_ids)`), and
|
|
106
|
+
`set_points3d(ids, xyz, descriptors=None)`. Point tracks in `points3D` are
|
|
107
|
+
derived from the image observations when writing. visloc's map model does not
|
|
108
|
+
keep image names, point colors, or reprojection errors: written models use
|
|
109
|
+
`image_<id>.jpg`, white points, and zero error.
|
|
110
|
+
|
|
111
|
+
### Localization
|
|
112
|
+
|
|
113
|
+
```python
|
|
114
|
+
# Attach one descriptor per 3-D point: from a `LANDMARK_ID D0 D1 ...` text file...
|
|
115
|
+
model.load_point3d_descriptors("landmark_descriptors.txt")
|
|
116
|
+
# ...or directly: model.set_points3d(ids, xyz, descriptors) # (M, D)
|
|
117
|
+
|
|
118
|
+
result = visloc.localize(
|
|
119
|
+
model.cameras[1], query_keypoints, query_descriptors, model, # (N, 2), (N, D)
|
|
120
|
+
ratio=0.8, ransac_iterations=256, reprojection_threshold=4.0, min_inliers=12,
|
|
121
|
+
)
|
|
122
|
+
if result.success:
|
|
123
|
+
print(result.pose.matrix(), result.inlier_count, result.mean_reprojection_error)
|
|
124
|
+
else:
|
|
125
|
+
print(result.failure_reason) # e.g. "no_descriptor_matches", "quality_gate_failed"
|
|
126
|
+
|
|
127
|
+
# With known 2D-3D correspondences:
|
|
128
|
+
pnp = visloc.estimate_pose_pnp_ransac(camera, pixels, world_points, reprojection_threshold=2.0)
|
|
129
|
+
if pnp is not None:
|
|
130
|
+
print(pnp.pose, pnp.inliers)
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
Note that `min_inliers` defaults to `0`, mirroring the Rust
|
|
134
|
+
`LocalizationConfig`; set a floor (for example 8-12) for real data.
|
|
135
|
+
|
|
136
|
+
### Trajectory evaluation
|
|
137
|
+
|
|
138
|
+
```python
|
|
139
|
+
# (N, 3) camera centers, (N, 7) [tx ty tz qx qy qz qw] (TUM), or (N, 4, 4) camera-to-world.
|
|
140
|
+
ate = visloc.evaluate_ate(estimated, ground_truth, alignment="sim3") # "se3" (default), "sim3", "first", "none"
|
|
141
|
+
print(ate.rmse, ate.mean, ate.max, ate.alignment.scale)
|
|
142
|
+
per_frame = ate.errors
|
|
143
|
+
|
|
144
|
+
# Match by frame id instead of by index:
|
|
145
|
+
ate = visloc.evaluate_ate(estimated, ground_truth, estimated_ids=est_ids, reference_ids=gt_ids)
|
|
146
|
+
|
|
147
|
+
rpe = visloc.evaluate_rpe(estimated_poses, gt_poses, delta=10)
|
|
148
|
+
print(rpe.translation["rmse"], rpe.rotation_deg["rmse"])
|
|
149
|
+
|
|
150
|
+
T = visloc.umeyama_alignment(source_xyz, target_xyz, with_scale=True)
|
|
151
|
+
aligned = T.apply(source_xyz)
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
## Typing
|
|
155
|
+
|
|
156
|
+
The package ships `py.typed` and a `_visloc.pyi` stub describing every class
|
|
157
|
+
and function, so editors and type checkers see the full API.
|
|
158
|
+
|
visloc-0.4.0/README.md
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
# visloc (Python bindings)
|
|
2
|
+
|
|
3
|
+
Python bindings for [visloc-rs](https://github.com/rsasaki0109/visloc-rs), a
|
|
4
|
+
pure-Rust visual localization / SfM library, built with
|
|
5
|
+
[pyo3](https://pyo3.rs) and [maturin](https://www.maturin.rs). Arrays go in and
|
|
6
|
+
out as NumPy arrays; no GPU features are compiled in.
|
|
7
|
+
|
|
8
|
+
The bindings cover the stable-intent surface of the Rust crates
|
|
9
|
+
(`docs/api_stability.md`):
|
|
10
|
+
|
|
11
|
+
| Python | Rust |
|
|
12
|
+
| --- | --- |
|
|
13
|
+
| `Camera` (COLMAP models + Double Sphere): `project`, `unproject`, `normalize`, `calibration_matrix` | `visloc_core::types::Camera` |
|
|
14
|
+
| `Pose` (alias `SE3`): rotation / quaternion / translation, `compose` (`@`), `inverse`, `transform`, `exp` / `log`, `camera_center` | `visloc_core::geometry::{SE3, Pose}` |
|
|
15
|
+
| `Reconstruction`, `Image`: COLMAP text + binary read/write, cameras / images / points3D as NumPy arrays | `visloc_io::colmap` |
|
|
16
|
+
| `localize`: 2-D keypoints + descriptors against a map with per-point descriptors (brute-force matching, PnP + RANSAC, refinement) | `visloc_localization::LocalizationPipeline` |
|
|
17
|
+
| `estimate_pose_pnp_ransac`: pose from 2D-3D correspondences | `visloc_vision::ransac::PnPRansac` |
|
|
18
|
+
| `evaluate_ate`, `evaluate_rpe`, `umeyama_alignment`: trajectory evaluation with SE(3) / Sim(3) alignment | `visloc_tracking::{PoseTrajectory, umeyama_similarity_transform}` |
|
|
19
|
+
|
|
20
|
+
Conventions match the Rust library and COLMAP: a camera pose is the
|
|
21
|
+
**world-to-camera** transform `T_cw` (`x_cam = R x_world + t`), quaternions are
|
|
22
|
+
`(w, x, y, z)` unless `scalar_first=False`, and pixel coordinates follow the
|
|
23
|
+
camera model's principal point.
|
|
24
|
+
|
|
25
|
+
## Build and install
|
|
26
|
+
|
|
27
|
+
Requirements: a Rust toolchain (the repository pins it in `rust-toolchain.toml`),
|
|
28
|
+
Python >= 3.9, and NumPy.
|
|
29
|
+
|
|
30
|
+
```sh
|
|
31
|
+
cd bindings/python
|
|
32
|
+
python -m venv .venv && . .venv/bin/activate
|
|
33
|
+
pip install maturin pytest numpy
|
|
34
|
+
|
|
35
|
+
# Editable development install into the active virtualenv:
|
|
36
|
+
maturin develop --release
|
|
37
|
+
|
|
38
|
+
# Or build a wheel:
|
|
39
|
+
maturin build --release --out dist && pip install dist/*.whl
|
|
40
|
+
|
|
41
|
+
# Tests (use the repository's COLMAP fixtures when present):
|
|
42
|
+
pytest -q
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
This crate is intentionally **not** a member of the root Cargo workspace (it is
|
|
46
|
+
listed under `[workspace] exclude` and has its own `Cargo.lock`): a pyo3
|
|
47
|
+
extension module leaves libpython symbols to be resolved at import time, so it
|
|
48
|
+
must not take part in `cargo test --workspace` at the repository root. Run
|
|
49
|
+
`cargo fmt` / `cargo clippy -- -D warnings` from this directory.
|
|
50
|
+
|
|
51
|
+
## Examples
|
|
52
|
+
|
|
53
|
+
### Cameras and poses
|
|
54
|
+
|
|
55
|
+
```python
|
|
56
|
+
import numpy as np
|
|
57
|
+
import visloc
|
|
58
|
+
|
|
59
|
+
camera = visloc.Camera("OPENCV", 640, 480, [500, 500, 320, 240, -0.1, 0.01, 0.0, 0.0])
|
|
60
|
+
pose = visloc.Pose.from_quaternion([1, 0, 0, 0], [0.0, 0.0, 0.5]) # world-to-camera
|
|
61
|
+
|
|
62
|
+
world_points = np.random.default_rng(0).uniform(-1, 1, (100, 3)) + [0, 0, 5]
|
|
63
|
+
pixels = camera.project(world_points, pose=pose) # (100, 2), NaN where not visible
|
|
64
|
+
rays = camera.unproject(pixels) # (100, 3) unit camera-frame rays
|
|
65
|
+
|
|
66
|
+
relative = pose.inverse() @ visloc.Pose.exp([0.1, 0, 0, 0, 0.05, 0])
|
|
67
|
+
print(relative.matrix(), relative.quaternion(), pose.camera_center())
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### COLMAP models
|
|
71
|
+
|
|
72
|
+
```python
|
|
73
|
+
model = visloc.Reconstruction.read("sparse/0") # binary if cameras.bin exists, else text
|
|
74
|
+
print(model) # Reconstruction(cameras=..., images=..., points3d=...)
|
|
75
|
+
|
|
76
|
+
xyz = model.points3d # (M, 3) float64
|
|
77
|
+
ids = model.point3d_ids # (M,) uint64, aligned with xyz
|
|
78
|
+
for image_id, image in model.images.items():
|
|
79
|
+
T_cw = image.pose.matrix() # 4x4 world-to-camera
|
|
80
|
+
uv = image.keypoints # (N, 2)
|
|
81
|
+
observed = image.point3d_ids # (N,) int64, -1 = untriangulated
|
|
82
|
+
|
|
83
|
+
model.write_binary("sparse_out") # or write_text(...)
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Models can also be built from NumPy data with `add_camera`, `add_image`
|
|
87
|
+
(`visloc.Image(id, camera_id, pose, keypoints, point3d_ids)`), and
|
|
88
|
+
`set_points3d(ids, xyz, descriptors=None)`. Point tracks in `points3D` are
|
|
89
|
+
derived from the image observations when writing. visloc's map model does not
|
|
90
|
+
keep image names, point colors, or reprojection errors: written models use
|
|
91
|
+
`image_<id>.jpg`, white points, and zero error.
|
|
92
|
+
|
|
93
|
+
### Localization
|
|
94
|
+
|
|
95
|
+
```python
|
|
96
|
+
# Attach one descriptor per 3-D point: from a `LANDMARK_ID D0 D1 ...` text file...
|
|
97
|
+
model.load_point3d_descriptors("landmark_descriptors.txt")
|
|
98
|
+
# ...or directly: model.set_points3d(ids, xyz, descriptors) # (M, D)
|
|
99
|
+
|
|
100
|
+
result = visloc.localize(
|
|
101
|
+
model.cameras[1], query_keypoints, query_descriptors, model, # (N, 2), (N, D)
|
|
102
|
+
ratio=0.8, ransac_iterations=256, reprojection_threshold=4.0, min_inliers=12,
|
|
103
|
+
)
|
|
104
|
+
if result.success:
|
|
105
|
+
print(result.pose.matrix(), result.inlier_count, result.mean_reprojection_error)
|
|
106
|
+
else:
|
|
107
|
+
print(result.failure_reason) # e.g. "no_descriptor_matches", "quality_gate_failed"
|
|
108
|
+
|
|
109
|
+
# With known 2D-3D correspondences:
|
|
110
|
+
pnp = visloc.estimate_pose_pnp_ransac(camera, pixels, world_points, reprojection_threshold=2.0)
|
|
111
|
+
if pnp is not None:
|
|
112
|
+
print(pnp.pose, pnp.inliers)
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
Note that `min_inliers` defaults to `0`, mirroring the Rust
|
|
116
|
+
`LocalizationConfig`; set a floor (for example 8-12) for real data.
|
|
117
|
+
|
|
118
|
+
### Trajectory evaluation
|
|
119
|
+
|
|
120
|
+
```python
|
|
121
|
+
# (N, 3) camera centers, (N, 7) [tx ty tz qx qy qz qw] (TUM), or (N, 4, 4) camera-to-world.
|
|
122
|
+
ate = visloc.evaluate_ate(estimated, ground_truth, alignment="sim3") # "se3" (default), "sim3", "first", "none"
|
|
123
|
+
print(ate.rmse, ate.mean, ate.max, ate.alignment.scale)
|
|
124
|
+
per_frame = ate.errors
|
|
125
|
+
|
|
126
|
+
# Match by frame id instead of by index:
|
|
127
|
+
ate = visloc.evaluate_ate(estimated, ground_truth, estimated_ids=est_ids, reference_ids=gt_ids)
|
|
128
|
+
|
|
129
|
+
rpe = visloc.evaluate_rpe(estimated_poses, gt_poses, delta=10)
|
|
130
|
+
print(rpe.translation["rmse"], rpe.rotation_deg["rmse"])
|
|
131
|
+
|
|
132
|
+
T = visloc.umeyama_alignment(source_xyz, target_xyz, with_scale=True)
|
|
133
|
+
aligned = T.apply(source_xyz)
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
## Typing
|
|
137
|
+
|
|
138
|
+
The package ships `py.typed` and a `_visloc.pyi` stub describing every class
|
|
139
|
+
and function, so editors and type checkers see the full API.
|