Point Cloud Library (PCL)
1.15.1
Toggle main menu visibility
Loading...
Searching...
No Matches
pcl
range_image
impl
range_image_spherical.hpp
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
36
#pragma once
37
38
#include <pcl/common/eigen.h>
39
#include <pcl/range_image/range_image_spherical.h>
40
#include <
pcl/pcl_macros.h
>
41
42
43
namespace
pcl
44
{
45
46
/////////////////////////////////////////////////////////////////////////
47
void
48
RangeImageSpherical::calculate3DPoint
(
float
image_x,
float
image_y,
float
range, Eigen::Vector3f& point)
const
49
{
50
float
angle_x, angle_y;
51
getAnglesFromImagePoint
(image_x, image_y, angle_x, angle_y);
52
53
float
cosY = std::cos (angle_y);
54
point = Eigen::Vector3f (range * sinf (angle_x) * cosY, range * sinf (angle_y), range * std::cos (angle_x)*cosY);
55
point =
to_world_system_
* point;
56
}
57
58
/////////////////////////////////////////////////////////////////////////
59
inline
void
60
RangeImageSpherical::getImagePoint
(
const
Eigen::Vector3f& point,
float
& image_x,
float
& image_y,
float
& range)
const
61
{
62
Eigen::Vector3f transformedPoint =
to_range_image_system_
* point;
63
range = transformedPoint.norm ();
64
float
angle_x =
atan2LookUp
(transformedPoint[0], transformedPoint[2]),
65
angle_y =
asinLookUp
(transformedPoint[1]/range);
66
getImagePointFromAngles
(angle_x, angle_y, image_x, image_y);
67
}
68
/////////////////////////////////////////////////////////////////////////
69
void
70
RangeImageSpherical::getAnglesFromImagePoint
(
float
image_x,
float
image_y,
float
& angle_x,
float
& angle_y)
const
71
{
72
angle_y = (image_y+
static_cast<
float
>
(
image_offset_y_
))*
angular_resolution_y_
- 0.5f*
static_cast<
float
>
(
M_PI
);
73
angle_x = ((image_x+
static_cast<
float
>
(
image_offset_x_
))*
angular_resolution_x_
-
static_cast<
float
>
(
M_PI
));
74
}
75
/////////////////////////////////////////////////////////////////////////
76
void
77
RangeImageSpherical::getImagePointFromAngles
(
float
angle_x,
float
angle_y,
float
& image_x,
float
& image_y)
const
78
{
79
image_x = (angle_x +
static_cast<
float
>
(
M_PI
))*
angular_resolution_x_reciprocal_
-
static_cast<
float
>
(
image_offset_x_
);
80
image_y = (angle_y + 0.5f*
static_cast<
float
>
(
M_PI
))*
angular_resolution_y_reciprocal_
-
static_cast<
float
>
(
image_offset_y_
);
81
}
82
}
// namespace pcl
83
pcl::RangeImage::image_offset_y_
int image_offset_y_
Position of the top left corner of the range image compared to an image of full size (360x180 degrees...
Definition
range_image.h:776
pcl::RangeImage::atan2LookUp
static float atan2LookUp(float y, float x)
Query the std::atan2 lookup table.
Definition
range_image.hpp:64
pcl::RangeImage::to_world_system_
Eigen::Affine3f to_world_system_
Inverse of to_range_image_system_.
Definition
range_image.h:769
pcl::RangeImage::asinLookUp
static float asinLookUp(float value)
Query the asin lookup table.
Definition
range_image.hpp:54
pcl::RangeImage::angular_resolution_y_reciprocal_
float angular_resolution_y_reciprocal_
1.0/angular_resolution_y_ - provided for better performance of multiplication compared to division
Definition
range_image.h:774
pcl::RangeImage::angular_resolution_y_
float angular_resolution_y_
Angular resolution of the range image in y direction in radians per pixel.
Definition
range_image.h:771
pcl::RangeImage::angular_resolution_x_
float angular_resolution_x_
Angular resolution of the range image in x direction in radians per pixel.
Definition
range_image.h:770
pcl::RangeImage::image_offset_x_
int image_offset_x_
Definition
range_image.h:776
pcl::RangeImage::to_range_image_system_
Eigen::Affine3f to_range_image_system_
Inverse of to_world_system_.
Definition
range_image.h:768
pcl::RangeImage::angular_resolution_x_reciprocal_
float angular_resolution_x_reciprocal_
1.0/angular_resolution_x_ - provided for better performance of multiplication compared to division
Definition
range_image.h:772
pcl::RangeImageSpherical::calculate3DPoint
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.
Definition
range_image_spherical.hpp:48
pcl::RangeImageSpherical::getAnglesFromImagePoint
void getAnglesFromImagePoint(float image_x, float image_y, float &angle_x, float &angle_y) const
Get the angles corresponding to the given image point.
Definition
range_image_spherical.hpp:70
pcl::RangeImageSpherical::getImagePointFromAngles
void getImagePointFromAngles(float angle_x, float angle_y, float &image_x, float &image_y) const
Get the image point corresponding to the given ranges.
Definition
range_image_spherical.hpp:77
pcl::RangeImageSpherical::getImagePoint
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.
Definition
range_image_spherical.hpp:60
pcl
Definition
convolution.h:46
pcl_macros.h
Defines all the PCL and non-PCL macros used.
M_PI
#define M_PI
Definition
pcl_macros.h:203