isl-org / FastGlobalRegistration

Fast Global Registration
Other
511 stars 134 forks source link

Can not understand Jacobian Computation Process in function OptimizePairwise #19

Open YE-ck opened 5 years ago

YE-ck commented 5 years ago

hello, i read the paper Fast Global Registration, which uses Gauss-Newton method to optimize T by equation 8 at the Section3.2 image I find your calculation of the Jacobian as follows: `

int ii = corres[c].first; int jj = corres[c].second; Eigen::Vector3f p, q; p = pointcloud_[i][ii]; q = pcj_copy[jj]; Eigen::Vector3f rpq = p - q;

        int c2 = c;

        float temp = par / (rpq.dot(rpq) + par);
        s[c2] = temp * temp;
                    J.setZero();
        J(1) = -q(2);
        J(2) = q(1);
        J(3) = -1;
        r = rpq(0);
        JTJ += J * J.transpose() * s[c2];
        JTr += J * r * s[c2];
        r2 += r * r * s[c2];

        J.setZero();
        J(2) = -q(0);
        J(0) = q(2);
        J(4) = -1;
        r = rpq(1);
        JTJ += J * J.transpose() * s[c2];
        JTr += J * r * s[c2];
        r2 += r * r * s[c2];

        J.setZero();
        J(0) = -q(1);
        J(1) = q(0);
        J(5) = -1;
        r = rpq(2);
        JTJ += J * J.transpose() * s[c2];
        JTr += J * r * s[c2];
        r2 += r * r * s[c2];

        r2 += (par * (1.0 - sqrt(s[c2])) * (1.0 - sqrt(s[c2])));`

To have a better understanding, I tried to substitute lp,q (equation 6) into objective 3 E(T;L). image image Then I got: image Using chain rule: image So: image And I realize that this equation represents the following line in the code: s[c2] = temp * temp; As far as I am concerned, J(2) should be calculated as follows: image image image image • I see that your calculation of Jacobian is divided into three parts which are quite different from I expected before. Could you explain more about your codes of Jacobian calculation? Thanks, yechuankun

qianyizh commented 5 years ago

See this page for detailed derivation: http://redwood-data.org/indoor/registration.html

Basically you can only linearize the transformation matrix when alpha, beta, gamma, a, b, c are all very small values. So T cannot be directly linearized in this way. Instead, you need some trick to bring T*^{-1}T to the front and linearize it. And the derivation leads to what's in the code.

zhulz commented 2 years ago

image

its only the weight ls of data item