Point Cloud Library (PCL)  1.14.1-dev
digital_elevation_map.h
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Point Cloud Library (PCL) - www.pointclouds.org
5  * Copyright (c) 2014-, Open Perception, Inc.
6  *
7  * All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  *
13  * * Redistributions of source code must retain the above copyright
14  * notice, this list of conditions and the following disclaimer.
15  * * Redistributions in binary form must reproduce the above
16  * copyright notice, this list of conditions and the following
17  * disclaimer in the documentation and/or other materials provided
18  * with the distribution.
19  * * Neither the name of the copyright holder(s) nor the names of its
20  * contributors may be used to endorse or promote products derived
21  * from this software without specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
26  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
27  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
28  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
29  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
33  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34  * POSSIBILITY OF SUCH DAMAGE.
35  */
36 
37 #pragma once
38 
39 #include <pcl/stereo/disparity_map_converter.h>
40 #include <pcl/point_types.h>
41 
42 namespace pcl {
43 
44 /** \brief Build a Digital Elevation Map in the column-disparity space from a disparity
45  * map and a color image of the scene.
46  *
47  * Example of usage:
48  *
49  * \code
50  * pcl::PointCloud<pcl::PointDEM>::Ptr cloud (new
51  * pcl::PointCloud<pcl::PointDEM>);
52  * pcl::PointCloud<pcl::RGB>::Ptr left_image (new
53  * pcl::PointCloud<pcl::RGB>);
54  * // Fill left image cloud.
55  *
56  * pcl::DigitalElevationMapBuilder demb;
57  * demb.setBaseline (0.8387445f);
58  * demb.setFocalLength (368.534700f);
59  * demb.setImageCenterX (318.112200f);
60  * demb.setImageCenterY (224.334900f);
61  * demb.setDisparityThresholdMin (15.0f);
62  * demb.setDisparityThresholdMax (80.0f);
63  * demb.setResolution (64, 32);
64  *
65  * // Left view of the scene.
66  * demb.loadImage (left_image);
67  * // Disparity map of the scene.
68  * demb.loadDisparityMap ("disparity_map.txt", 640, 480);
69  *
70  * demb.compute(*cloud);
71  * \endcode
72  *
73  * \author Timur Ibadov (ibadov.timur@gmail.com)
74  * \ingroup stereo
75  */
77 public:
86 
87  /** \brief DigitalElevationMapBuilder constructor. */
89 
90  /** \brief Empty destructor. */
92 
93  /** \brief Set resolution of the DEM.
94  * \param[in] resolution_column the column resolution.
95  * \param[in] resolution_disparity the disparity resolution.
96  */
97  void
98  setResolution(std::size_t resolution_column, std::size_t resolution_disparity);
99 
100  /** \brief Get column resolution of the DEM.
101  * \return column resolution of the DEM.
102  */
103  std::size_t
105 
106  /** \brief Get disparity resolution of the DEM.
107  * \return disparity resolution of the DEM.
108  */
109  std::size_t
111 
112  /** \brief Set minimum amount of points in a DEM's cell.
113  * \param[in] min_points_in_cell minimum amount of points in a DEM's cell.
114  */
115  void
116  setMinPointsInCell(std::size_t min_points_in_cell);
117 
118  /** \brief Get minimum amount of points in a DEM's cell.
119  * \return minimum amount of points in a DEM's cell.
120  */
121  std::size_t
123 
124  /** \brief Compute the Digital Elevation Map.
125  * \param[out] out_cloud the variable to return the resulting cloud.
126  */
127  void
128  compute(pcl::PointCloud<PointDEM>& out_cloud) override;
129 
130 protected:
131  /** \brief Column resolution of the DEM. */
132  std::size_t resolution_column_{64};
133  /** \brief disparity resolution of the DEM. */
134  std::size_t resolution_disparity_{32};
135  /** \brief Minimum amount of points in a DEM's cell. */
136  std::size_t min_points_in_cell_{1};
137 };
138 
139 } // namespace pcl
Build a Digital Elevation Map in the column-disparity space from a disparity map and a color image of...
~DigitalElevationMapBuilder() override
Empty destructor.
void setResolution(std::size_t resolution_column, std::size_t resolution_disparity)
Set resolution of the DEM.
DigitalElevationMapBuilder()
DigitalElevationMapBuilder constructor.
std::size_t getMinPointsInCell() const
Get minimum amount of points in a DEM's cell.
std::size_t getDisparityResolution() const
Get disparity resolution of the DEM.
void compute(pcl::PointCloud< PointDEM > &out_cloud) override
Compute the Digital Elevation Map.
std::size_t getColumnResolution() const
Get column resolution of the DEM.
void setMinPointsInCell(std::size_t min_points_in_cell)
Set minimum amount of points in a DEM's cell.
Compute point cloud from the disparity map.
PointCloud represents the base class in PCL for storing collections of 3D points.
Definition: point_cloud.h:173
Defines all the PCL implemented PointT point type structures.
#define PCL_EXPORTS
Definition: pcl_macros.h:323