Point Cloud Library (PCL)
1.11.0
octree
include
pcl
gpu
octree
octree.hpp
1
/*
2
* Software License Agreement (BSD License)
3
*
4
* Copyright (c) 2011, Willow Garage, 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 Willow Garage, Inc. 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
* Author: Anatoly Baskeheev, Itseez Ltd, (myname.mysurname@mycompany.com)
35
*/
36
37
#ifndef _PCL_GPU_OCTREE_
38
#define _PCL_GPU_OCTREE_
39
40
#include <vector>
41
42
#include <
pcl/memory.h
>
43
#include <
pcl/point_types.h
>
44
#include <
pcl/pcl_macros.h
>
45
#include <pcl/gpu/containers/device_array.h>
46
#include <pcl/gpu/octree/device_format.hpp>
47
48
namespace
pcl
49
{
50
namespace
gpu
51
{
52
/**
53
* \brief Octree implementation on GPU. It suppors parallel building and parallel batch search as well .
54
* \author Anaoly Baksheev, Itseez, myname.mysurname@mycompany.com
55
*/
56
57
class
PCL_EXPORTS
Octree
58
{
59
public
:
60
61
/** \brief Default constructor.*/
62
Octree
();
63
64
/** \brief Denstructor.*/
65
virtual
~
Octree
();
66
67
/** \brief Types */
68
using
Ptr
= shared_ptr<Octree>;
69
using
ConstPtr
= shared_ptr<const Octree>;
70
71
/** \brief Point typwe supported */
72
using
PointType
=
pcl::PointXYZ
;
73
74
/** \brief Point cloud supported */
75
using
PointCloud
=
DeviceArray<PointType>
;
76
77
/** \brief Point Batch query cloud type */
78
using
Queries
=
DeviceArray<PointType>
;
79
80
/** \brief Point Radiuses for batch query */
81
using
Radiuses
=
DeviceArray<float>
;
82
83
/** \brief Point Indices for batch query */
84
using
Indices
=
DeviceArray<int>
;
85
86
/** \brief Point Sqrt distances array type */
87
using
ResultSqrDists
=
DeviceArray<float>
;
88
89
const
PointCloud
*
cloud_
;
90
91
/** \brief Sets cloud for which octree is built */
92
void
setCloud(
const
PointCloud
& cloud_arg);
93
94
/** \brief Performs parallel octree building */
95
void
build();
96
97
/** \brief Returns true if tree has been built */
98
bool
isBuilt()
const
;
99
100
/** \brief Downloads Octree from GPU to search using CPU function. It use useful for single (not-batch) search */
101
void
internalDownload();
102
103
/** \brief Performs search of all points within given radius on CPU. It call \a internalDownload if necessary
104
* \param[in] center center of sphere
105
* \param[in] radius radious of sphere
106
* \param[out] out indeces of points within give sphere
107
* \param[in] max_nn maximum numver of results returned
108
*/
109
void
radiusSearchHost(
const
PointType
& center,
float
radius, std::vector<int>& out,
int
max_nn = INT_MAX);
110
111
/** \brief Performs approximate nearest neighbor search on CPU. It call \a internalDownload if necessary
112
* \param[in] query 3D point for which neighbour is be fetched
113
* \param[out] out_index neighbour index
114
* \param[out] sqr_dist square distance to the neighbour returned
115
*/
116
void
approxNearestSearchHost(
const
PointType
& query,
int
& out_index,
float
& sqr_dist);
117
118
/** \brief Performs batch radius search on GPU
119
* \param[in] centers array of centers
120
* \param[in] radius radius for all queries
121
* \param[in] max_results max number of returned points for each querey
122
* \param[out] result results packed to single array
123
*/
124
void
radiusSearch(
const
Queries
& centers,
float
radius,
int
max_results,
NeighborIndices
& result)
const
;
125
126
/** \brief Performs batch radius search on GPU
127
* \param[in] centers array of centers
128
* \param[in] radiuses array of radiuses
129
* \param[in] max_results max number of returned points for each querey
130
* \param[out] result results packed to single array
131
*/
132
void
radiusSearch(
const
Queries
& centers,
const
Radiuses
& radiuses,
int
max_results,
NeighborIndices
& result)
const
;
133
134
/** \brief Performs batch radius search on GPU
135
* \param[in] centers array of centers
136
* \param[in] indices indices for centers array (only for these points search is performed)
137
* \param[in] radius radius for all queries
138
* \param[in] max_results max number of returned points for each querey
139
* \param[out] result results packed to single array
140
*/
141
void
radiusSearch(
const
Queries
& centers,
const
Indices
& indices,
float
radius,
int
max_results,
NeighborIndices
& result)
const
;
142
143
/** \brief Batch approximate nearest search on GPU
144
* \param[in] queries array of centers
145
* \param[out] result array of results ( one index for each query )
146
*/
147
void
approxNearestSearch(
const
Queries
& queries,
NeighborIndices
& result)
const
;
148
149
/** \brief Batch exact k-nearest search on GPU for k == 1 only!
150
* \param[in] queries array of centers
151
* \param[in] k number of neighbors (only k == 1 is supported)
152
* \param[out] results array of results
153
*/
154
void
nearestKSearchBatch(
const
Queries
& queries,
int
k,
NeighborIndices
& results)
const
;
155
156
/** \brief Desroys octree and release all resources */
157
void
clear();
158
private
:
159
void
*impl;
160
bool
built_;
161
};
162
163
/** \brief Performs brute force radius search on GPU
164
* \param[in] cloud cloud where to search
165
* \param[in] query query point
166
* \param[in] radius radius
167
* \param[out] result indeces of points within give sphere
168
* \param[in] buffer buffer for intermediate results. Keep reference to it between calls to eliminate internal allocations
169
*/
170
PCL_EXPORTS
void
bruteForceRadiusSearchGPU
(
const
Octree::PointCloud
& cloud,
const
Octree::PointType
& query,
float
radius,
DeviceArray<int>
& result,
DeviceArray<int>
& buffer);
171
}
172
}
173
174
#endif
/* _PCL_GPU_OCTREE_ */
pcl_macros.h
Defines all the PCL and non-PCL macros used.
pcl
Definition:
convolution.h:46
point_types.h
pcl::gpu::Octree
Octree implementation on GPU.
Definition:
octree.hpp:57
pcl::gpu::Octree::ConstPtr
shared_ptr< const Octree > ConstPtr
Definition:
octree.hpp:69
pcl::gpu::NeighborIndices
Definition:
device_format.hpp:46
pcl::PointXYZ
A point structure representing Euclidean xyz coordinates.
Definition:
point_types.hpp:300
pcl::gpu::DeviceArray< PointType >
pcl::gpu::Octree::cloud_
const PointCloud * cloud_
Definition:
octree.hpp:89
pcl::gpu::bruteForceRadiusSearchGPU
PCL_EXPORTS void bruteForceRadiusSearchGPU(const Octree::PointCloud &cloud, const Octree::PointType &query, float radius, DeviceArray< int > &result, DeviceArray< int > &buffer)
Performs brute force radius search on GPU.
pcl::gpu::Octree::Ptr
shared_ptr< Octree > Ptr
Types.
Definition:
octree.hpp:68
memory.h
Defines functions, macros and traits for allocating and using memory.
PCL_EXPORTS
#define PCL_EXPORTS
Definition:
pcl_macros.h:331