Absolute bundle adjustment with GPS is very slow

已查看 366 次
跳至第一个未读帖子

San Jiang

未读,
2016年6月21日 06:00:242016/6/21
收件人 Ceres Solver
Hi,
  thanks for releasing the usefull library. Recently, I have tried to integrate ceres into an existed sfm workflow and added position constrains for each image with help of GPS information, just like the cost function in  following topic.  however, the difference is that my workflow can be divided into tow steps:
    1) relative sfm without GPS information. In this step, the first image' pose is identify and translation is zero. and only reprojection residuals are considered.
    2) absolute sfm with GPS information. In this step, the extra residual blocks are added besides the reprojection residual, which estmate the offset between image position and GPS position.

according to these two step, I could successfully do bundle adjustment in step one. But very slow iteration speed has been identified as following and termination status is no convergent!
Then, anyone could provide some tips on how to accelate this iteration.

Thanks! any help is highly appreciated!

San Jiang.


===============================================================================================
https://groups.google.com/forum/#!starred/ceres-solver/-Cq37gjICL0

        bool operator()(const T* const qvec, const T* const tvec,
            T* residuals) const {
            // Calculate pose center.
            //const Eigen::Quaternion<T> quat(qvec[0], qvec[1], qvec[2], qvec[3]);
            //Eigen::Matrix<T, 3, 1> tran(tvec[0], tvec[1], tvec[2]);
            //Eigen::Matrix<T, 3, 1> imgC = quat * -tran;

            //residuals[0] = imgC[0] - T(gpsC_(0));
            //residuals[1] = imgC[1] - T(gpsC_(1));
            //residuals[2] = imgC[2] - T(gpsC_(2));

            residuals[0] = tvec[0] - T(gpsC_(0));
            residuals[1] = tvec[1] - T(gpsC_(1));
            residuals[2] = tvec[2] - T(gpsC_(2));

            if (weight_ > 0.0)
            {
                residuals[0] *= T(weight_);
                residuals[1] *= T(weight_);
                residuals[2] *= T(weight_);
            }

            return true;
        }
===============================================================================================

==============================================================================
Absolute bundle adjustment
==============================================================================

