gadomski / cpd

C++ implementation of the Coherent Point Drift point set registration algorithm.
http://www.gadom.ski/cpd
GNU General Public License v2.0
396 stars 124 forks source link

resultPtr has wrong transformation after rigid registration #41

Closed iwyoo closed 8 years ago

iwyoo commented 8 years ago

Hi, I found an error in rigid registration. For example,

cpd::Rigid reg; cpd::Registration::ResultPtr result = reg.run(X,Y); result->transformation.print();

This code prints wrong translation values that are too small than expected. (at (0,3) and (1,3) of the homogeneous transformation matrix.) I guess that these value are not "denormalized" after 'execute" unlike Y matrix in 'result'. Is it correct? all just my wrong usage? Please check it. (Any way, this library is wonderful. I love it.)

gadomski commented 8 years ago

I can confirm, this is a bug. I'm currently working on a fix.

gadomski commented 8 years ago

@iwyoo I've put a stab at a fix into the issues/41-rigid-transformation branch. If you have time to pull and test that branch to see if you get expected results, I'd appreciate it.

I've also added a test case but I'm not convinced it's right.

iwyoo commented 8 years ago

First, I tested with the below source code,

arma::mat X,Y;
X.load("X.txt");
Y.load("Y.txt");

std::cout << "X : " << std::endl;
X.print();
std::cout << "Y : " << std::endl;
Y.print();

cpd::Registration::ResultPtr result;
cpd::Rigid reg1;
result = reg1.run(X,Y);

std::cout << "rigid transformation" << std::endl;
result->transformation.print();

std::cout << "rigid coordinates" << std::endl;
result->Y.print();

the output is following.

X : 
   1.0000   1.0000   1.0000
   1.0000   2.0000   1.0000
   2.0000   2.0000   1.0000
   2.0000   1.0000   1.0000
Y : 
        0        0        0
        0   1.0000        0
   1.0000   1.0000        0
   1.0000        0        0
rigid transformation
   1.0000        0        0   1.0000
        0   1.0000        0   1.0000
        0        0   1.0000   1.0000
        0        0        0   1.0000
rigid coordinates
   1.0000   1.0000   1.0000
   1.0000   2.0000   1.0000
   2.0000   2.0000   1.0000
   2.0000   1.0000   1.0000

It looks very fine. Also, it works well with my program now. Thank you very much!

gadomski commented 8 years ago

Glad it worked, thanks for the report!