range_image_spherical.hpp
/*
* Software License Agreement (BSD License)
*
* Copyright (c) 2012-, Open Perception, Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of the copyright holder(s) nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
*/
#pragma once
#include <pcl/common/eigen.h>
#include <pcl/range_image/range_image_spherical.h>
#include <pcl/pcl_macros.h>
namespace pcl
{
/////////////////////////////////////////////////////////////////////////
void
RangeImageSpherical::calculate3DPoint (float image_x, float image_y, float range, Eigen::Vector3f& point) const
{
float angle_x, angle_y;
getAnglesFromImagePoint (image_x, image_y, angle_x, angle_y);
float cosY = std::cos (angle_y);
point = Eigen::Vector3f (range * sinf (angle_x) * cosY, range * sinf (angle_y), range * std::cos (angle_x)*cosY);
point = to_world_system_ * point;
}
/////////////////////////////////////////////////////////////////////////
inline void
RangeImageSpherical::getImagePoint (const Eigen::Vector3f& point, float& image_x, float& image_y, float& range) const
{
Eigen::Vector3f transformedPoint = to_range_image_system_ * point;
range = transformedPoint.norm ();
float angle_x = atan2LookUp (transformedPoint[0], transformedPoint[2]),
angle_y = asinLookUp (transformedPoint[1]/range);
getImagePointFromAngles (angle_x, angle_y, image_x, image_y);
}
/////////////////////////////////////////////////////////////////////////
void
RangeImageSpherical::getAnglesFromImagePoint (float image_x, float image_y, float& angle_x, float& angle_y) const
{
angle_y = (image_y+static_cast<float> (image_offset_y_))*angular_resolution_y_ - 0.5f*static_cast<float> (M_PI);
angle_x = ((image_x+ static_cast<float> (image_offset_x_))*angular_resolution_x_ - static_cast<float> (M_PI));
}
/////////////////////////////////////////////////////////////////////////
void
RangeImageSpherical::getImagePointFromAngles (float angle_x, float angle_y, float& image_x, float& image_y) const
{
image_x = (angle_x + static_cast<float> (M_PI))*angular_resolution_x_reciprocal_ - static_cast<float> (image_offset_x_);
image_y = (angle_y + 0.5f*static_cast<float> (M_PI))*angular_resolution_y_reciprocal_ - static_cast<float> (image_offset_y_);
}
} // namespace pcl
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:63
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:53
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
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.
Definition: range_image.hpp:585
pcl::RangeImageSpherical::getImagePoint
virtual void getImagePoint(const Eigen::Vector3f &point, float &image_x, float &image_y, float &range) const
Get imagePoint from 3D point in world coordinates.
Definition: range_image.hpp:355
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
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:201