iter      cost      cost_change  |gradient|   |step|    tr_ratio  tr_radius  ls_iter  iter_time  total_time
   0  2.502760e+007    0.00e+000    2.06e+005   0.00e+000   0.00e+000  1.00e+004        0    6.12e-001    4.32e+000
   1  2.502713e+007    4.69e+002    2.62e+003   1.60e-002   1.00e+000  3.00e+004        1    2.80e+000    7.12e+000
   2  2.502713e+007    3.63e+000    4.20e+002   2.31e-002   1.00e+000  9.00e+004        1    1.42e+000    8.54e+000
   3  2.502712e+007    6.49e+000    1.58e+003   6.25e-002   1.00e+000  2.70e+005        1    1.39e+000    9.93e+000
   4  2.502711e+007    1.45e+001    3.14e+003   1.85e-001   1.00e+000  8.10e+005        1    1.29e+000    1.12e+001
   5  2.502707e+007    4.04e+001    1.50e+004   5.71e-001   9.97e-001  2.43e+006        1    1.44e+000    1.27e+001
   6  2.502696e+007    1.12e+002    1.33e+005   1.73e+000   9.20e-001  5.96e+006        1    1.39e+000    1.40e+001
   7  2.502696e+007   -4.67e+001    0.00e+000   4.25e+000  -1.52e-001  2.98e+006        1    7.97e-001    1.48e+001
   8  2.502682e+007    1.36e+002    2.01e+005   2.13e+000   8.60e-001  4.76e+006        1    1.36e+000    1.62e+001
   9  2.502670e+007    1.16e+002    5.12e+005   3.40e+000   4.46e-001  4.76e+006        1    1.40e+000    1.76e+001
  10  2.502647e+007    2.38e+002    5.10e+005   3.39e+000   6.26e-001  4.83e+006        1    1.32e+000    1.89e+001
  11  2.502623e+007    2.32e+002    5.25e+005   3.45e+000   6.06e-001  4.88e+006        1    1.24e+000    2.02e+001
  12  2.502600e+007    2.38e+002    5.33e+005   3.48e+000   6.04e-001  4.92e+006        1    1.25e+000    2.14e+001
  13  2.502576e+007    2.40e+002    5.41e+005   3.51e+000   5.99e-001  4.96e+006        1    1.28e+000    2.27e+001
  14  2.502551e+007    2.43e+002    5.48e+005   3.54e+000   5.96e-001  5.00e+006        1    1.27e+000    2.40e+001
  15  2.502527e+007    2.45e+002    5.54e+005   3.57e+000   5.93e-001  5.03e+006        1    1.28e+000    2.52e+001
  16  2.502502e+007    2.47e+002    5.59e+005   3.59e+000   5.90e-001  5.06e+006        1    1.28e+000    2.65e+001
  17  2.502477e+007    2.49e+002    5.63e+005   3.61e+000   5.88e-001  5.09e+006        1    1.27e+000    2.78e+001
  18  2.502452e+007    2.51e+002    5.67e+005   3.63e+000   5.86e-001  5.12e+006        1    1.31e+000    2.91e+001
  19  2.502427e+007    2.52e+002    5.70e+005   3.65e+000   5.85e-001  5.14e+006        1    1.23e+000    3.03e+001
  20  2.502401e+007    2.54e+002    5.73e+005   3.67e+000   5.83e-001  5.16e+006        1    1.27e+000    3.16e+001
  21  2.502376e+007    2.55e+002    5.76e+005   3.68e+000   5.82e-001  5.19e+006        1    1.28e+000    3.29e+001
  22  2.502350e+007    2.56e+002    5.78e+005   3.70e+000   5.82e-001  5.21e+006        1    1.29e+000    3.42e+001
  23  2.502324e+007    2.58e+002    5.80e+005   3.72e+000   5.81e-001  5.23e+006        1    1.29e+000    3.55e+001
  24  2.502299e+007    2.59e+002    5.81e+005   3.73e+000   5.80e-001  5.25e+006        1    1.27e+000    3.67e+001
  25  2.502273e+007    2.60e+002    5.83e+005   3.75e+000   5.80e-001  5.28e+006        1    1.28e+000    3.80e+001
  26  2.502246e+007    2.61e+002    5.84e+005   3.76e+000   5.80e-001  5.30e+006        1    1.29e+000    3.93e+001
  27  2.502220e+007    2.62e+002    5.85e+005   3.78e+000   5.80e-001  5.32e+006        1    1.28e+000    4.06e+001
  28  2.502194e+007    2.63e+002    5.85e+005   3.79e+000   5.80e-001  5.34e+006        1    1.25e+000    4.18e+001
  29  2.502167e+007    2.65e+002    5.86e+005   3.81e+000   5.80e-001  5.36e+006        1    1.28e+000    4.31e+001
  30  2.502141e+007    2.66e+002    5.86e+005   3.82e+000   5.80e-001  5.38e+006        1    1.26e+000    4.44e+001
  31  2.502114e+007    2.67e+002    5.86e+005   3.84e+000   5.80e-001  5.41e+006        1    1.28e+000    4.57e+001
  32  2.502087e+007    2.68e+002    5.86e+005   3.85e+000   5.81e-001  5.43e+006        1    1.27e+000    4.69e+001
  33  2.502060e+007    2.69e+002    5.86e+005   3.87e+000   5.81e-001  5.45e+006        1    1.28e+000    4.82e+001
  34  2.502033e+007    2.70e+002    5.86e+005   3.89e+000   5.82e-001  5.48e+006        1    1.24e+000    4.95e+001
  35  2.502006e+007    2.72e+002    5.86e+005   3.90e+000   5.83e-001  5.50e+006        1    1.28e+000    5.07e+001
  36  2.501979e+007    2.73e+002    5.85e+005   3.92e+000   5.83e-001  5.53e+006        1    1.23e+000    5.20e+001
  37  2.501952e+007    2.74e+002    5.84e+005   3.94e+000   5.84e-001  5.55e+006        1    1.27e+000    5.32e+001
  38  2.501924e+007    2.75e+002    5.84e+005   3.96e+000   5.85e-001  5.58e+006        1    1.47e+000    5.47e+001
  39  2.501896e+007    2.77e+002    5.83e+005   3.98e+000   5.86e-001  5.61e+006        1    1.61e+000    5.63e+001
  40  2.501869e+007    2.78e+002    5.82e+005   4.00e+000   5.87e-001  5.64e+006        1    1.42e+000    5.77e+001
  41  2.501841e+007    2.80e+002    5.81e+005   4.02e+000   5.88e-001  5.67e+006        1    1.30e+000    5.90e+001
  42  2.501812e+007    2.81e+002    5.79e+005   4.04e+000   5.90e-001  5.70e+006        1    1.37e+000    6.04e+001
  43  2.501784e+007    2.83e+002    5.79e+005   4.07e+000   5.91e-001  5.74e+006        1    1.44e+000    6.18e+001
  44  2.501756e+007    2.85e+002    5.79e+005   4.09e+000   5.92e-001  5.78e+006        1    1.42e+000    6.33e+001
  45  2.501727e+007    2.86e+002    5.79e+005   4.12e+000   5.94e-001  5.81e+006        1    1.29e+000    6.46e+001
  46  2.501698e+007    2.88e+002    5.79e+005   4.15e+000   5.95e-001  5.85e+006        1    1.29e+000    6.58e+001
  47  2.501669e+007    2.90e+002    5.79e+005   4.18e+000   5.97e-001  5.90e+006        1    1.28e+000    6.71e+001
  48  2.501640e+007    2.92e+002    5.79e+005   4.21e+000   5.98e-001  5.94e+006        1    1.29e+000    6.84e+001
  49  2.501610e+007    2.95e+002    5.79e+005   4.24e+000   6.00e-001  5.99e+006        1    1.27e+000    6.97e+001
  50  2.501581e+007    2.97e+002    5.79e+005   4.27e+000   6.02e-001  6.04e+006        1    1.28e+000    7.10e+001
  51  2.501551e+007    2.99e+002    5.79e+005   4.31e+000   6.04e-001  6.09e+006        1    1.29e+000    7.23e+001
  52  2.501521e+007    3.02e+002    5.79e+005   4.35e+000   6.05e-001  6.15e+006        1    1.29e+000    7.36e+001
