| 12345678910111213141516171819202122232425262728293031 |
- """Thin wrapper around ``keypoints_on_match_image`` with cached correspondence."""
- from __future__ import annotations
- import sys
- from pathlib import Path
- _IMG_MATCH_DIR = Path(__file__).resolve().parent
- _REPO_ROOT = _IMG_MATCH_DIR.parent
- for _p in (_REPO_ROOT, _IMG_MATCH_DIR):
- if str(_p) not in sys.path:
- sys.path.insert(0, str(_p))
- import numpy as np
- from keypoints_on_match_image import gather_correspondence
- class KeypointsMatching:
- def __init__(self, keypoints_obj):
- self.keypoints_obj = keypoints_obj
- self._correspondence: dict | None = None
- def correspondence(self) -> dict:
- if self._correspondence is None:
- self._correspondence = gather_correspondence(self.keypoints_obj)
- return self._correspondence
- def get_keypoints(self) -> np.ndarray:
- xy = self.correspondence()["matched_keypoints_original_xy"]
- return np.asarray(xy, dtype=np.float64)
|