11"""Epipolar geometry."""
2- from dataclasses import dataclass , field
3- from typing import List
2+ from typing import List , Tuple
43
54import numpy as np
5+ from numba import float64 , int32 , njit
6+ from numba .experimental import jitclass
67
78from .calibration import Calibration
89from .constants import PT_UNUSED
1213from .ray_tracing import ray_tracing
1314from .trafo import dist_to_flat , metric_to_pixel , pixel_to_metric
1415
16+ spec = [
17+ ('pnr' , int32 ),
18+ ('tol' , float64 ),
19+ ('corr' , float64 ),
20+ ]
1521
16- @dataclass
22+ @jitclass ( spec )
1723class Candidate :
1824 """Candidate point in the second image."""
1925
@@ -22,10 +28,16 @@ def __init__(self, pnr=PT_UNUSED, tol=0.0, corr=0.0):
2228 self .tol = tol
2329 self .corr = corr
2430
25- def __repr__ (self ):
26- return f"Candidate(pnr={ self .pnr } , tol={ self .tol } , corr={ self .corr } )"
31+ # def __repr__(self):
32+ # return f"Candidate(pnr={self.pnr}, tol={self.tol}, corr={self.corr})"
2733
34+ spec = [
35+ ('pnr' , int32 ),
36+ ('x' , float64 ),
37+ ('y' , float64 ),
38+ ]
2839
40+ @jitclass (spec )
2941class Coord2d :
3042 """2D coordinates in the image space."""
3143
@@ -34,31 +46,38 @@ def __init__(self, pnr=PT_UNUSED, x=0.0, y=0.0):
3446 self .x = x
3547 self .y = y
3648
37- def __repr__ (self ):
38- return f"Coord2d(pnr={ self .pnr } , x={ self .x } , y={ self .y } )"
39-
49+ # def __repr__(self):
50+ # return f"Coord2d(pnr={self.pnr}, x={self.x}, y={self.y})"
4051
52+ @njit
4153def sort_coord2d_x (crd : List [Coord2d ]) -> List [Coord2d ]:
4254 """Quicksort for coordinates by x ."""
4355 return sorted (crd , key = lambda p : p .x )
4456
45-
57+ @ njit
4658def sort_coord2d_y (crd : List [Coord2d ]) -> List [Coord2d ]:
4759 """Sort coordinates by y."""
4860 return sorted (crd , key = lambda p : p .y )
4961
62+ spec = [
63+ ('pnr' , int32 ),
64+ ('x' , float64 ),
65+ ('y' , float64 ),
66+ ('z' , float64 ),
67+ ]
5068
51- @dataclass
69+ @jitclass ( spec )
5270class Coord3d :
53- """3D coordinates in the object space."""
71+ """2D coordinates in the image space."""
5472
55- pnr : int = field (default = PT_UNUSED )
56- x : float = field (default = 0.0 )
57- y : float = field (default = 0.0 )
58- z : float = field (default = 0.0 )
73+ def __init__ (self , pnr = PT_UNUSED , x = 0.0 , y = 0.0 , z = 0.0 ):
74+ self .pnr = pnr
75+ self .x = x
76+ self .y = y
77+ self .z = z
5978
6079
61- def epi_mm (xl , yl , cal1 , cal2 , mmp , vpar ) -> tuple [float , float , float , float ]:
80+ def epi_mm (xl , yl , cal1 , cal2 , mmp , vpar ) -> Tuple [float , float , float , float ]:
6281 """Return the end points of the epipolar line in the "second" camera.
6382
6483 /* epi_mm() takes a point in images space of one camera, positions of this
0 commit comments