Files
gps-denied-onboard/src/gps_denied/schemas/vo.py
T

50 lines
1.3 KiB
Python

"""Sequential Visual Odometry schemas (Component F07)."""
from typing import Optional
import numpy as np
from pydantic import BaseModel
class Features(BaseModel):
"""Extracted image features (e.g., from SuperPoint)."""
model_config = {"arbitrary_types_allowed": True}
keypoints: np.ndarray # (N, 2)
descriptors: np.ndarray # (N, 256)
scores: np.ndarray # (N,)
class Matches(BaseModel):
"""Matches between two sets of features (e.g., from LightGlue)."""
model_config = {"arbitrary_types_allowed": True}
matches: np.ndarray # (M, 2)
scores: np.ndarray # (M,)
keypoints1: np.ndarray # (M, 2)
keypoints2: np.ndarray # (M, 2)
class RelativePose(BaseModel):
"""Relative pose between two frames."""
model_config = {"arbitrary_types_allowed": True}
translation: np.ndarray # (3,)
rotation: np.ndarray # (3, 3)
confidence: float
inlier_count: int
total_matches: int
tracking_good: bool
scale_ambiguous: bool = True
chunk_id: Optional[str] = None
class Motion(BaseModel):
"""Motion estimate from OpenCV."""
model_config = {"arbitrary_types_allowed": True}
translation: np.ndarray # (3,) unit vector
rotation: np.ndarray # (3, 3) rotation matrix
inliers: np.ndarray # Boolean mask of inliers
inlier_count: int