lomatch 1.0.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.
- lomatch-1.0.0/PKG-INFO +114 -0
- lomatch-1.0.0/README.md +91 -0
- lomatch-1.0.0/pyproject.toml +52 -0
- lomatch-1.0.0/src/loma/__init__.py +7 -0
- lomatch-1.0.0/src/loma/benchmarks/__init__.py +4 -0
- lomatch-1.0.0/src/loma/benchmarks/mega.py +196 -0
- lomatch-1.0.0/src/loma/benchmarks/rubik.py +310 -0
- lomatch-1.0.0/src/loma/benchmarks/scannet.py +121 -0
- lomatch-1.0.0/src/loma/benchmarks/wxbs.py +76 -0
- lomatch-1.0.0/src/loma/descriptor/__init__.py +1 -0
- lomatch-1.0.0/src/loma/descriptor/dedode.py +407 -0
- lomatch-1.0.0/src/loma/descriptor/transformer/__init__.py +1 -0
- lomatch-1.0.0/src/loma/descriptor/transformer/dinov2.py +397 -0
- lomatch-1.0.0/src/loma/descriptor/transformer/layers/__init__.py +10 -0
- lomatch-1.0.0/src/loma/descriptor/transformer/layers/attention.py +59 -0
- lomatch-1.0.0/src/loma/descriptor/transformer/layers/block.py +144 -0
- lomatch-1.0.0/src/loma/descriptor/transformer/layers/drop_path.py +37 -0
- lomatch-1.0.0/src/loma/descriptor/transformer/layers/layer_scale.py +28 -0
- lomatch-1.0.0/src/loma/descriptor/transformer/layers/mlp.py +41 -0
- lomatch-1.0.0/src/loma/descriptor/transformer/layers/patch_embed.py +101 -0
- lomatch-1.0.0/src/loma/detector/__init__.py +1 -0
- lomatch-1.0.0/src/loma/detector/dad.py +425 -0
- lomatch-1.0.0/src/loma/detector/utils.py +213 -0
- lomatch-1.0.0/src/loma/device.py +13 -0
- lomatch-1.0.0/src/loma/features.py +52 -0
- lomatch-1.0.0/src/loma/geometry.py +849 -0
- lomatch-1.0.0/src/loma/io.py +30 -0
- lomatch-1.0.0/src/loma/loma.py +498 -0
- lomatch-1.0.0/src/loma/loss.py +102 -0
- lomatch-1.0.0/src/loma/normalizers.py +17 -0
- lomatch-1.0.0/src/loma/random.py +20 -0
- lomatch-1.0.0/src/loma/types.py +125 -0
lomatch-1.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
|
+
Name: lomatch
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: A very good local feature matcher.
|
|
5
|
+
Author: Johan Edstedt, David Nordström
|
|
6
|
+
Author-email: Johan Edstedt <johan.edstedt@liu.se>, David Nordström <davnords@chalmers.se>
|
|
7
|
+
Requires-Dist: dataclasses>=0.8
|
|
8
|
+
Requires-Dist: einops>=0.8.1
|
|
9
|
+
Requires-Dist: opencv-python>=4.12.0.88
|
|
10
|
+
Requires-Dist: pillow>=12.0.0
|
|
11
|
+
Requires-Dist: torch
|
|
12
|
+
Requires-Dist: torchvision>=0.23.0
|
|
13
|
+
Requires-Dist: tqdm>=4.67.1
|
|
14
|
+
Requires-Dist: tyro
|
|
15
|
+
Requires-Dist: ruff ; extra == 'dev'
|
|
16
|
+
Requires-Dist: pyright ; extra == 'dev'
|
|
17
|
+
Requires-Dist: wxbs-benchmark>=0.0.4 ; extra == 'eval'
|
|
18
|
+
Requires-Dist: scipy>=1.15.3 ; extra == 'eval'
|
|
19
|
+
Requires-Python: >=3.10
|
|
20
|
+
Provides-Extra: dev
|
|
21
|
+
Provides-Extra: eval
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
|
|
24
|
+
<div align="center">
|
|
25
|
+
<h1>LoMa: Local Feature Matching Revisited</h1>
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
<a href="https://arxiv.org/abs/TBD"><img src="https://img.shields.io/badge/arXiv-TBD-b31b1b" alt="arXiv"></a>
|
|
29
|
+
<a href="https://www.davnords.com/loma"><img src="https://img.shields.io/badge/Project_Page-green" alt="Project Page"></a>
|
|
30
|
+
|
|
31
|
+
**Chalmers University of Technology**; **Linköping University**; **University of Amsterdam**; **Lund University**
|
|
32
|
+
|
|
33
|
+
[David Nordström*](https://scholar.google.com/citations?user=-vJPE04AAAAJ), [Johan Edstedt*](https://scholar.google.com/citations?user=Ul-vMR0AAAAJ&hl), [Georg Bökman](https://scholar.google.com/citations?user=FUE3Wd0AAAAJ), [Jonathan Astermark](https://scholar.google.com/citations?user=dsEPAvUAAAAJ), [Anders Heyden](https://scholar.google.com/citations?user=9j-6i_oAAAAJ), [Viktor Larsson](https://scholar.google.com/citations?user=vHeD0TYAAAAJ), [Mårten Wadenbäck](https://scholar.google.com/citations?user=6WRQpCQAAAAJ), [Michael Felsberg](https://scholar.google.com/citations?user=lkWfR08AAAAJ), [Fredrik Kahl](https://scholar.google.com/citations?user=P_w6UgMAAAAJ)
|
|
34
|
+
</div>
|
|
35
|
+
|
|
36
|
+
<p align="center">
|
|
37
|
+
<img src="assets/loma.jpg" alt="example" width=45%>
|
|
38
|
+
<br>
|
|
39
|
+
<em>Performance on a difficult matching pair compared to LightGlue.</em>
|
|
40
|
+
</p>
|
|
41
|
+
|
|
42
|
+
## Overview
|
|
43
|
+
LoMa is a fast and accurate family of local feature matchers. It works similar to [LightGlue](https://github.com/cvg/LightGlue) but significantly improves matching robustness and accuracy across benchmarks, even outperforming [RoMa](https://github.com/Parskatt/RoMa) and [RoMa v2](https://github.com/Parskatt/RoMaV2) on the difficult [WxBS](https://arxiv.org/abs/1504.06603) benchmark. As LoMa leverages local keypoint descriptions, the models are perfect drop-in replacement in e.g. SfM and Visual Localization pipelines.
|
|
44
|
+
|
|
45
|
+
## Updates
|
|
46
|
+
- [April 6, 2026] LoMa inference code released.
|
|
47
|
+
|
|
48
|
+
## How to Use
|
|
49
|
+
```python
|
|
50
|
+
import cv2
|
|
51
|
+
from loma import LoMa, LoMaB
|
|
52
|
+
|
|
53
|
+
# load pretrained model
|
|
54
|
+
model = LoMa(LoMaB()) # also available: LoMaB128, LoMaL, LoMaG
|
|
55
|
+
# Define image paths, e.g.
|
|
56
|
+
img_A_path, img_B_path = "assets/0015_A.jpg", "assets/0015_B.jpg"
|
|
57
|
+
# Extract matching keypoints in image coordinates
|
|
58
|
+
kptsA, kptsB = model.match(img_A_path, img_B_path)
|
|
59
|
+
|
|
60
|
+
# Find a fundamental matrix (or anything else of interest)
|
|
61
|
+
F, mask = cv2.findFundamentalMat(
|
|
62
|
+
kptsA, kptsB, ransacReprojThreshold=0.2, method=cv2.USAC_MAGSAC, confidence=0.999999, maxIters=10000
|
|
63
|
+
)
|
|
64
|
+
```
|
|
65
|
+
We provide additional code examples in [demo.py](demo.py), which might help in understanding. To run the demo, use the following API:
|
|
66
|
+
```bash
|
|
67
|
+
uv run demo.py matcher:loma-b
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Setup/Install
|
|
71
|
+
In your python environment (tested on Linux python 3.12), run:
|
|
72
|
+
```bash
|
|
73
|
+
uv pip install -e .
|
|
74
|
+
```
|
|
75
|
+
or
|
|
76
|
+
```bash
|
|
77
|
+
uv sync
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Benchmarks
|
|
81
|
+
We initially provide code for evaluating on MegaDepth, ScanNet, WxBS and RUBIK. If you do not already have MegaDepth1500 and ScanNet1500, you may run the following to download them:
|
|
82
|
+
```bash
|
|
83
|
+
source scripts/eval_prep.sh
|
|
84
|
+
```
|
|
85
|
+
To run a benchmark you need to install the optional dependencies by e.g. `uv sync --extra eval`. Thereafter, you can use the following call signature:
|
|
86
|
+
```bash
|
|
87
|
+
uv run eval.py matcher:loma-b --benchmark wxbs
|
|
88
|
+
```
|
|
89
|
+
Use `uv run eval.py --help` to explore the different options.
|
|
90
|
+
|
|
91
|
+
### Expected Results
|
|
92
|
+
The results are similar to those reported in the paper. For example, running the evaluation for LoMa-B on WxBS gives us `mAA_10px: 0.6876`.
|
|
93
|
+
|
|
94
|
+
## Sizes
|
|
95
|
+
We an array of models: LoMA-{B, B128, L, G}. For most usecases LoMa-B, which is the same size as LightGlue, works fine. LoMa-G is significantly heavier but gives the most accurate matches, even surpassing the RoMa-family on e.g. WxBS and IMC22.
|
|
96
|
+
|
|
97
|
+
## Checklist
|
|
98
|
+
- [x] Publish the inference code.
|
|
99
|
+
- [ ] Release a lightweight descriptor.
|
|
100
|
+
- [ ] Integrate with [HLoc](https://github.com/cvg/Hierarchical-Localization?tab=readme-ov-file).
|
|
101
|
+
- [ ] Provide training code.
|
|
102
|
+
- [ ] Release HardMatch.
|
|
103
|
+
|
|
104
|
+
## License
|
|
105
|
+
All our code except the matcher, which inherits its license from LightGlue, is MIT license. LightGlue has an [Apache-2.0](https://github.com/cvg/LightGlue/blob/main/LICENSE) license.
|
|
106
|
+
|
|
107
|
+
## Acknowledgement
|
|
108
|
+
Thanks to [Parskatt](https://github.com/Parskatt) for writing most of the code. Our codebase structure is mainly based on [RoMaV2](https://github.com/Parskatt/RoMaV2) and our architectures build on [LightGlue](https://github.com/cvg/lightglue), [DeDoDe](https://github.com/Parskatt/DeDoDe), and [DaD](https://github.com/Parskatt/dad).
|
|
109
|
+
|
|
110
|
+
## BibTeX
|
|
111
|
+
If you find our models useful, please consider citing our paper!
|
|
112
|
+
```
|
|
113
|
+
Preprint coming soon.
|
|
114
|
+
```
|
lomatch-1.0.0/README.md
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
<h1>LoMa: Local Feature Matching Revisited</h1>
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
<a href="https://arxiv.org/abs/TBD"><img src="https://img.shields.io/badge/arXiv-TBD-b31b1b" alt="arXiv"></a>
|
|
6
|
+
<a href="https://www.davnords.com/loma"><img src="https://img.shields.io/badge/Project_Page-green" alt="Project Page"></a>
|
|
7
|
+
|
|
8
|
+
**Chalmers University of Technology**; **Linköping University**; **University of Amsterdam**; **Lund University**
|
|
9
|
+
|
|
10
|
+
[David Nordström*](https://scholar.google.com/citations?user=-vJPE04AAAAJ), [Johan Edstedt*](https://scholar.google.com/citations?user=Ul-vMR0AAAAJ&hl), [Georg Bökman](https://scholar.google.com/citations?user=FUE3Wd0AAAAJ), [Jonathan Astermark](https://scholar.google.com/citations?user=dsEPAvUAAAAJ), [Anders Heyden](https://scholar.google.com/citations?user=9j-6i_oAAAAJ), [Viktor Larsson](https://scholar.google.com/citations?user=vHeD0TYAAAAJ), [Mårten Wadenbäck](https://scholar.google.com/citations?user=6WRQpCQAAAAJ), [Michael Felsberg](https://scholar.google.com/citations?user=lkWfR08AAAAJ), [Fredrik Kahl](https://scholar.google.com/citations?user=P_w6UgMAAAAJ)
|
|
11
|
+
</div>
|
|
12
|
+
|
|
13
|
+
<p align="center">
|
|
14
|
+
<img src="assets/loma.jpg" alt="example" width=45%>
|
|
15
|
+
<br>
|
|
16
|
+
<em>Performance on a difficult matching pair compared to LightGlue.</em>
|
|
17
|
+
</p>
|
|
18
|
+
|
|
19
|
+
## Overview
|
|
20
|
+
LoMa is a fast and accurate family of local feature matchers. It works similar to [LightGlue](https://github.com/cvg/LightGlue) but significantly improves matching robustness and accuracy across benchmarks, even outperforming [RoMa](https://github.com/Parskatt/RoMa) and [RoMa v2](https://github.com/Parskatt/RoMaV2) on the difficult [WxBS](https://arxiv.org/abs/1504.06603) benchmark. As LoMa leverages local keypoint descriptions, the models are perfect drop-in replacement in e.g. SfM and Visual Localization pipelines.
|
|
21
|
+
|
|
22
|
+
## Updates
|
|
23
|
+
- [April 6, 2026] LoMa inference code released.
|
|
24
|
+
|
|
25
|
+
## How to Use
|
|
26
|
+
```python
|
|
27
|
+
import cv2
|
|
28
|
+
from loma import LoMa, LoMaB
|
|
29
|
+
|
|
30
|
+
# load pretrained model
|
|
31
|
+
model = LoMa(LoMaB()) # also available: LoMaB128, LoMaL, LoMaG
|
|
32
|
+
# Define image paths, e.g.
|
|
33
|
+
img_A_path, img_B_path = "assets/0015_A.jpg", "assets/0015_B.jpg"
|
|
34
|
+
# Extract matching keypoints in image coordinates
|
|
35
|
+
kptsA, kptsB = model.match(img_A_path, img_B_path)
|
|
36
|
+
|
|
37
|
+
# Find a fundamental matrix (or anything else of interest)
|
|
38
|
+
F, mask = cv2.findFundamentalMat(
|
|
39
|
+
kptsA, kptsB, ransacReprojThreshold=0.2, method=cv2.USAC_MAGSAC, confidence=0.999999, maxIters=10000
|
|
40
|
+
)
|
|
41
|
+
```
|
|
42
|
+
We provide additional code examples in [demo.py](demo.py), which might help in understanding. To run the demo, use the following API:
|
|
43
|
+
```bash
|
|
44
|
+
uv run demo.py matcher:loma-b
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Setup/Install
|
|
48
|
+
In your python environment (tested on Linux python 3.12), run:
|
|
49
|
+
```bash
|
|
50
|
+
uv pip install -e .
|
|
51
|
+
```
|
|
52
|
+
or
|
|
53
|
+
```bash
|
|
54
|
+
uv sync
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Benchmarks
|
|
58
|
+
We initially provide code for evaluating on MegaDepth, ScanNet, WxBS and RUBIK. If you do not already have MegaDepth1500 and ScanNet1500, you may run the following to download them:
|
|
59
|
+
```bash
|
|
60
|
+
source scripts/eval_prep.sh
|
|
61
|
+
```
|
|
62
|
+
To run a benchmark you need to install the optional dependencies by e.g. `uv sync --extra eval`. Thereafter, you can use the following call signature:
|
|
63
|
+
```bash
|
|
64
|
+
uv run eval.py matcher:loma-b --benchmark wxbs
|
|
65
|
+
```
|
|
66
|
+
Use `uv run eval.py --help` to explore the different options.
|
|
67
|
+
|
|
68
|
+
### Expected Results
|
|
69
|
+
The results are similar to those reported in the paper. For example, running the evaluation for LoMa-B on WxBS gives us `mAA_10px: 0.6876`.
|
|
70
|
+
|
|
71
|
+
## Sizes
|
|
72
|
+
We an array of models: LoMA-{B, B128, L, G}. For most usecases LoMa-B, which is the same size as LightGlue, works fine. LoMa-G is significantly heavier but gives the most accurate matches, even surpassing the RoMa-family on e.g. WxBS and IMC22.
|
|
73
|
+
|
|
74
|
+
## Checklist
|
|
75
|
+
- [x] Publish the inference code.
|
|
76
|
+
- [ ] Release a lightweight descriptor.
|
|
77
|
+
- [ ] Integrate with [HLoc](https://github.com/cvg/Hierarchical-Localization?tab=readme-ov-file).
|
|
78
|
+
- [ ] Provide training code.
|
|
79
|
+
- [ ] Release HardMatch.
|
|
80
|
+
|
|
81
|
+
## License
|
|
82
|
+
All our code except the matcher, which inherits its license from LightGlue, is MIT license. LightGlue has an [Apache-2.0](https://github.com/cvg/LightGlue/blob/main/LICENSE) license.
|
|
83
|
+
|
|
84
|
+
## Acknowledgement
|
|
85
|
+
Thanks to [Parskatt](https://github.com/Parskatt) for writing most of the code. Our codebase structure is mainly based on [RoMaV2](https://github.com/Parskatt/RoMaV2) and our architectures build on [LightGlue](https://github.com/cvg/lightglue), [DeDoDe](https://github.com/Parskatt/DeDoDe), and [DaD](https://github.com/Parskatt/dad).
|
|
86
|
+
|
|
87
|
+
## BibTeX
|
|
88
|
+
If you find our models useful, please consider citing our paper!
|
|
89
|
+
```
|
|
90
|
+
Preprint coming soon.
|
|
91
|
+
```
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "lomatch"
|
|
3
|
+
version = "1.0.0"
|
|
4
|
+
description = "A very good local feature matcher."
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
authors = [
|
|
7
|
+
{ name = "Johan Edstedt", email = "johan.edstedt@liu.se" },
|
|
8
|
+
{ name = "David Nordström", email = "davnords@chalmers.se" }
|
|
9
|
+
]
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
|
+
dependencies = [
|
|
12
|
+
"dataclasses>=0.8",
|
|
13
|
+
"einops>=0.8.1",
|
|
14
|
+
"opencv-python>=4.12.0.88",
|
|
15
|
+
"pillow>=12.0.0",
|
|
16
|
+
"torch",
|
|
17
|
+
"torchvision>=0.23.0",
|
|
18
|
+
"tqdm>=4.67.1",
|
|
19
|
+
"tyro",
|
|
20
|
+
]
|
|
21
|
+
|
|
22
|
+
[build-system]
|
|
23
|
+
requires = ["uv_build>=0.8.15,<0.9.0"]
|
|
24
|
+
build-backend = "uv_build"
|
|
25
|
+
|
|
26
|
+
[tool.uv.build-backend]
|
|
27
|
+
module-name = "loma"
|
|
28
|
+
|
|
29
|
+
[project.optional-dependencies]
|
|
30
|
+
eval = [
|
|
31
|
+
"wxbs-benchmark>=0.0.4",
|
|
32
|
+
"scipy>=1.15.3",
|
|
33
|
+
]
|
|
34
|
+
dev = [
|
|
35
|
+
"ruff",
|
|
36
|
+
"pyright",
|
|
37
|
+
]
|
|
38
|
+
|
|
39
|
+
[tool.pyright]
|
|
40
|
+
include = ["src"]
|
|
41
|
+
pythonVersion = "3.10"
|
|
42
|
+
# Optional imports (benchmark extras, poselib, etc.) are not always present in the dev env.
|
|
43
|
+
reportMissingImports = "none"
|
|
44
|
+
typeCheckingMode = "basic"
|
|
45
|
+
# Incomplete stubs for nn.Module indexing and dynamic third-party attributes.
|
|
46
|
+
reportIndexIssue = "none"
|
|
47
|
+
reportAttributeAccessIssue = "none"
|
|
48
|
+
# torchvision / vendor ViT: call signatures and general iteration on Module do not match stubs.
|
|
49
|
+
reportCallIssue = "none"
|
|
50
|
+
reportGeneralTypeIssues = "none"
|
|
51
|
+
reportArgumentType = "none"
|
|
52
|
+
reportReturnType = "none"
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import numpy as np
|
|
2
|
+
from tqdm import tqdm
|
|
3
|
+
import logging
|
|
4
|
+
|
|
5
|
+
from loma.loma import LoMa
|
|
6
|
+
from loma.geometry import (
|
|
7
|
+
compute_pose_error,
|
|
8
|
+
compute_relative_pose,
|
|
9
|
+
estimate_pose_cv2_ransac,
|
|
10
|
+
pose_auc,
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
logger = logging.getLogger(__name__)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class MegaDepthPoseEstimationBenchmark:
|
|
17
|
+
def __init__(
|
|
18
|
+
self,
|
|
19
|
+
data_root="data/megadepth",
|
|
20
|
+
num_keypoints: int = 4096,
|
|
21
|
+
) -> None:
|
|
22
|
+
self.data_root = data_root
|
|
23
|
+
self.num_keypoints = num_keypoints
|
|
24
|
+
self._post_init()
|
|
25
|
+
|
|
26
|
+
def _post_init(self):
|
|
27
|
+
raise NotImplementedError(
|
|
28
|
+
"Add scene names and benchmark name in derived class _post_init"
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
def benchmark(
|
|
32
|
+
self,
|
|
33
|
+
model: LoMa,
|
|
34
|
+
num_ransac_runs: int = 5,
|
|
35
|
+
sample_every: int = 1,
|
|
36
|
+
):
|
|
37
|
+
self.scenes = [
|
|
38
|
+
np.load(f"{self.data_root}/{scene}", allow_pickle=True)
|
|
39
|
+
for scene in self.scene_names
|
|
40
|
+
]
|
|
41
|
+
|
|
42
|
+
data_root = self.data_root
|
|
43
|
+
thresholds = [5, 10, 20]
|
|
44
|
+
tot_e_t, tot_e_R, tot_e_pose = [], [], []
|
|
45
|
+
for scene_ind in range(len(self.scenes)):
|
|
46
|
+
scene = self.scenes[scene_ind]
|
|
47
|
+
pairs = scene["pair_infos"]
|
|
48
|
+
intrinsics = scene["intrinsics"]
|
|
49
|
+
poses = scene["poses"]
|
|
50
|
+
im_paths = scene["image_paths"]
|
|
51
|
+
pair_inds = range(len(pairs))
|
|
52
|
+
for pairind in (
|
|
53
|
+
pbar := tqdm(
|
|
54
|
+
pair_inds[::sample_every],
|
|
55
|
+
desc="Current AUC: ?",
|
|
56
|
+
mininterval=10,
|
|
57
|
+
)
|
|
58
|
+
):
|
|
59
|
+
idx1, idx2 = pairs[pairind][0]
|
|
60
|
+
K1 = intrinsics[idx1].copy()
|
|
61
|
+
T1 = poses[idx1].copy()
|
|
62
|
+
R1, t1 = T1[:3, :3], T1[:3, 3]
|
|
63
|
+
K2 = intrinsics[idx2].copy()
|
|
64
|
+
T2 = poses[idx2].copy()
|
|
65
|
+
R2, t2 = T2[:3, :3], T2[:3, 3]
|
|
66
|
+
R, t = compute_relative_pose(R1, t1, R2, t2)
|
|
67
|
+
im_A_path = f"{data_root}/{im_paths[idx1]}"
|
|
68
|
+
im_B_path = f"{data_root}/{im_paths[idx2]}"
|
|
69
|
+
|
|
70
|
+
kpts1, kpts2 = model.match(
|
|
71
|
+
im_A_path, im_B_path, num_keypoints=self.num_keypoints
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
for _ in range(num_ransac_runs):
|
|
75
|
+
shuffling = np.random.permutation(np.arange(len(kpts1)))
|
|
76
|
+
kpts1 = kpts1[shuffling]
|
|
77
|
+
kpts2 = kpts2[shuffling]
|
|
78
|
+
|
|
79
|
+
try:
|
|
80
|
+
threshold = 0.5
|
|
81
|
+
norm_threshold = threshold / (
|
|
82
|
+
np.mean(np.abs(K1[:2, :2])) + np.mean(np.abs(K2[:2, :2]))
|
|
83
|
+
)
|
|
84
|
+
R_est, t_est, _ = estimate_pose_cv2_ransac(
|
|
85
|
+
kpts1,
|
|
86
|
+
kpts2,
|
|
87
|
+
K1,
|
|
88
|
+
K2,
|
|
89
|
+
norm_threshold,
|
|
90
|
+
conf=0.99999,
|
|
91
|
+
)
|
|
92
|
+
e_t, e_R = compute_pose_error(R_est, t_est[:, 0], R, t)
|
|
93
|
+
e_pose = max(e_t, e_R)
|
|
94
|
+
except Exception as e:
|
|
95
|
+
logger.debug(f"Pose estimation error: {e}")
|
|
96
|
+
e_t, e_R = 90, 90
|
|
97
|
+
e_pose = max(e_t, e_R)
|
|
98
|
+
tot_e_t.append(e_t)
|
|
99
|
+
tot_e_R.append(e_R)
|
|
100
|
+
tot_e_pose.append(e_pose)
|
|
101
|
+
|
|
102
|
+
pbar.set_postfix(
|
|
103
|
+
auc=f"{[f'{a.item():.3f}' for a in pose_auc(tot_e_pose, thresholds)]}"
|
|
104
|
+
)
|
|
105
|
+
tot_e_pose = np.array(tot_e_pose)
|
|
106
|
+
auc = pose_auc(tot_e_pose, thresholds)
|
|
107
|
+
acc_5 = (tot_e_pose < 5).mean()
|
|
108
|
+
acc_10 = (tot_e_pose < 10).mean()
|
|
109
|
+
acc_15 = (tot_e_pose < 15).mean()
|
|
110
|
+
acc_20 = (tot_e_pose < 20).mean()
|
|
111
|
+
map_5 = acc_5
|
|
112
|
+
map_10 = np.mean([acc_5, acc_10])
|
|
113
|
+
map_20 = np.mean([acc_5, acc_10, acc_15, acc_20])
|
|
114
|
+
logger.info("%s auc: %s", model.name, auc)
|
|
115
|
+
return {
|
|
116
|
+
"auc_5": auc[0],
|
|
117
|
+
"auc_10": auc[1],
|
|
118
|
+
"auc_20": auc[2],
|
|
119
|
+
"map_5": map_5,
|
|
120
|
+
"map_10": map_10,
|
|
121
|
+
"map_20": map_20,
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
class Mega1500(MegaDepthPoseEstimationBenchmark):
|
|
126
|
+
def _post_init(self):
|
|
127
|
+
self.scene_names = [
|
|
128
|
+
"0015_0.1_0.3.npz",
|
|
129
|
+
"0015_0.3_0.5.npz",
|
|
130
|
+
"0022_0.1_0.3.npz",
|
|
131
|
+
"0022_0.3_0.5.npz",
|
|
132
|
+
"0022_0.5_0.7.npz",
|
|
133
|
+
]
|
|
134
|
+
self.benchmark_name = "Mega1500"
|
|
135
|
+
self.model = "essential"
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
class Mega1500_F(MegaDepthPoseEstimationBenchmark):
|
|
139
|
+
def _post_init(self):
|
|
140
|
+
self.scene_names = [
|
|
141
|
+
"0015_0.1_0.3.npz",
|
|
142
|
+
"0015_0.3_0.5.npz",
|
|
143
|
+
"0022_0.1_0.3.npz",
|
|
144
|
+
"0022_0.3_0.5.npz",
|
|
145
|
+
"0022_0.5_0.7.npz",
|
|
146
|
+
]
|
|
147
|
+
# self.benchmark_name = "Mega1500_F"
|
|
148
|
+
self.model = "fundamental"
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
class MegaIMCPT(MegaDepthPoseEstimationBenchmark):
|
|
152
|
+
def _post_init(self):
|
|
153
|
+
self.scene_names = [
|
|
154
|
+
"mega_8_scenes_0008_0.1_0.3.npz",
|
|
155
|
+
"mega_8_scenes_0008_0.3_0.5.npz",
|
|
156
|
+
"mega_8_scenes_0019_0.1_0.3.npz",
|
|
157
|
+
"mega_8_scenes_0019_0.3_0.5.npz",
|
|
158
|
+
"mega_8_scenes_0021_0.1_0.3.npz",
|
|
159
|
+
"mega_8_scenes_0021_0.3_0.5.npz",
|
|
160
|
+
"mega_8_scenes_0024_0.1_0.3.npz",
|
|
161
|
+
"mega_8_scenes_0024_0.3_0.5.npz",
|
|
162
|
+
"mega_8_scenes_0025_0.1_0.3.npz",
|
|
163
|
+
"mega_8_scenes_0025_0.3_0.5.npz",
|
|
164
|
+
"mega_8_scenes_0032_0.1_0.3.npz",
|
|
165
|
+
"mega_8_scenes_0032_0.3_0.5.npz",
|
|
166
|
+
"mega_8_scenes_0063_0.1_0.3.npz",
|
|
167
|
+
"mega_8_scenes_0063_0.3_0.5.npz",
|
|
168
|
+
"mega_8_scenes_1589_0.1_0.3.npz",
|
|
169
|
+
"mega_8_scenes_1589_0.3_0.5.npz",
|
|
170
|
+
]
|
|
171
|
+
# self.benchmark_name = "MegaIMCPT"
|
|
172
|
+
self.model = "essential"
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
class MegaIMCPT_F(MegaDepthPoseEstimationBenchmark):
|
|
176
|
+
def _post_init(self):
|
|
177
|
+
self.scene_names = [
|
|
178
|
+
"mega_8_scenes_0008_0.1_0.3.npz",
|
|
179
|
+
"mega_8_scenes_0008_0.3_0.5.npz",
|
|
180
|
+
"mega_8_scenes_0019_0.1_0.3.npz",
|
|
181
|
+
"mega_8_scenes_0019_0.3_0.5.npz",
|
|
182
|
+
"mega_8_scenes_0021_0.1_0.3.npz",
|
|
183
|
+
"mega_8_scenes_0021_0.3_0.5.npz",
|
|
184
|
+
"mega_8_scenes_0024_0.1_0.3.npz",
|
|
185
|
+
"mega_8_scenes_0024_0.3_0.5.npz",
|
|
186
|
+
"mega_8_scenes_0025_0.1_0.3.npz",
|
|
187
|
+
"mega_8_scenes_0025_0.3_0.5.npz",
|
|
188
|
+
"mega_8_scenes_0032_0.1_0.3.npz",
|
|
189
|
+
"mega_8_scenes_0032_0.3_0.5.npz",
|
|
190
|
+
"mega_8_scenes_0063_0.1_0.3.npz",
|
|
191
|
+
"mega_8_scenes_0063_0.3_0.5.npz",
|
|
192
|
+
"mega_8_scenes_1589_0.1_0.3.npz",
|
|
193
|
+
"mega_8_scenes_1589_0.3_0.5.npz",
|
|
194
|
+
]
|
|
195
|
+
# self.benchmark_name = "MegaIMCPT_F"
|
|
196
|
+
self.model = "fundamental"
|