……………………………………
 491  2.487564e+007    4.68e+002    7.55e+005   7.07e+000   5.60e-001  6.13e+006        1    1.37e+000    6.56e+002
 492  2.487517e+007    4.70e+002    7.55e+005   7.09e+000   5.60e-001  6.14e+006        1    1.34e+000    6.57e+002
 493  2.487470e+007    4.71e+002    7.56e+005   7.11e+000   5.60e-001  6.15e+006        1    1.39e+000    6.58e+002
 494  2.487422e+007    4.72e+002    7.56e+005   7.12e+000   5.60e-001  6.16e+006        1    1.31e+000    6.60e+002
 495  2.487375e+007    4.73e+002    7.57e+005   7.14e+000   5.60e-001  6.17e+006        1    1.31e+000    6.61e+002
 496  2.487328e+007    4.75e+002    7.57e+005   7.16e+000   5.60e-001  6.19e+006        1    1.32e+000    6.62e+002
 497  2.487280e+007    4.76e+002    7.58e+005   7.18e+000   5.60e-001  6.20e+006        1    1.29e+000    6.64e+002
 498  2.487232e+007    4.77e+002    7.58e+005   7.20e+000   5.60e-001  6.21e+006        1    1.30e+000    6.65e+002
 499  2.487184e+007    4.78e+002    7.59e+005   7.22e+000   5.60e-001  6.22e+006        1    1.30e+000    6.66e+002
 500  2.487136e+007    4.80e+002    7.59e+005   7.24e+000   5.60e-001  6.23e+006        1    1.31e+000    6.68e+002


