@@ -40,6 +40,19 @@ def setUpClass(cls):
4040 xi = 1
4141 cls .stereographic = gtsam .Cal3Unified (fx , fy , s , u0 , v0 , k1 , k2 , p1 , p2 , xi )
4242
43+ p1 = [- 1.0 , 0.0 , - 1.0 ]
44+ p2 = [ 1.0 , 0.0 , - 1.0 ]
45+ q1 = gtsam .Rot3 (1.0 , 0.0 , 0.0 , 0.0 )
46+ q2 = gtsam .Rot3 (1.0 , 0.0 , 0.0 , 0.0 )
47+ pose1 = gtsam .Pose3 (q1 , p1 )
48+ pose2 = gtsam .Pose3 (q2 , p2 )
49+ camera1 = gtsam .PinholeCameraCal3Unified (pose1 , cls .stereographic )
50+ camera2 = gtsam .PinholeCameraCal3Unified (pose2 , cls .stereographic )
51+ cls .origin = np .array ([0.0 , 0.0 , 0.0 ])
52+ cls .poses = gtsam .Pose3Vector ([pose1 , pose2 ])
53+ cls .cameras = gtsam .CameraSetCal3Unified ([camera1 , camera2 ])
54+ cls .measurements = gtsam .Point2Vector ([k .project (cls .origin ) for k in cls .cameras ])
55+
4356 def test_Cal3Unified (self ):
4457 K = gtsam .Cal3Unified ()
4558 self .assertEqual (K .fx (), 1. )
@@ -108,40 +121,17 @@ def test_sfm_factor2(self):
108121 @unittest .skip ("triangulatePoint3 currently seems to require perspective projections." )
109122 def test_triangulation (self ):
110123 """Estimate spatial point from image measurements"""
111- p1 = [- 1.0 , 0.0 , - 1.0 ]
112- p2 = [ 1.0 , 0.0 , - 1.0 ]
113- q1 = gtsam .Rot3 (1.0 , 0.0 , 0.0 , 0.0 )
114- q2 = gtsam .Rot3 (1.0 , 0.0 , 0.0 , 0.0 )
115- obj_point = np .array ([0.0 , 0.0 , 0.0 ])
116- pose1 = gtsam .Pose3 (q1 , p1 )
117- pose2 = gtsam .Pose3 (q2 , p2 )
118- camera1 = gtsam .PinholeCameraCal3Unified (pose1 , self .stereographic )
119- camera2 = gtsam .PinholeCameraCal3Unified (pose2 , self .stereographic )
120- cameras = gtsam .CameraSetCal3Unified ([camera1 , camera2 ])
121- measurements = gtsam .Point2Vector ([k .project (obj_point ) for k in cameras ])
122- triangulated = gtsam .triangulatePoint3 (cameras , measurements , rank_tol = 1e-9 , optimize = True )
124+ triangulated = gtsam .triangulatePoint3 (self .cameras , self .measurements , rank_tol = 1e-9 , optimize = True )
123125 self .gtsamAssertEquals (measurements [0 ], self .img_point )
124- self .gtsamAssertEquals (triangulated , obj_point )
126+ self .gtsamAssertEquals (triangulated , self . origin )
125127
126128 def test_triangulation_rectify (self ):
127129 """Estimate spatial point from image measurements using rectification"""
128- p1 = [- 1.0 , 0.0 , - 1.0 ]
129- p2 = [ 1.0 , 0.0 , - 1.0 ]
130- q1 = gtsam .Rot3 (1.0 , 0.0 , 0.0 , 0.0 )
131- q2 = gtsam .Rot3 (1.0 , 0.0 , 0.0 , 0.0 )
132- obj_point = np .array ([0.0 , 0.0 , 0.0 ])
133- pose1 = gtsam .Pose3 (q1 , p1 )
134- pose2 = gtsam .Pose3 (q2 , p2 )
135- camera1 = gtsam .PinholeCameraCal3Unified (pose1 , self .stereographic )
136- camera2 = gtsam .PinholeCameraCal3Unified (pose2 , self .stereographic )
137- cameras = gtsam .CameraSetCal3Unified ([camera1 , camera2 ])
138- measurements = gtsam .Point2Vector ([k .project (obj_point ) for k in cameras ])
139- rectified = gtsam .Point2Vector ([k .calibration ().calibrate (pt ) for k , pt in zip (cameras , measurements )])
130+ rectified = gtsam .Point2Vector ([k .calibration ().calibrate (pt ) for k , pt in zip (self .cameras , self .measurements )])
140131 shared_cal = gtsam .Cal3_S2 ()
141- poses = gtsam .Pose3Vector ([pose1 , pose2 ])
142- triangulated = gtsam .triangulatePoint3 (poses , shared_cal , rectified , rank_tol = 1e-9 , optimize = False )
132+ triangulated = gtsam .triangulatePoint3 (self .poses , shared_cal , rectified , rank_tol = 1e-9 , optimize = False )
143133 self .gtsamAssertEquals (measurements [0 ], self .img_point )
144- self .gtsamAssertEquals (triangulated , obj_point )
134+ self .gtsamAssertEquals (triangulated , self . origin )
145135
146136 def test_retract (self ):
147137 expected = gtsam .Cal3Unified (100 + 2 , 105 + 3 , 0.0 + 4 , 320 + 5 , 240 + 6 ,
0 commit comments