ds_msp.core¶
The CameraModel protocol and the shared data conventions (Points3D, Pixels, Rays,
Valid, Params) every other module exchanges. Dependency-free (numpy + typing only) — the
bottom of the package's dependency graph.
ds_msp.core.contracts ¶
Core contracts for the multi-model camera library.
This module is the single source of truth for the interface every camera
model implements and the data conventions every module exchanges. It is
deliberately dependency-free (numpy + typing only) so it sits at the bottom of
the dependency graph: core knows nothing about concrete models, services, or
I/O. Everything else depends on this; this depends on nothing internal.
Data conventions (the "wire format" between modules)
==================== ============ ========= ==========================================
Name Shape dtype Meaning / convention
==================== ============ ========= ==========================================
Points3D (N, 3) float64 camera-frame points, meters, +Z forward
Pixels (N, 2) float64 (u, v), pixel centers, origin top-left
Rays (N, 3) float64 unit-norm bearing vectors
Valid (N,) bool per-point projectability / feasibility mask
Params (P,) float64 model parameters in param_names order
J_point (N, 2, 3) float64 d(u, v) / d(x, y, z)
J_param (N, 2, P) float64 d(u, v) / d(params)
==================== ============ ========= ==========================================
Additional rules:
- Leading batch dimensions are preserved: (..., 3) / (..., 2) are accepted.
- Invalid rows are zeroed, never NaN, so masks compose without poisoning arithmetic.
- Parameter vectors are always produced/consumed in param_names order.
CameraModel ¶
Bases: Protocol
Structural interface every camera model satisfies.
Models satisfy this by shape (duck typing) — they need not inherit from
it — which keeps concrete models decoupled from core at runtime while
static checkers still verify conformance. Services and the converter accept
CameraModel and therefore work with any model interchangeably.
Source code in ds_msp/core/contracts.py
distortion
property
¶
Model-specific distortion tail (the params after fx,fy,cx,cy).
from_dict
classmethod
¶
from_params
classmethod
¶
initialize_from_correspondences ¶
Seed parameters (closed-form/linear) from ray<->pixel correspondences.
param_bounds
classmethod
¶
project ¶
project_jacobian ¶
Return (uv, J_point, J_param, valid) with analytic derivatives.
J_point is (N,2,3) = d(u,v)/d(x,y,z);
J_param is (N,2,P) = d(u,v)/d(params).