Point Cloud Library (PCL) 1.12.0
Loading...
Searching...
No Matches
range_image_planar.hpp
1/*
2 * Software License Agreement (BSD License)
3 *
4 * Point Cloud Library (PCL) - www.pointclouds.org
5 * Copyright (c) 2010, Willow Garage, Inc.
6 * Copyright (c) 2012-, Open Perception, Inc.
7 *
8 * All rights reserved.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 *
14 * * Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * * Redistributions in binary form must reproduce the above
17 * copyright notice, this list of conditions and the following
18 * disclaimer in the documentation and/or other materials provided
19 * with the distribution.
20 * * Neither the name of the copyright holder(s) nor the names of its
21 * contributors may be used to endorse or promote products derived
22 * from this software without specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
27 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
28 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
29 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
30 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
31 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
34 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35 * POSSIBILITY OF SUCH DAMAGE.
36 *
37 */
38
39#pragma once
40
41#include <pcl/common/eigen.h>
42#include <pcl/range_image/range_image_planar.h>
43#include <pcl/pcl_macros.h>
44
45namespace pcl
46{
47
48/////////////////////////////////////////////////////////////////////////
49template <typename PointCloudType> void
51 int di_width, int di_height,
52 float di_center_x, float di_center_y,
54 const Eigen::Affine3f& sensor_pose,
56 float min_range)
57{
58 //std::cout << "Starting to create range image from "<<point_cloud.size ()<<" points.\n";
59
68
69 is_dense = false;
70
73
74 to_range_image_system_ = to_world_system_.inverse (Eigen::Isometry);
75
76 unsigned int size = width*height;
77 points.clear ();
79
80 int top=height, right=-1, bottom=-1, left=width;
81 doZBuffer (point_cloud, noise_level, min_range, top, right, bottom, left);
82
83 // Do not crop
84 //cropImage (border_size, top, right, bottom, left);
85
87}
88
89
90/////////////////////////////////////////////////////////////////////////
91void
92RangeImagePlanar::calculate3DPoint (float image_x, float image_y, float range, Eigen::Vector3f& point) const
93{
94 //std::cout << __PRETTY_FUNCTION__ << " called.\n";
97 point[2] = range / (std::sqrt (delta_x*delta_x + delta_y*delta_y + 1));
98 point[0] = delta_x*point[2];
99 point[1] = delta_y*point[2];
100 point = to_world_system_ * point;
101}
102
103/////////////////////////////////////////////////////////////////////////
104inline void
105RangeImagePlanar::getImagePoint (const Eigen::Vector3f& point, float& image_x, float& image_y, float& range) const
106{
107 Eigen::Vector3f transformedPoint = to_range_image_system_ * point;
108 if (transformedPoint[2]<=0) // Behind the observer?
109 {
110 image_x = image_y = range = -1.0f;
111 return;
112 }
113 range = transformedPoint.norm ();
114
117}
118
119} // namespace pcl
120
Iterator class for point clouds with or without given indices.
bool is_dense
True if no points are invalid (e.g., have NaN or Inf values in any of their floating point fields).
std::uint32_t width
The point cloud width (if organized as an image-structure).
std::uint32_t height
The point cloud height (if organized as an image-structure).
std::vector< PointWithRange, Eigen::aligned_allocator< PointWithRange > > points
The point data.
PCL_EXPORTS void recalculate3DPointPositions()
Recalculate all 3D point positions according to their pixel position and range.
int image_offset_y_
Position of the top left corner of the range image compared to an image of full size (360x180 degrees...
Eigen::Affine3f to_world_system_
Inverse of to_range_image_system_.
PointWithRange unobserved_point
This point is used to be able to return a reference to a non-existing point.
void doZBuffer(const PointCloudType &point_cloud, float noise_level, float min_range, int &top, int &right, int &bottom, int &left)
Integrate the given point cloud into the current range image using a z-buffer.
Eigen::Affine3f to_range_image_system_
Inverse of to_world_system_.
static PCL_EXPORTS void getCoordinateFrameTransformation(RangeImage::CoordinateFrame coordinate_frame, Eigen::Affine3f &transformation)
Get the transformation that transforms the given coordinate frame into CAMERA_FRAME.
void createFromPointCloudWithFixedSize(const PointCloudType &point_cloud, int di_width, int di_height, float di_center_x, float di_center_y, float di_focal_length_x, float di_focal_length_y, const Eigen::Affine3f &sensor_pose, CoordinateFrame coordinate_frame=CAMERA_FRAME, float noise_level=0.0f, float min_range=0.0f)
Create the image from an existing point cloud.
float center_y_
The principle point of the image.
float focal_length_y_reciprocal_
1/focal_length -> for internal use
float focal_length_y_
The focal length of the image in pixels.
void calculate3DPoint(float image_x, float image_y, float range, Eigen::Vector3f &point) const override
Calculate the 3D point according to the given image point and range.
void getImagePoint(const Eigen::Vector3f &point, float &image_x, float &image_y, float &range) const override
Calculate the image point and range from the given 3D point.
Defines all the PCL and non-PCL macros used.