Hello,
I am trying to test bundle adjustment on synthetic data. I am using the bundle_adjuster example in Ceres.
I added a ground truth error metric. For the cameras, the average ground truth error is the distance between the correct camera position and the camera position after optimization. This applies to all cameras and is divided by the number of cameras. And for points, the average ground truth error is the distance between the correct point position and the point position after optimization. This applies to all points and is divided by the number of points.
First, I ran bundle_adjuster without adding any error to the scene.
The initial cost (reprojection error) is: 2.510083e-16
It is close to zero, so all is normal, since the scene is perfect at this point. The ground truth error for cameras and points is also close to zero.
Next, in bundle_adjuster.cc, I added perturbations to the problem
bal_problem.Normalize();
bal_problem.Perturb(0.05, 0.05, 0.05);
After these perturbations, I calculated the initial ground truth error as:
GROUND TRUTH INITIAL AVG CAMERA ERROR: 0.08
GROUND TRUTH INITIAL AVG POINT ERROR: 0.08
Then, I ran the command:
bin/bundle_adjuster --input=synthetic-data.txt --num_iterations=5
I get the output:
iter cost cost_change |gradient| |step| tr_ratio tr_radius ls_iter iter_time total_time
0 1.344274e+03 0.00e+00 4.60e+02 0.00e+00 0.00e+00 1.00e+04 0 4.52e-01 6.85e-01
1 2.519456e+01 1.32e+03 6.74e+01 1.52e+02 9.82e-01 3.00e+04 3 6.68e-01 1.35e+00
2 2.795099e-01 2.49e+01 6.63e+00 5.91e+01 9.91e-01 9.00e+04 7 7.28e-01 2.08e+00
3 3.181261e-03 2.76e-01 4.94e-01 3.25e+01 9.92e-01 2.70e+05 38 1.36e+00 3.44e+00
4 1.178155e-05 3.17e-03 4.45e-02 1.55e+01 9.98e-01 8.10e+05 95 2.53e+00 5.97e+00
5 5.716298e-09 1.18e-05 5.42e-04 1.72e+00 1.00e+00 2.43e+06 134 3.33e+00 9.30e+00
Solver Summary (v 2.0.0-eigen-(3.3.7)-no_lapack-eigensparse-no_openmp)
Original Reduced
Parameter blocks 23616 23616
Parameters 74304 74304
Residual blocks 338882 338882
Residuals 677764 677764
Minimizer TRUST_REGION
Trust region strategy LEVENBERG_MARQUARDT
Given Used
Linear solver ITERATIVE_SCHUR ITERATIVE_SCHUR
Preconditioner JACOBI JACOBI
Threads 1 1
Linear solver ordering 23040,576 23040,576
Schur structure 2,3,9 2,3,9
Cost:
Initial 1.344274e+03
Final 5.716298e-09
Change 1.344274e+03
Minimizer iterations 6
Successful steps 6
Unsuccessful steps 0
Time (in seconds):
Preprocessor 0.233319
Residual only evaluation 0.231133 (5)
Jacobian & residual evaluation 2.385698 (6)
Linear solver 6.186789 (5)
Minimizer 9.065083
Postprocessor 0.019331
Total 9.317733
Termination: NO_CONVERGENCE (Maximum number of iterations reached. Number of iterations: 5.)
The reprojection error is minimized to a low value. However, my ground truth error is:
GROUND TRUTH AVG CAMERA ERROR: 1.70
GROUND TRUTH AVG POINT ERROR: 0.47
So the ground truth error became worse after optimization. Is this normal behavior? Is there some option in Ceres I can tune so that the problem optimizes closer to the ground truth?