Category Archives: PCL


Hello friends,

After doing a lot of research in point cloud library,I came up with the successful integration of computer vision with point cloud library.

I hope you have opencv and pcl installed by now.If not see:

This post is the result of inspiration from

Since I was not successful in compiling and running the code from the blog mentioned above in ubuntu 12.04 I came up with another solution.

The code below filters the point cloud from a PCD file and visualizes it.

The code will work properly on every PCD file after you make sure the filter_limit parameters are set in a proper way.

Download the code from here :

Here goes the explaination:

#include <pcl/point_cloud.h>
#include <pcl/io/pcd_io.h>
#include <pcl/io/ply_io.h>
#include <pcl/point_types.h>
#include <pcl/filters/passthrough.h>
#include <pcl/visualization/pcl_visualizer.h>
#include <vtkSmartPointer.h>

These are the required PCL libraries

int a = 22;
int b = 12;
int c=  10;

These are pre-set values for the trackbar

pcl::visualization::PCLVisualizer viewer ("Get the view here");

This is the window to display/visualize stuff

pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZ>);
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud_filtered(new pcl::PointCloud<pcl::PointXYZ>);

Here we have declared two point clouds of type POINTXYZ,you can change the type according to your PCD file.

pcl::io::loadPCDFile (argv[1], *cloud);
pcl::copyPointCloud( *cloud,*cloud_filtered);

Now we have loaded the file into the cloud and then copied into the other cloud.

cv::namedWindow( "picture");
cvCreateTrackbar("X_limit", "picture", &a, 30, NULL);
cvCreateTrackbar("Y_limit", "picture", &b, 30, NULL);
cvCreateTrackbar("Z_limit", "picture", &c, 30, NULL);

This will look familiar to OpenCV users.For those who dont know this,it is a way of creating trackbars to control any parameter,here,filter limits.

pcl::PassThrough<pcl::PointXYZ> pass;

Creating an object of class PassThrough filter

while (!viewer.wasStopped ())

		pcl::copyPointCloud(*cloud_filtered, *cloud);

        i = 0.1*((float)a);
        j = 0.1*((float)b);
        k = 0.1*((float)c);

//        cout << "i = " << i << " j = " << j << " k = " << k << endl;

        pass.setInputCloud (cloud);
	pass.setFilterFieldName ("y");
        pass.setFilterLimits (-j, j);
        pass.filter (*cloud);

        pass.setInputCloud (cloud);
        pass.setFilterFieldName ("x");
        pass.setFilterLimits (-i, i);
        pass.filter (*cloud);

	pass.setInputCloud (cloud);
        pass.setFilterFieldName ("z");
        pass.setFilterLimits (-k,k);
        pass.filter (*cloud);

	viewer.addPointCloud (cloud, "scene_cloud");
	viewer.spinOnce ();

Iterating though the cloud,setting filter parameters and linking it to the trackbars.

Now for the compiling part.
1)Download this file and save it as in the same folder where you have saved opencv_pcl_filter.cpp :

2)Download this sample PCD file and save as test.pcd in the same folder :

3) open a terminal and type
a)chmod +x
b)./ opencv_pcl_filter.cpp
c)./opencv_pcl_filter test.pcd

And you will see something like this:
Screenshot from 2014-07-01 17:29:43

And thats it,we have successfully created a filter in PCL.

Thanks ๐Ÿ™‚


Install Point Cloud Library(Bugs Resolved)

Hello friends,

In our last post we had a brief description of of what the Point Cloud Library is,so now lets install it and get started with PCL.

Here I will only be telling the installation procedure for Ubuntu(Linux),

SO here it goes: –

Open the terminal and type

a) sudo add-apt-repository ppa:v-launchpad-jochen-sprickerhof-de/pcl

b) sudo apt-get update

c) sudo apt-get install libpcl-all

And its done ๐Ÿ™‚

Now open a new terminal and type :
sudo gedit /usr/lib/pkgconfig/flann.pc

and in that file remove “-lflann_cpp-gd”. Save and close the file.

Now lets test it.

Method 1:-

a) Make a folder,and in the folder download the code and place it in a file named pcl_write.cpp

b) Download code from here :-

c) Make a new folder named build inside the current folder.

d) Make a new file named CMakeLists.txt and copy the following contents in it :


cmake_minimum_required(VERSION 2.6 FATAL_ERROR)
find_package(PCL 1.3 REQUIRED COMPONENTS common io)
add_executable(pcd_write_test pcd_write.cpp)
target_link_libraries(pcd_write_test ${PCL_COMMON_LIBRARIES} ${PCL_IO_LIBRARIES})

e) Enter the folder build by typing “cd build” in the terminal.

f) now in the terminal type these two commands:
cmake ..
sudo make

And a executable file will be generated.

Method 2 ( One of my seniors Jay Rambhia helped me get this,buts its slightly modified):-

Make a file named in the folder where ur code file is there and copy these contents in it :

Open a terminal and navigate to the folder where the code and is present and type:
a) chmod +X

Second method is simple isn’t it??

So its done ๐Ÿ™‚

Thank you ๐Ÿ™‚

Point cloud Library Introduction

Hello everyone,
I am currently working on a stereo vision project. So for that I thought of integrating PCL with OpenCV. So lets first get to the point that what is PCL.

PCL โ€“ Point Cloud Library
It has a set of pre-defined model libraries.

Filters:- Used for noise removal. Estimation of 3D from 2D always has a lot of noise interpreted automatically. So filters help them to remove that noise. Distance (Guassian mean type) of every point from its nearest neighbors is taken, if this crosses a set threshold, then it is recognized as noise.

Features:- This is a library consisting of methods devising 3D construction. K-Space is the space surrounded around a selected point. This neighborhood is found out by octree method or KD tree method. A KD tree is a space partitioning data structure for organizing points in K-dimensional space. These trees are useful in multidimensional search. It is a binary tree, having a node represented by K-Dimensional points, and dividing space into two halves. If for a particular split the “x” axis is chosen, all points in the subtree with a smaller “x” value than the node will appear in the left subtree and all points with larger “x” value will be in the right subtree. In a 3-dimensional tree, the root would have an x-aligned plane, the root’s children would both have y-aligned planes, the root’s grandchildren would all have z-aligned planes, the root’s great-grandchildren would all have x-aligned planes, the root’s great-great-grandchildren would all have y-aligned planes, and so on.The most easiest method in determining surface normals and curvatures is by finding eigenvectors and eigenvalues of the K-Space.

Key-Points:- This library has the algorithms for two pint cloud detection.

Registration:- It is a process of combining point datasets into one consistent model. In laymanโ€™s words its basically joining image datasets of a 3-D segmented image to make it one complete image.

:- It is a process of partitioning a digital image into multiple segments called as super-pixels. Image segmentation is typically used to locate objects and boundaries (lines, curves, etc.) in images. More precisely, image segmentation is the process of assigning a label to every pixel in an image such that pixels with the same label share certain characteristics.

Surface:- This library consists of methods of reconstructing surfaces. One of such methods is meshing.

Range image:- It is nothing but a kind of depth map. It is an image whose points represent distance from the sensor.

Visualization:- This library is for human interfacing, to check the working of algorithms. It is like opencvโ€™s highgui library.

This is just an intro,the next posts will include integration of PCL with OpenCV.

Thank you ๐Ÿ™‚

Also visit :