Absolute Bundle Adjustment Report
---------------------------------
    Residuals : 1591579
   Parameters : 521610
   Iterations : 500
         Time : 667.579107 [s]
 Initial cost : 3.965478 [px]
   Final cost : 3.953081 [px]
  Termination : No convergence

Sameer Agarwal

未读,
2016年6月21日 08:19:432016/6/21
收件人 ceres-...@googlegroups.com
San,
My comments are inline.

    1) relative sfm without GPS information. In this step, the first image' pose is identify and translation is zero. and only reprojection residuals are considered.
    2) absolute sfm with GPS information. In this step, the extra residual blocks are added besides the reprojection residual, which estmate the offset between image position and GPS position.

according to these two step, I could successfully do bundle adjustment in step one. But very slow iteration speed has been identified as following and termination status is no convergent!
Then, anyone could provide some tips on how to accelate this iteration.

I believe the problem here is that the absolute pose constraints that you have added to the problem work as regularizers, preventing your images from moving too much. Which will naturally slow the convergence down.

But I have a question for you. When you did the relative sfm with no gps information, your sfm reconstruction will have a translation, rotation and scale ambiguity. I imagine you did a similarity transform from your relative reconstruction to the gps locations of the cameras.

my guess is that the positions of the cameras do not match the gps positions well. It would be a good idea to see what the starting residuals for your image position term are.  If they are large then you either have to do some outlier pruning, or anneal the terms which enforce the gps positions, by starting with a small weight, optimizing, increasing the weight and optimizing again.

Sameer


--
You received this message because you are subscribed to the Google Groups "Ceres Solver" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ceres-solver...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ceres-solver/fd91515f-3243-4b68-84cd-acd2f762378f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

William Rucklidge

未读,
2016年6月21日 12:13:582016/6/21
收件人 ceres-...@googlegroups.com
Depending on your coordinate frame, you may want to consider doing some manual preconditioning of the GPS positions, by changing the values Ceres is adjusting from being absolute positions to relative positions.

More detail: If your positions are in ECEF, then their absolute magnitudes are going to be roughly 6e6 (radius of the Earth). The other parameters you adjust are likely to have much smaller magnitudes - for example, rotation quaternion components are always in [-1, 1]. Consider using the original GPS positions as a base, and have Ceres adjust corrections to that base. That is (in pseudocode; in reality this would be >1 cost functor):
MyCostFunctor(const double* absolute_position, const double* rotation_quaternion, double* residuals) {
   current_pose = Pose(absolute_position, rotation_quaternion);
   ... compute reprojection residuals based on current_pose ...
   pose_error = absolute_position - GPS_position
   ... add terms to residuals based on pose_error
}
you'd do
MyCostFunctor(const double* position_correction, const double* rotation_quaternion, double* residuals) {
   current_pose = Pose(GPS_position + position_correction, rotation_quaternion);
   ... compute reprojection residuals based on current_pose ...
   ... add terms to residuals based on position_correction
}
The values in the position_correction vector will be much smaller than the values in absolute_position would have been.

If your coordinate system isn't ECEF then this may not be a concern for you.

-wjr


San Jiang

未读,
2016年6月22日 20:04:142016/6/22
收件人 Ceres Solver
Sameer,
   thanks for providing some useful advises. After checking the similarity transformation from relative orientation to coarse absolute orientation, I found that some mistakes in this process. Now, the bundle adjustment process could be convergent to rational value as following.

已删除帖子

San Jiang

