File: passthrough.rst

package info (click to toggle)
pcl 1.7.2-7
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 138,052 kB
  • ctags: 39,618
  • sloc: cpp: 446,687; xml: 28,552; ansic: 13,753; python: 539; makefile: 72; sh: 25
file content (89 lines) | stat: -rw-r--r-- 2,353 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
.. _passthrough:

Filtering a PointCloud using a PassThrough filter
--------------------------------------------------

In this tutorial we will learn how to perform a simple filtering along a
specified dimension -- that is, cut off values that are either inside or
outside a given user range.

The code
--------

First, create a file, let's say, ``passthrough.cpp`` in your favorite
editor, and place the following inside it:

.. literalinclude:: sources/passthrough/passthrough.cpp
   :language: cpp
   :linenos:

The explanation
---------------

Now, let's break down the code piece by piece.

In the following lines, we define the Point Clouds structures, fill in the
input cloud, and display its content to screen.

.. literalinclude:: sources/passthrough/passthrough.cpp
   :language: cpp
   :lines: 11-27

Then, we create the PassThrough filter object, and set its parameters. The
filter field name is set to the z coordinate, and the accepted interval values
are set to (0.0;1.0).

.. literalinclude:: sources/passthrough/passthrough.cpp
   :language: cpp
   :lines: 30-35

   
Finally we show the content of the filtered cloud.

.. literalinclude:: sources/passthrough/passthrough.cpp
   :language: cpp
   :lines: 37-41

   
Compiling and running the program
---------------------------------

Add the following lines to your CMakeLists.txt file:

.. literalinclude:: sources/passthrough/CMakeLists.txt
   :language: cmake
   :linenos:


After you have made the executable, you can run it. Simply do::

  $ ./passthrough

You will see something similar to::

  Cloud before filtering: 
      0.352222 -0.151883 -0.106395
      -0.397406 -0.473106 0.292602
      -0.731898 0.667105 0.441304
      -0.734766 0.854581 -0.0361733
      -0.4607 -0.277468 -0.916762
  Cloud after filtering: 
      -0.397406 -0.473106 0.292602
      -0.731898 0.667105 0.441304

A graphical display of the filtering process is shown below. 

.. image:: images/passthrough_2.png

Note that the coordinate axis are represented as red (x), green (y), and blue
(z). The five points are represented with green as the points remaining after
filtering and red as the points that have been removed by the filter.

As an exercise, try uncommenting this line

.. literalinclude:: sources/passthrough/passthrough.cpp
   :language: cpp
   :lines: 34

and run the program again.