File: normal_estimation_using_integral_images.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 (66 lines) | stat: -rw-r--r-- 2,198 bytes parent folder | download | duplicates (2)
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
.. _normal_estimation_using_integral_images:

Normal Estimation Using Integral Images
---------------------------------------

In this tutorial we will learn how to compute normals for an organized point
cloud using integral images. 


The code
--------

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

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

.. literalinclude:: sources/normal_estimation_using_integral_images/normal_estimation_using_integral_images.cpp
   :language: cpp
   :linenos:
   
The explanation
---------------

Now, let's break down the code piece by piece. In the first part we load a
point cloud from a file:

.. literalinclude:: sources/normal_estimation_using_integral_images/normal_estimation_using_integral_images.cpp
   :language: cpp
   :lines: 11-12

In the second part we create an object for the normal estimation and compute
the normals:

.. literalinclude:: sources/normal_estimation_using_integral_images/normal_estimation_using_integral_images.cpp
   :language: cpp
   :lines: 14-22

The following normal estimation methods are available:

.. code-block:: cpp

     enum NormalEstimationMethod
     {
       COVARIANCE_MATRIX,
       AVERAGE_3D_GRADIENT,
       AVERAGE_DEPTH_CHANGE,
       SIMPLE_3D_GRADIENT
     };
	 
The COVARIANCE_MATRIX mode creates 9 integral images to compute the normal for
a specific point from the covariance matrix of its local neighborhood. The
AVERAGE_3D_GRADIENT mode creates 6 integral images to compute smoothed versions
of horizontal and vertical 3D gradients and computes the normals using the
cross-product between these two gradients. The AVERAGE_DEPTH_CHANGE mode
creates only a single integral image and computes the normals from the average
depth changes.

In the last part we visualize the point cloud and the corresponding normals:

.. literalinclude:: sources/normal_estimation_using_integral_images/normal_estimation_using_integral_images.cpp
   :language: cpp
   :lines: 24-32