NikolausDemmel / rootba

Square Root Bundle Adjustment for Large-Scale Reconstruction
BSD 3-Clause "New" or "Revised" License
287 stars 38 forks source link

Why inverse the coordinate to add pertubation #8

Closed BayRanger closed 2 years ago

BayRanger commented 2 years ago

Hi Nikolaus,

In the code file bal_problem.cpp, there is a inversion transformation to add perturbation, so as to add noise in camera 2 world coordinate I think, My question is that is it necessary to do the transformation? What is the motivation to do this step?

Bests

Reference code

if (rotation_sigma > 0 || translation_sigma > 0) {
    for (auto& cam : cameras_) {
      // perturb camera center in world coordinates
      if (translation_sigma > 0) {
        SE3 T_w_c = cam.T_c_w.inverse();
        T_w_c.translation() += perturbation<Scalar, 3>(translation_sigma, eng);
        cam.T_c_w = T_w_c.inverse();
      }
      // local rotation perturbation in camera frame
      if (rotation_sigma > 0) {
        cam.T_c_w.so3() =
            SO3::exp(perturbation<Scalar, 3>(rotation_sigma, eng)) *
            cam.T_c_w.so3();
      }
    }
  }
NikolausDemmel commented 2 years ago

IIRC it's just to literally do what the documentation says, i.e. perturb the position of the camera.

But you are right, we could also perturb the translation of T_c_w directly. Compared to perturbing the translation T_w_c there would be a rotation of the noise (and also negation). Since the noise is (almost) isotropic, it should not make a significant difference IMHO.

BayRanger commented 2 years ago

Thank you for your explaination, still, this inversion operation makes the code look more precise, because we should add noise in the camera coordinate.