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