Installing Point Cloud Library and configuring Code::Blocks to compile (Ubuntu 14.04 LTS)

Most of the credit for this post goes to this blog post and this documentation at the Point Cloud Library website. However, those didn't quite get me to the finish line, so here's what got me there:

In anticipation of getting a Microsoft Kinect for Windows v2 to image some plants, I wanted to get the Point Cloud Library (PCL) up and running so that we could define 3D entities from the 2D RGB-D images we'll get from the Kinect. I'll be developing in C++ with Code::Blocks so my first goal was to compile some code using the PCL.

Mercifully, prebuilt binaries for the PCL are available through the apt package manager. As documented at the PCL website:
sudo add-apt-repository ppa:v-launchpad-jochen-sprickerhof-de/pcl
sudo apt-get update
sudo apt-get install libpcl-all
As for configuring Code::Blocks, I followed a blog post at this site, but it seemed that some of the shared object libraries requirements had changed since that blog post. Ultimately, it required adding the following:
Go to Project->Build Options->Search Directories Tab->Compiler Tab and add the following locations:
/usr/include/eigen3
/usr/include/pcl-1.7
/usr/include/pcl-1.7/pcl/surface
/usr/include/vtk-5.8
Then in Project->Build Options->Linker Settings Tab add the following link libraries:
/usr/lib/libvtk* (all of the libvtk .so files)
/usr/lib/libpcl* (all of the libpcl .so files)
/usr/lib/i386-linux-gnu/libboost_thread.so 
/usr/lib/i386-linux-gnu/libpthread.so 
/usr/lib/i386-linux-gnu/libboost_filesystem.so 
/usr/lib/i386-linux-gnu/libboost_iostreams.so 
/usr/lib/i386-linux-gnu/libboost_system.so
These files may not be in these locations on all systems, so use find to track them down, e.g.:
find /usr/lib* -name "*boost*.so"
The code I used to test if I could compile was obtained here from the Point Cloud Library, and it's also reproduced here:
#include <iostream>
#include <pcl/io/pcd_io.h>
#include <pcl/point_types.h>

int main (int argc, char** argv)
{
  pcl::PointCloud<pcl::PointXYZ> cloud;

  // Fill in the cloud data
  cloud.width    = 5;
  cloud.height   = 1;
  cloud.is_dense = false;
  cloud.points.resize (cloud.width * cloud.height);

  for (size_t i = 0; i < cloud.points.size (); ++i)
  {
    cloud.points[i].x = 1024 * rand () / (RAND_MAX + 1.0f);
    cloud.points[i].y = 1024 * rand () / (RAND_MAX + 1.0f);
    cloud.points[i].z = 1024 * rand () / (RAND_MAX + 1.0f);
  }

  pcl::io::savePCDFileASCII ("test_pcd.pcd", cloud);
  std::cerr << "Saved " << cloud.points.size () << " data points to test_pcd.pcd." << std::endl;

  for (size_t i = 0; i < cloud.points.size (); ++i)
    std::cerr << "    " << cloud.points[i].x << " " << cloud.points[i].y << " " << cloud.points[i].z << std::endl;

  return (0);
}
And hopefully you get the output:

Comments

  1. There are 2 typos in line 26, a ; before endl and >> instead << after second space. It should go like this:

    std::cerr << " " << cloud.points[i].x << " " << cloud.points[i].y << " " << cloud.points[i].z << std::endl;

    Anyway, good post. Saved me

    ReplyDelete
  2. Ha ha.. I am the author of aravindev.blogspot.com.
    I ended up referring your blog to configure PCL. I don't even remember that I had written a blog on configuring it. :D
    Nice write up anyways!
    -Aravind

    ReplyDelete
    Replies
    1. This gave me a good laugh, thanks for commenting (and for writing the original blog post)!

      Delete
  3. Hi! I have just begun working with TLS point clouds and would like to explore PCL as a tool for my project. Can the above be implemented on windows too? I have never implemented these processes before and would appreciate any help so I can start using PCL for point cloud processing. Thank you!

    ReplyDelete
    Replies
    1. I think PCL should work fine on Windows and be applicable to terrestrial laser scanning clouds, though I don't have any experience with either. I suggest starting with the PCL documentation for a Windows installation. Good luck!

      Delete

Post a Comment

Popular Posts