Point Cloud Library (PCL)  1.12.1-dev
range_image_spherical.h
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2012-, Open Perception, Inc.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * * Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  * * Redistributions in binary form must reproduce the above
14  * copyright notice, this list of conditions and the following
15  * disclaimer in the documentation and/or other materials provided
16  * with the distribution.
17  * * Neither the name of the copyright holder(s) nor the names of its
18  * contributors may be used to endorse or promote products derived
19  * from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32  * POSSIBILITY OF SUCH DAMAGE.
33  */
34 
35 #pragma once
36 
37 #include <pcl/range_image/range_image.h>
38 
39 namespace pcl
40 {
41  /** \brief @b RangeImageSpherical is derived from the original range image and uses a slightly different
42  * spherical projection. In the original range image, the image will appear more and more
43  * "scaled down" along the y axis, the further away from the mean line of the image a point is.
44  * This class removes this scaling, which makes it especially suitable for spinning LIDAR sensors
45  * that capure a 360° view, since a rotation of the sensor will now simply correspond to a shift of the
46  * range image. (This class is similar to RangeImagePlanar, but changes less of the behaviour of the base class.)
47  * \author Andreas Muetzel
48  * \ingroup range_image
49  */
51  {
52  public:
53  // =====TYPEDEFS=====
55  using Ptr = shared_ptr<RangeImageSpherical>;
56  using ConstPtr = shared_ptr<const RangeImageSpherical>;
57 
58  // =====CONSTRUCTOR & DESTRUCTOR=====
59  /** Constructor */
61  /** Destructor */
63 
64  /** Return a newly created RangeImagePlanar.
65  * Reimplementation to return an image of the same type. */
66  virtual RangeImage*
67  getNew () const { return new RangeImageSpherical; }
68 
69  // =====PUBLIC METHODS=====
70  /** \brief Get a boost shared pointer of a copy of this */
71  inline Ptr
72  makeShared () { return Ptr (new RangeImageSpherical (*this)); }
73 
74 
75  // Since we reimplement some of these overloaded functions, we have to do the following:
78 
79  /** \brief Calculate the 3D point according to the given image point and range
80  * \param image_x the x image position
81  * \param image_y the y image position
82  * \param range the range
83  * \param point the resulting 3D point
84  * \note Implementation according to planar range images (compared to spherical as in the original)
85  */
86  virtual inline void
87  calculate3DPoint (float image_x, float image_y, float range, Eigen::Vector3f& point) const;
88 
89  /** \brief Calculate the image point and range from the given 3D point
90  * \param point the resulting 3D point
91  * \param image_x the resulting x image position
92  * \param image_y the resulting y image position
93  * \param range the resulting range
94  * \note Implementation according to planar range images (compared to spherical as in the original)
95  */
96  virtual inline void
97  getImagePoint (const Eigen::Vector3f& point, float& image_x, float& image_y, float& range) const;
98 
99  /** Get the angles corresponding to the given image point */
100  inline void
101  getAnglesFromImagePoint (float image_x, float image_y, float& angle_x, float& angle_y) const;
102 
103  /** Get the image point corresponding to the given ranges */
104  inline void
105  getImagePointFromAngles (float angle_x, float angle_y, float& image_x, float& image_y) const;
106 
107  };
108 } // namespace end
109 
110 
111 #include <pcl/range_image/impl/range_image_spherical.hpp> // Definitions of templated and inline functions
RangeImage is derived from pcl/PointCloud and provides functionalities with focus on situations where...
Definition: range_image.h:55
void calculate3DPoint(float image_x, float image_y, float range, PointWithRange &point) const
Calculate the 3D point according to the given image point and range.
shared_ptr< RangeImage > Ptr
Definition: range_image.h:60
virtual void getImagePoint(const Eigen::Vector3f &point, float &image_x, float &image_y, float &range) const
Get imagePoint from 3D point in world coordinates.
shared_ptr< const RangeImage > ConstPtr
Definition: range_image.h:61
PCL_EXPORTS RangeImage()
Constructor.
RangeImageSpherical is derived from the original range image and uses a slightly different spherical ...
void calculate3DPoint(float image_x, float image_y, float range, PointWithRange &point) const
Calculate the 3D point according to the given image point and range.
PCL_EXPORTS RangeImageSpherical()
Constructor.
Ptr makeShared()
Get a boost shared pointer of a copy of this.
virtual void getImagePoint(const Eigen::Vector3f &point, float &image_x, float &image_y, float &range) const
Get imagePoint from 3D point in world coordinates.
shared_ptr< RangeImageSpherical > Ptr
void getAnglesFromImagePoint(float image_x, float image_y, float &angle_x, float &angle_y) const
Get the angles corresponding to the given image point.
void getImagePointFromAngles(float angle_x, float angle_y, float &image_x, float &image_y) const
Get the image point corresponding to the given ranges.
virtual RangeImage * getNew() const
Return a newly created RangeImagePlanar.
virtual PCL_EXPORTS ~RangeImageSpherical()
Destructor.
#define PCL_EXPORTS
Definition: pcl_macros.h:323