Monday, April 11, 2011

Registering Two Point Clouds

Problem Statement
Given two 3D point clouds with a good enough (how much??) overlap with each other (overlap in terms of scene information), we wish to combine them to build a composite point-cloud, which would naturally be denser than the two input point-clouds.

ICP Implementations
[2]    <<TODO>> 3D-ICP example here.
        -It provides a tiny example C file that uses ICP API (CICP::Align3D()) provided by the MPRT library (librariessvntutorialsdocumentation). 
        - MPRT provides its source code as an SVN, so we can look into the ICP implementation if we want to.
[4]     Don't know but some C++ code, check if the above ones ain't good enough.
From the above ones, I found the MRPT library implementation (the 2nd one in the above list) most reliable, so I am going for it. 

Getting The MRPT ICP Example Running
Today, I finally could run a demo test application of ICP that uses the MRPT library! Yippee :) Following are the steps I followed:
1. Download the source code for MRPT from its SVN. Its quite large-sized code, ~150 MBs.
2. Build the source ( regular "cmake . and make"  way). This will compile the source, it takes significant time. This will create the libraries in its local path.
3. From synaptic, install the mrpt libraries (libmrpt-dev, mrpt-apps, mrpt-doc, mrpt-libs).
4. Get the test.cpp source code of this example
5. Now you want to compile the test.cpp file. This step, as you might have guess already, took some time. Following is what I did to get this step done...
OK, to start with, I tried to build with simple "g++ test.cpp" command, but it doesn't work. I don't know why. It fails to find the required header files which are buried at various places in /usr/include/mrpt/... . I found the following way out : this web-page on MRPT website particularly encourages to use cmake for compiling and linking the applications that use the MRPT library. On the same webpage, it provides with a sample CMakeLists.txt file. So I created a CMakeLists.txt file in the same folder as test.cpp. 
Then, according to what the page suggests, I had to do "ccmake .", then "cmake ." and then "make". To get the ccmake package I had to install cmake-curses-gui from Synaptic.
So, I did a "ccmake .". A GUI-kind-of thing opened up, where I pressed 'c' to configure (which had to be done twice, for some reason :-o) then pressed 'g' to generate and exit. Then I did "cmake ." and then "make" but make failed. I got following error-

.../mrpttest> make
Scanning dependencies of target mrpt_example1
Linking CXX executable mrpt_example1
/usr/bin/ld: cannot find -lmrpt-base
collect2: ld returned 1 exit status
make[2]: *** [mrpt_example1] Error 1
make[1]: *** [CMakeFiles/mrpt_example1.dir/all] Error 2
make: *** [all] Error 2

So it is not able to locate the mprt-base library. I tried to find the library file in the standard Linux paths where libs are typically stored, but failed to find these libraries in 5 mins. However, I had explicitly compiled the svn source code of the MRPT library, so I had the compiled MRPT libraries with me there. I thought, for time being at least, I would use them. In order to use them, I put the following line in my CMakeLists.txt file-
Note that, for the reason mentioned here, the LINK_DIRECTORIES() clause has to be placed before the ADD_EXECUTABLE clause in the CMakeLists.txt file. Do not miss this part, this is crucial. 

After, the above one-line change in the CMakeLists.txt file, I did ccmake, cmake, and make again. And bingo! it works now! 
I got the following output which is the same as the screenshots displayed here.

No comments:

Post a Comment