Questions on state vector in bundle_adjuster.cc

39 views
Skip to first unread message

Grace

unread,
Jul 16, 2016, 12:12:19 AM7/16/16
to Ceres Solver
Hi,

I am new to ceres solver.
Would like to understand more in the example bundle_adjuster.cc.

Based on general understanding, each residual is a function of variables. 
One row in the Jacobian matrix, is partial derivative of the residual function with respect to a variable in the state vector.
For example, the state vector is [3d_point_1 3d_point_2 ....  3d_point_n camera_position_1 camera_position_2 .....camera_pose_F ]

Question 1;
How does ceres solver includes the state vector which generally determines the partial derivatives in the Jacobian.

From the following codes in bundle_adjuster.cc. (problem->AddResidualBlock)
(i) The same 3D point is added several times in the loop. (as different camera poses could see the same 3D point)
(ii) Also the same camera pose is added many times (as each camera pose see many 3D points)

Question 2:
How does Ceres solver manages the optimization of the same variable [3d_point_1 3d_point_2 ....  3d_point_n camera_position_1 camera_position_2 .....camera_pose_F ]

 for (int i = 0; i < bal_problem->num_observations(); ++i) 
{
....
if (FLAGS_use_quaternions) {
      // When using quaternions, we split the camera into two
      // parameter blocks. One of size 4 for the quaternion and the
      // other of size 6 containing the translation, focal length and
      // the radial distortion parameters.
      problem->AddResidualBlock(cost_function,
                                loss_function,
                                camera,
                                camera + 4,
                                point);
    } else {
      problem->AddResidualBlock(cost_function, loss_function, camera, point);
}

Thank you.

Sameer Agarwal

unread,
Jul 18, 2016, 9:45:44 AM7/18/16
to ceres-...@googlegroups.com
Grace,
My replies are inline.

On Fri, Jul 15, 2016 at 9:12 PM Grace <ethca...@gmail.com> wrote:
Hi,

I am new to ceres solver.
Would like to understand more in the example bundle_adjuster.cc.

Based on general understanding, each residual is a function of variables. 
One row in the Jacobian matrix, is partial derivative of the residual function with respect to a variable in the state vector.

This is correct.
 
For example, the state vector is [3d_point_1 3d_point_2 ....  3d_point_n camera_position_1 camera_position_2 .....camera_pose_F ]

Question 1;
How does ceres solver includes the state vector which generally determines the partial derivatives in the Jacobian.

From the following codes in bundle_adjuster.cc. (problem->AddResidualBlock)
(i) The same 3D point is added several times in the loop. (as different camera poses could see the same 3D point)
(ii) Also the same camera pose is added many times (as each camera pose see many 3D points)

We make an internal copy of all the variables into a single vector and work with it. This is not visible to the user. We also detect when different residual blocks use the same parameter block, say two residuals with the same 3d point by looking at the pointer you pass in.

Question 2:
How does Ceres solver manages the optimization of the same variable [3d_point_1 3d_point_2 ....  3d_point_n camera_position_1 camera_position_2 .....camera_pose_F ]

I am not sure what your question is here, or what the following code fragment has to do with it.

Sameer
 

 for (int i = 0; i < bal_problem->num_observations(); ++i) 
{
....
if (FLAGS_use_quaternions) {
      // When using quaternions, we split the camera into two
      // parameter blocks. One of size 4 for the quaternion and the
      // other of size 6 containing the translation, focal length and
      // the radial distortion parameters.
      problem->AddResidualBlock(cost_function,
                                loss_function,
                                camera,
                                camera + 4,
                                point);
    } else {
      problem->AddResidualBlock(cost_function, loss_function, camera, point);
}

Thank you.

--
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/61975fb9-beb1-42f5-a041-90734278ae25%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages