gadomski / cpd

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

Investigate performance issues #124

Open gadomski opened 7 years ago

gadomski commented 7 years ago

Several users have reported that this C++ implementation is slower than the Matlab implementation.

RolandZhu commented 7 years ago

I agree, any idea about how this happens? My current project registers about 200 points in real time. Even enable fgt will slow down the process, and using Matlab(10ms) is faster than using C++(15ms), may I ask for any comment on that? Thanks.

gadomski commented 7 years ago

@RolandZhu no comment other than that I'm looking into it :-).

marcopus commented 6 years ago

I also have this problem. I gave it a try with cpd to morph 3D point clouds of bones for a human modeling application. These point clouds have in the order of 10k vertices and I wanted a streamlined way to morph sources to targets point cluods on-the-fly, by simply running an executable from the command line, instead of computing the registration off-line with MATLAB.

It turns out that not only MATLAB implementation is way faster (~5 minutes for a rigid+nonrigid registration using fgt lowrank) but I don't even get the nonrigid registration results within a reasonable time with the C++ program I just compiled. I've got the process running for 2 hours now, and so far it did only 16 iterations with the fgt direct-tree method, while MATLAB took ~350 iterations to converge. So it's just taking forever. ifgt and switched methds do not even pass the first iteration, strangely enough.

Parallelization might speed up the process a bit I think, but I wasn't successfull to build cpd with openmp-enabled fgt (which must be built as shared library), and cpd searches for static libraries of fgt apparently, or I was doing something wrong.

I would be glad to hear about any development on this.

aanwark commented 6 years ago

@marcopus I have noticed the same issue, with my tests the Matlab implementation is much faster than its C++ counterpart. I have one confusion though; is there a flag that needs to be set, if the library is needed to be compiled with fgt support? I compiled and installed fgt before and used a flag -WITH_FGT while doing cmake .. on this code. Is this approach right?

gadomski commented 6 years ago

No updates on performance as of yet, other than to make sure you're compiling in release mode (CMAKE_BUILD_TYPE=Release).

I have one confusion though; is there a flag that needs to be set, if the library is needed to be compiled with fgt support?

-DWITH_FGT=ON, e.g. if you're using a build/ subdirectory:

$ mkdir build && cd build && cmake .. -DWITH_FGT=ON -DCMAKE_BUILD_TYPE=Release
VShawn commented 1 month ago

I certain that the performance issue originates from gauss_transform.cpp in rigid case.

With the same data, using the original GaussTransformDirect::compute took 2.7 seconds.

image

After I modifying GaussTransformDirect::compute, the time decreased to 0.005 seconds.

image

Unfortunately, the modified GaussTransformDirect::compute I created clearly has issues with the calculation results.

BTW, here the test results on the fgt using the same data.

image