Point Cloud Library (PCL)  1.8.0
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 #ifndef PCL_RANGE_IMAGE_SPHERICAL_H_
36 #define PCL_RANGE_IMAGE_SPHERICAL_H_
37 
38 #include <pcl/range_image/range_image.h>
39 
40 namespace pcl
41 {
42  /** \brief @b RangeImageSpherical is derived from the original range image and uses a slightly different
43  * spherical projection. In the original range image, the image will appear more and more
44  * "scaled down" along the y axis, the further away from the mean line of the image a point is.
45  * This class removes this scaling, which makes it especially suitable for spinning LIDAR sensors
46  * that capure a 360° view, since a rotation of the sensor will now simply correspond to a shift of the
47  * range image. (This class is similar to RangeImagePlanar, but changes less of the behaviour of the base class.)
48  * \author Andreas Muetzel
49  * \ingroup range_image
50  */
52  {
53  public:
54  // =====TYPEDEFS=====
56  typedef boost::shared_ptr<RangeImageSpherical> Ptr;
57  typedef boost::shared_ptr<const RangeImageSpherical> ConstPtr;
58 
59  // =====CONSTRUCTOR & DESTRUCTOR=====
60  /** Constructor */
61  PCL_EXPORTS RangeImageSpherical () {}
62  /** Destructor */
63  PCL_EXPORTS virtual ~RangeImageSpherical () {}
64 
65  /** Return a newly created RangeImagePlanar.
66  * Reimplmentation to return an image of the same type. */
67  virtual RangeImage*
68  getNew () const { return new RangeImageSpherical; }
69 
70  // =====PUBLIC METHODS=====
71  /** \brief Get a boost shared pointer of a copy of this */
72  inline Ptr
73  makeShared () { return Ptr (new RangeImageSpherical (*this)); }
74 
75 
76  // Since we reimplement some of these overloaded functions, we have to do the following:
79 
80  /** \brief Calculate the 3D point according to the given image point and range
81  * \param image_x the x image position
82  * \param image_y the y image position
83  * \param range the range
84  * \param point the resulting 3D point
85  * \note Implementation according to planar range images (compared to spherical as in the original)
86  */
87  virtual inline void
88  calculate3DPoint (float image_x, float image_y, float range, Eigen::Vector3f& point) const;
89 
90  /** \brief Calculate the image point and range from the given 3D point
91  * \param point the resulting 3D point
92  * \param image_x the resulting x image position
93  * \param image_y the resulting y image position
94  * \param range the resulting range
95  * \note Implementation according to planar range images (compared to spherical as in the original)
96  */
97  virtual inline void
98  getImagePoint (const Eigen::Vector3f& point, float& image_x, float& image_y, float& range) const;
99 
100  /** Get the angles corresponding to the given image point */
101  inline void
102  getAnglesFromImagePoint (float image_x, float image_y, float& angle_x, float& angle_y) const;
103 
104  /** Get the image point corresponding to the given ranges */
105  inline void
106  getImagePointFromAngles (float angle_x, float angle_y, float& image_x, float& image_y) const;
107 
108  };
109 } // namespace end
110 
111 
112 #include <pcl/range_image/impl/range_image_spherical.hpp> // Definitions of templated and inline functions
113 
114 #endif //#ifndef PCL_RANGE_IMAGE_SPHERICAL_H_
void getImagePointFromAngles(float angle_x, float angle_y, float &image_x, float &image_y) const
Get the image point corresponding to the given ranges.
boost::shared_ptr< RangeImageSpherical > Ptr
RangeImage is derived from pcl/PointCloud and provides functionalities with focus on situations where...
Definition: range_image.h:55
RangeImageSpherical is derived from the original range image and uses a slightly different spherical ...
boost::shared_ptr< const RangeImageSpherical > ConstPtr
void getAnglesFromImagePoint(float image_x, float image_y, float &angle_x, float &angle_y) const
Get the angles corresponding to the given image point.
virtual void getImagePoint(const Eigen::Vector3f &point, float &image_x, float &image_y, float &range) const
Get imagePoint from 3D point in world coordinates.
PCL_EXPORTS RangeImageSpherical()
Constructor.
virtual PCL_EXPORTS ~RangeImageSpherical()
Destructor.
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.
virtual RangeImage * getNew() const
Return a newly created RangeImagePlanar.
virtual void getImagePoint(const Eigen::Vector3f &point, float &image_x, float &image_y, float &range) const
Calculate the image point and range from the given 3D point.
Ptr makeShared()
Get a boost shared pointer of a copy of this.
virtual void calculate3DPoint(float image_x, float image_y, float range, Eigen::Vector3f &point) const
Calculate the 3D point according to the given image point and range.