@@ -117,10 +117,10 @@ def build_factor_graph(method, num_cameras, measurements, cal):
117
117
# Add priors on calibrations if necessary
118
118
if method in ["Essential+Ks" , "Binary+Ks" ]:
119
119
for i in range (num_cameras ):
120
- model = gtsam .noiseModel .Isotropic .Sigma (1 , 10 .0 )
120
+ model = gtsam .noiseModel .Isotropic .Sigma (1 , 1000 .0 )
121
121
graph .addPriorCal3f (K (i ), cal , model )
122
122
elif method in ["Essential+K" , "Binary+K" ]:
123
- model = gtsam .noiseModel .Isotropic .Sigma (1 , 10 .0 )
123
+ model = gtsam .noiseModel .Isotropic .Sigma (1 , 1000 .0 )
124
124
graph .addPriorCal3f (K (0 ), cal , model )
125
125
126
126
z = measurements # shorthand
@@ -186,6 +186,8 @@ def get_initial_estimate(method, num_cameras, ground_truth, cal):
186
186
for a in range (num_cameras ):
187
187
b = (a + 1 ) % num_cameras
188
188
c = (a + 2 ) % num_cameras
189
+ # initialEstimate.insert(EdgeKey(a, b).key(), E1.retract(0.1 * np.ones((5, 1))))
190
+ # initialEstimate.insert(EdgeKey(a, c).key(), E2.retract(0.1 * np.ones((5, 1))))
189
191
initialEstimate .insert (EdgeKey (a , b ).key (), E1 )
190
192
initialEstimate .insert (EdgeKey (a , c ).key (), E2 )
191
193
total_dimension += E1 .dim () + E2 .dim ()
@@ -206,8 +208,9 @@ def get_initial_estimate(method, num_cameras, ground_truth, cal):
206
208
def optimize (graph , initialEstimate , method ):
207
209
"""optimize the graph"""
208
210
params = LevenbergMarquardtParams ()
209
- params .setlambdaInitial (1e10 ) # Initialize lambda to a high value
210
- params .setlambdaUpperBound (1e10 )
211
+ if method not in ["Calibrated" , "Binary+K" , "Binary+Ks" ]:
212
+ params .setlambdaInitial (1e10 ) # Initialize lambda to a high value
213
+ params .setlambdaUpperBound (1e10 )
211
214
# params.setAbsoluteErrorTol(0.1)
212
215
params .setVerbosityLM ("SUMMARY" )
213
216
optimizer = LevenbergMarquardtOptimizer (graph , initialEstimate , params )
@@ -373,6 +376,8 @@ def main():
373
376
374
377
# Compute final error
375
378
final_error = graph .error (result )
379
+ if method in ["Binary+K" , "Binary+Ks" ]:
380
+ final_error *= cal .f () * cal .f ()
376
381
377
382
# Store results
378
383
results [method ]["distances" ].extend (distances )
0 commit comments