File: convex_hull_2d.rst

package info (click to toggle)
pcl 1.15.0%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 143,128 kB
  • sloc: cpp: 520,234; xml: 28,792; ansic: 8,212; python: 334; lisp: 93; sh: 49; makefile: 30
file content (61 lines) | stat: -rw-r--r-- 1,799 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
.. _convex_hull_2d:

Construct a convex hull polygon for a plane model
-------------------------------------------------

In this tutorial we will learn how to calculate a simple 2D convex hull polygon
for a set of points supported by a plane.

The following video shows a demonstration of the code given below on the test
dataset `table_scene_mug_stereo_textured.pcd 
<https://raw.github.com/PointCloudLibrary/data/master/tutorials/table_scene_mug_stereo_textured.pcd>`_.

.. raw:: html
  
  <iframe title="Acquiring the convex hull of a planar surface" width="480" height="390" src="https://www.youtube.com/embed/J9CjWDgPDTM?rel=0" frameborder="0" allowfullscreen></iframe>

The code
--------

First, download the dataset `table_scene_mug_stereo_textured.pcd
<https://raw.github.com/PointCloudLibrary/data/master/tutorials/table_scene_mug_stereo_textured.pcd>`_
and save it somewhere to disk.

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

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


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

The only interesting part is in the lines below, where the ConvexHull object
gets created and the reconstruction is performed:

.. literalinclude:: sources/convex_hull_2d/convex_hull_2d.cpp
   :language: cpp
   :lines: 49-52


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

Add the following lines to your CMakeLists.txt file:

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


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

  $ ./convex_hull_2d

You will see *something similar* to::

  PointCloud after filtering has: 139656 data points.
  Convex hull has: 30 data points.