Iterative-Closest-Point
Iterative-Closest-Point copied to clipboard
final rotation matrix
Is there a way to get the rotation matrix and translation values required to transform the dynamic to static point clouds? I edited the ICP.cpp but the final rotation matrix is a unity matrix with zero translation values. Thanks
Sorry, I haven't gone through this repo in years... The rotation and translation matrix is the change between successive iterations and the last update ends up being very small.
the arithmetic for the transform is of the form: x_final = R2 * (R1 * (R0 * x_start + t0) + t1 + t2
To get the final rotation matrix, all you have to do is multiply the rotation matrix from each step RN ..* R2 * R1 * R0 e.g.:
float rotationCumulative[9]; clearRotation(rotationCumulative); for (int iter = 0; iter < maxIterations && abs(cost) > eps; iter++) { //... //... at the end of the loop float rotationMatCopy[9]; matrixMult(rotationMatrix, rotationCumulative, rotationMatCopy); for (int i = 0; i < 9; i++) rotationCumulative[i] = rotationMatCopy[i]; }
There is a little bit more arithmetic involved in getting the translation, if I had more time I could do it.
Sorry this repo is not maintained well nor is it designed well, I would change a lot of things if I were to refactor it.
Thanks I appreciate your quick reply and it works! To get the translation, I inverted rotationCumulative (i.e. rotInv) and applied it to the static point cloud, compute the mean from new static mean cloud:
computeCloudMean(staticPointCloud, &dynamicMidF); gs::Point tF(0.0, 0.0, 0.0); rotate(&dynamicMidF, rotInv, &tF); translation[0] = staticMid.pos[0] - tF.pos[0]; translation[1] = staticMid.pos[1] - tF.pos[1]; translation[2] = staticMid.pos[2] - tF.pos[2]; However, the translation is not right. Maybe the way I am thinking about this it not right. Thanks again!
Thanks I appreciate your quick reply and it works! To get the translation, I inverted rotationCumulative (i.e. rotInv) and applied it to the static point cloud, compute the mean from new static mean cloud:
computeCloudMean(staticPointCloud, &dynamicMidF); gs::Point tF(0.0, 0.0, 0.0); rotate(&dynamicMidF, rotInv, &tF); translation[0] = staticMid.pos[0] - tF.pos[0]; translation[1] = staticMid.pos[1] - tF.pos[1]; translation[2] = staticMid.pos[2] - tF.pos[2]; However, the translation is not right. Maybe the way I am thinking about this it not right. Thanks again!
Did you manage to get the correct values of translation yet ?
Thank you
No I have not been able to compute the correct translation.