Point Cloud Library (PCL)
1.11.1-dev
kinfu
include
pcl
gpu
kinfu
raycaster.h
1
/*
2
* Software License Agreement (BSD License)
3
*
4
* Point Cloud Library (PCL) - www.pointclouds.org
5
* Copyright (c) 2011, Willow Garage, Inc.
6
*
7
* All rights reserved.
8
*
9
* Redistribution and use in source and binary forms, with or without
10
* modification, are permitted provided that the following conditions
11
* are met:
12
*
13
* * Redistributions of source code must retain the above copyright
14
* notice, this list of conditions and the following disclaimer.
15
* * Redistributions in binary form must reproduce the above
16
* copyright notice, this list of conditions and the following
17
* disclaimer in the documentation and/or other materials provided
18
* with the distribution.
19
* * Neither the name of Willow Garage, Inc. nor the names of its
20
* contributors may be used to endorse or promote products derived
21
* from this software without specific prior written permission.
22
*
23
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
26
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
27
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
28
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
29
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
33
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34
* POSSIBILITY OF SUCH DAMAGE.
35
*
36
*/
37
38
#pragma once
39
40
#include <
pcl/memory.h
>
41
#include <
pcl/pcl_macros.h
>
42
#include <
pcl/point_types.h
>
43
#include <pcl/gpu/containers/device_array.h>
44
#include <pcl/gpu/kinfu/pixel_rgb.h>
45
#include <Eigen/Geometry>
46
47
namespace
pcl
48
{
49
namespace
gpu
50
{
51
class
TsdfVolume;
52
53
/** \brief Class that performs raycasting for TSDF volume
54
* \author Anatoly Baskeheev, Itseez Ltd, (myname.mysurname@mycompany.com)
55
*/
56
struct
PCL_EXPORTS
RayCaster
57
{
58
public
:
59
using
Ptr
= shared_ptr<RayCaster>;
60
using
ConstPtr
= shared_ptr<const RayCaster>;
61
using
MapArr
=
DeviceArray2D<float>
;
62
using
View
=
DeviceArray2D<PixelRGB>
;
63
using
Depth
=
DeviceArray2D<unsigned short>
;
64
65
/** \brief Image with height */
66
const
int
cols,
rows
;
67
68
/** \brief Constructor
69
* \param[in] rows image rows
70
* \param[in] cols image cols
71
* \param[in] fx focal x
72
* \param[in] fy focal y
73
* \param[in] cx principal point x
74
* \param[in] cy principal point y
75
*/
76
RayCaster
(
int
rows = 480,
int
cols = 640,
float
fx = 525.f,
float
fy = 525.f,
float
cx = -1,
float
cy = -1);
77
~
RayCaster
();
78
79
/** \brief Sets camera intrinsics */
80
void
81
setIntrinsics(
float
fx = 525.f,
float
fy = 525.f,
float
cx = -1,
float
cy = -1);
82
83
/** \brief Runs raycasting algorithm from given camera pose. It writes results to internal files.
84
* \param[in] volume tsdf volume container
85
* \param[in] camera_pose camera pose
86
*/
87
void
88
run(
const
TsdfVolume
& volume,
const
Eigen::Affine3f& camera_pose);
89
90
/** \brief Generates scene view using data raycasted by run method. So call it before.
91
* \param[out] view output array for RGB image
92
*/
93
void
94
generateSceneView(
View
& view)
const
;
95
96
/** \brief Generates scene view using data raycasted by run method. So call it before.
97
* \param[out] view output array for RGB image
98
* \param[in] light_source_pose pose of light source
99
*/
100
void
101
generateSceneView(
View
& view,
const
Eigen::Vector3f& light_source_pose)
const
;
102
103
/** \brief Generates depth image using data raycasted by run method. So call it before.
104
* \param[out] depth output array for depth image
105
*/
106
void
107
generateDepthImage(
Depth
& depth)
const
;
108
109
/** \brief Returns raycasterd vertex map. */
110
MapArr
111
getVertexMap()
const
;
112
113
/** \brief Returns raycasterd normal map. */
114
MapArr
115
getNormalMap()
const
;
116
117
private
:
118
/** \brief Camera intrinsics. */
119
float
fx_, fy_, cx_, cy_;
120
121
/* Vertext/normal map internal representation example for rows=2 and cols=4
122
* X X X X
123
* X X X X
124
* Y Y Y Y
125
* Y Y Y Y
126
* Z Z Z Z
127
* Z Z Z Z
128
*/
129
130
/** \brief vertex map of 3D points*/
131
MapArr
vertex_map_;
132
133
/** \brief normal map of 3D points*/
134
MapArr
normal_map_;
135
136
/** \brief camera pose from which raycasting was done */
137
Eigen::Affine3f camera_pose_;
138
139
/** \brief Last passed volume size */
140
Eigen::Vector3f volume_size_;
141
142
public
:
143
PCL_MAKE_ALIGNED_OPERATOR_NEW
144
};
145
146
/** \brief Converts from map representation to organized not-dence point cloud. */
147
template
<
typename
Po
int
Type>
148
void
convertMapToOranizedCloud
(
const
RayCaster::MapArr
& map,
DeviceArray2D<PointType>
& cloud);
149
}
150
}
pcl::gpu::convertMapToOranizedCloud
void convertMapToOranizedCloud(const RayCaster::MapArr &map, DeviceArray2D< PointType > &cloud)
Converts from map representation to organized not-dence point cloud.
pcl_macros.h
Defines all the PCL and non-PCL macros used.
pcl
Definition:
convolution.h:46
point_types.h
pcl::gpu::RayCaster::rows
const int rows
Definition:
raycaster.h:66
pcl::gpu::RayCaster::ConstPtr
shared_ptr< const RayCaster > ConstPtr
Definition:
raycaster.h:60
pcl::gpu::DeviceArray2D< float >
pcl::gpu::TsdfVolume
TsdfVolume class.
Definition:
tsdf_volume.h:55
PCL_MAKE_ALIGNED_OPERATOR_NEW
#define PCL_MAKE_ALIGNED_OPERATOR_NEW
Macro to signal a class requires a custom allocator.
Definition:
memory.h:63
pcl::gpu::RayCaster::Ptr
shared_ptr< RayCaster > Ptr
Definition:
raycaster.h:59
pcl::gpu::RayCaster
Class that performs raycasting for TSDF volume.
Definition:
raycaster.h:56
memory.h
Defines functions, macros and traits for allocating and using memory.
PCL_EXPORTS
#define PCL_EXPORTS
Definition:
pcl_macros.h:323