未读,
2016年6月22日 20:36:072016/6/22
收件人 Ceres Solver
iter      cost      cost_change  |gradient|   |step|    tr_ratio  tr_radius  ls_iter  iter_time  total_time
   0  4.027004e+005    0.00e+000    1.89e+003   0.00e+000   0.00e+000  1.00e+004        0    6.22e-001    4.52e+000
   1  4.022521e+005    4.48e+002    2.60e+001   2.43e+000   1.00e+000  3.00e+004        1    2.65e+000    7.18e+000
   2  4.022483e+005    3.81e+000    1.91e+000   3.85e+000   1.00e+000  9.00e+004        1    1.31e+000    8.49e+000
   3  4.022433e+005    5.02e+000    3.99e+000   6.90e+000   1.00e+000  2.70e+005        1    1.25e+000    9.73e+000
   4  4.022384e+005    4.84e+000    5.20e+000   9.11e+000   1.00e+000  8.10e+005        1    1.27e+000    1.10e+001
   5  4.022366e+005    1.85e+000    1.04e+001   5.57e+000   1.00e+000  2.43e+006        1    1.41e+000    1.24e+001
   6  4.022363e+005    3.27e-001    6.75e+000   7.22e+000   1.00e+000  7.29e+006        1    1.29e+000    1.37e+001
   7  4.022361e+005    1.28e-001    2.26e+000   9.97e+000   1.00e+000  2.19e+007        1    1.27e+000    1.50e+001
   8  4.022361e+005    4.21e-002    1.94e+000   7.00e+000   1.00e+000  6.56e+007        1    1.29e+000    1.63e+001
   9  4.022361e+005    7.64e-003    2.19e+000   3.71e+000   9.97e-001  1.97e+008        1    1.27e+000    1.75e+001
  10  4.022361e+005    3.78e-003    3.77e+000   5.00e+000   9.60e-001  5.90e+008        1    1.37e+000    1.89e+001
  11  4.022361e+005    2.51e-003    5.39e+000   6.27e+000   8.65e-001  9.68e+008        1    1.34e+000    2.02e+001
  12  4.022361e+005    8.81e-004    1.86e+000   3.13e+000   9.71e-001  2.91e+009        1    1.27e+000    2.15e+001
  13  4.022361e+005    7.52e-005    1.86e+000   1.19e+000   9.89e-001  8.72e+009        1    1.34e+000    2.29e+001
  14  4.022361e+005    1.28e-006    1.90e+000   1.59e-001   9.95e-001  2.61e+010        1    1.29e+000    2.42e+001



Absolute Bundle Adjustment Report
---------------------------------
    Residuals : 1591757
   Parameters : 521745
   Iterations : 15
         Time : 25.546804 [s]
 Initial cost : 0.502982 [px]
   Final cost : 0.502692 [px]
  Termination : Convergence


Elapsed time: 19.15 [minutes]

San Jiang

未读,
2016年6月24日 09:27:072016/6/24
收件人 Ceres Solver
Hi, wjr
    Thanks for sharing your experience on gps assisted bundle adjustment. and I have test  bundle adjustment in ECEF coordinate system. However, the orientation bias is large between relative sfm and absolute sfm. then the convergence speed is also slow and even the termination state is NOT CONVERGENT.
    I think the preprocessing, like similairty transformation from relative sfm to absolute sfm  using image projection center and gps information, is necessary. However, three correspondings are needed for 3D similarity transformation. then, if only two images are to be processed, the similarity transformation is not possible. So, I would try to add gps constrains to the first bundle adjustment step. If you have some good ideal or information about how to construct the cost function, I would highly appreciated!

    San Jiang!

William Rucklidge

未读,
2016年6月24日 12:08:392016/6/24
收件人 ceres-...@googlegroups.com
One easy-to-miss pitfall of working in ECEF is that if any of your values ever pass through a variable of type "float", you're going to have a bad day. 24 bits of mantissa means a precision of about 1 in 16 million - for values in the 6 million range, your representation quantum is in the 10s of cm. This can badly mess up your calculations, especially the Jacobians. If everything in sight is a double (including any third party libraries), then you're fine.

The cost function you gave earlier seemed fine - apply a cost for any adjustment of the pose away from the GPS-provided initial position. As Sameer suggested, you should try a large range of weights for the GPS-related costs.

I'm not sure why you're doing this in two passes of SFM rather than a single pass. It seems to add complexity; what's the intended benefit?

-wjr

--
You received this message because you are subscribed to the Google Groups "Ceres Solver" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ceres-solver...@googlegroups.com.
回复全部
回复作者
转发
0 个新帖子