Point Cloud Library (PCL)  1.14.1-dev
features.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_FEATURES_HPP_
38 #define _PCL_GPU_FEATURES_HPP_
39 
40 #include <pcl/pcl_macros.h>
41 #include <pcl/point_types.h>
42 #include <pcl/gpu/containers/device_array.h>
43 #include <pcl/gpu/octree/device_format.hpp>
44 #include <pcl/gpu/octree/octree.hpp>
45 
46 namespace pcl
47 {
48  namespace gpu
49  {
50  ////////////////////////////////////////////////////////////////////////////////////////////
51  /** \brief @b Feature represents the base feature class. */
52 
54  {
55  public:
58 
62 
64 
65  void setInputCloud(const PointCloud& cloud);
66  void setSearchSurface(const PointCloud& surface);
67  void setIndices(const Indices& indices);
68  void setRadiusSearch(float radius, int max_results);
69  protected:
73  float radius_;
75 
77  };
78 
79  ////////////////////////////////////////////////////////////////////////////////////////////
80  /** \brief @b Feature represents the base feature class that takes normals as input also. */
81 
83  {
84  public:
85 
86  void setInputNormals(const Normals& normals);
87  protected:
89  };
90 
91  ////////////////////////////////////////////////////////////////////////////////////////////
92  /** \brief @b Class for normal estimation. */
94  {
95  public:
96  // float x, y, z, curvature; -> sizeof(PointXYZ) = 4 * sizeof(float)
98 
100  void compute(Normals& normals);
101  void setViewPoint(float vpx, float vpy, float vpz);
102  void getViewPoint(float& vpx, float& vpy, float& vpz) const;
103 
104  static void computeNormals(const PointCloud& cloud, const NeighborIndices& nn_indices, Normals& normals);
105  static void flipNormalTowardsViewpoint(const PointCloud& cloud, float vp_x, float vp_y, float vp_z, Normals& normals);
106  static void flipNormalTowardsViewpoint(const PointCloud& cloud, const Indices& indices, float vp_x, float vp_y, float vp_z, Normals& normals);
107  private:
108  float vpx_, vpy_, vpz_;
109  NeighborIndices nn_indices_;
110  };
111 
112  ////////////////////////////////////////////////////////////////////////////////////////////
113  /** \brief @b Class for PFH estimation. */
115  {
116  public:
117  void compute(const PointCloud& cloud, const Normals& normals, const NeighborIndices& neighb_indices, DeviceArray2D<PFHSignature125>& features);
119  private:
120  NeighborIndices nn_indices_;
121  DeviceArray2D<float> data_rpk;
122  int max_elems_rpk;
123  };
124 
125  ////////////////////////////////////////////////////////////////////////////////////////////
126  /** \brief @b Class for PFHRGB estimation. */
128  {
129  public:
130  using PointType = PointXYZ; //16 bytes for xyzrgb
131  void compute(const PointCloud& cloud, const Normals& normals, const NeighborIndices& neighb_indices, DeviceArray2D<PFHRGBSignature250>& features);
133  private:
134  NeighborIndices nn_indices_;
135  DeviceArray2D<float> data_rpk;
136  int max_elems_rpk;
137  };
138 
139  ////////////////////////////////////////////////////////////////////////////////////////////
140  /** \brief @b Class for FPFH estimation. */
142  {
143  public:
145 
147 
148  void compute(const PointCloud& cloud, const Normals& normals, const NeighborIndices& neighbours, DeviceArray2D<FPFHSignature33>& features);
149 
150  private:
151  NeighborIndices nn_indices_, nn_indices2_;
152 
153  DeviceArray<int> unique_indices_storage;
154  DeviceArray<int> lookup;
155 
157  };
158 
159  //////////////////////////////////////////////////////////////////////////////////////////////
160  ///** \brief @b Class for PPF estimation. */
162  {
163  public:
165  };
166 
167  //////////////////////////////////////////////////////////////////////////////////////////////
168  ///** \brief @b Class for PPFRGB estimation. */
169 
171  {
172  public:
173 
174  using PointType = PointXYZ; //16 bytes for xyzrgb
176  };
177 
178  //////////////////////////////////////////////////////////////////////////////////////////////
179  ///** \brief @b Class for PPFRGBRegion estimation. */
180 
182  {
183  public:
184  using PointType = PointXYZ; //16 bytes for xyzrgb
186 
187  private:
188  NeighborIndices nn_indices_;
189  };
190 
191 
192  //////////////////////////////////////////////////////////////////////////////////////////////
193  ///** \brief @b Class for PPFRGBRegion estimation. */
194 
196  {
197  public:
198 
200  private:
201  NeighborIndices nn_indices_;
202  DeviceArray2D<float> proj_normals_buf;
203  };
204 
205 
206  //////////////////////////////////////////////////////////////////////////////////////////////
207  ///** \brief @b Class for Viewpoint Feature Histogramm estimation. */
208 
210  {
211  public:
212 
213  enum
214  {
215  BINS1_F1 = 45,
216  BINT2_F2 = 45,
217  BINS3_F3 = 45,
218  BINS4_F4 = 45,
219  BINS_VP = 128
220  };
221 
223 
224  void setViewPoint(float vpx, float vpy, float vpz);
225  void getViewPoint(float& vpx, float& vpy, float& vpz) const;
226 
227  void setUseGivenNormal (bool use);
228  void setNormalToUse (const NormalType& normal);
229  void setUseGivenCentroid (bool use);
230  void setCentroidToUse (const PointType& centroid);
231 
232  void setNormalizeBins (bool normalize);
233  void setNormalizeDistance (bool normalize);
234  void setFillSizeComponent (bool fill_size);
235 
237  private:
238 
239  float vpx_, vpy_, vpz_;
240 
241  bool use_given_normal_;
242  bool use_given_centroid_;
243  bool normalize_bins_;
244  bool normalize_distances_;
245  bool size_component_;
246 
247  NormalType normal_to_use_;
248  PointType centroid_to_use_;
249  };
250 
251 
252  //////////////////////////////////////////////////////////////////////////////////////////////
253  ///** \brief @b Class for SpinImages estimation. */
254 
256  {
257  public:
259 
260  SpinImageEstimation (unsigned int image_width = 8,
261  double support_angle_cos = 0.0, // when 0, this is bogus, so not applied
262  unsigned int min_pts_neighb = 0);
263 
264  void setImageWidth (unsigned int bin_count);
265  void setSupportAngle (float support_angle_cos);
266  void setMinPointCountInNeighbourhood (unsigned int min_pts_neighb);
267  void setInputWithNormals (const PointCloud& input, const Normals& normals);
268  void setSearchSurfaceWithNormals (const PointCloud& surface, const Normals& normals);
269 
270  void setRotationAxis (const NormalType& axis);
271  void setInputRotationAxes (const Normals& axes);
273  void setAngularDomain (bool is_angular = true);
274  void setRadialStructure (bool is_radial = true);
275 
277 
278  private:
279  Normals input_normals_;
280  Normals rotation_axes_cloud_;
281 
282  bool is_angular_;
283 
284  NormalType rotation_axis_;
285  bool use_custom_axis_;
286 
287  /* use input normals as rotation axes*/
288  bool use_custom_axes_cloud_;
289 
290  bool is_radial_;
291 
292  unsigned int image_width_;
293  float support_angle_cos_;
294  unsigned int min_pts_neighb_;
295 
296  bool fake_surface_;
297 
298  NeighborIndices nn_indices_;
299  };
300  }
301 };
302 
303 #endif /* _PCL_GPU_FEATURES_HPP_ */
304 
305 
DeviceArray2D class
Definition: device_array.h:188
Class for FPFH estimation.
Definition: features.hpp:142
void compute(const PointCloud &cloud, const Normals &normals, const NeighborIndices &neighbours, DeviceArray2D< FPFHSignature33 > &features)
void compute(DeviceArray2D< FPFHSignature33 > &features)
Class for normal estimation.
Definition: features.hpp:94
void getViewPoint(float &vpx, float &vpy, float &vpz) const
static void computeNormals(const PointCloud &cloud, const NeighborIndices &nn_indices, Normals &normals)
static void flipNormalTowardsViewpoint(const PointCloud &cloud, const Indices &indices, float vp_x, float vp_y, float vp_z, Normals &normals)
static void flipNormalTowardsViewpoint(const PointCloud &cloud, float vp_x, float vp_y, float vp_z, Normals &normals)
void setViewPoint(float vpx, float vpy, float vpz)
void compute(Normals &normals)
Octree implementation on GPU.
Definition: octree.hpp:59
Class for PFH estimation.
Definition: features.hpp:115
void compute(const PointCloud &cloud, const Normals &normals, const NeighborIndices &neighb_indices, DeviceArray2D< PFHSignature125 > &features)
void compute(DeviceArray2D< PFHSignature125 > &features)
Class for PFHRGB estimation.
Definition: features.hpp:128
void compute(DeviceArray2D< PFHRGBSignature250 > &features)
void compute(const PointCloud &cloud, const Normals &normals, const NeighborIndices &neighb_indices, DeviceArray2D< PFHRGBSignature250 > &features)
void compute(DeviceArray< PPFSignature > &features)
void compute(DeviceArray< PPFRGBSignature > &features)
void compute(DeviceArray< PPFRGBSignature > &features)
void compute(DeviceArray< PrincipalCurvatures > &features)
void setImageWidth(unsigned int bin_count)
void setMinPointCountInNeighbourhood(unsigned int min_pts_neighb)
SpinImageEstimation(unsigned int image_width=8, double support_angle_cos=0.0, unsigned int min_pts_neighb=0)
void compute(DeviceArray2D< SpinImage > &features, DeviceArray< unsigned char > &mask)
void setSupportAngle(float support_angle_cos)
void setRadialStructure(bool is_radial=true)
void setSearchSurfaceWithNormals(const PointCloud &surface, const Normals &normals)
void setAngularDomain(bool is_angular=true)
void setInputWithNormals(const PointCloud &input, const Normals &normals)
void setRotationAxis(const NormalType &axis)
void setInputRotationAxes(const Normals &axes)
void getViewPoint(float &vpx, float &vpy, float &vpz) const
void setUseGivenNormal(bool use)
void setCentroidToUse(const PointType &centroid)
void setNormalizeBins(bool normalize)
void setNormalToUse(const NormalType &normal)
void compute(DeviceArray< VFHSignature308 > &feature)
void setNormalizeDistance(bool normalize)
void setUseGivenCentroid(bool use)
void setViewPoint(float vpx, float vpy, float vpz)
void setFillSizeComponent(bool fill_size)
Defines all the PCL implemented PointT point type structures.
Defines all the PCL and non-PCL macros used.
#define PCL_EXPORTS
Definition: pcl_macros.h:323
A point structure representing an N-D histogram.
A point structure representing Euclidean xyz coordinates.
Feature represents the base feature class that takes normals as input also.
Definition: features.hpp:83
void setInputNormals(const Normals &normals)
Feature represents the base feature class.
Definition: features.hpp:54
PointCloud cloud_
Definition: features.hpp:70
void setSearchSurface(const PointCloud &surface)
Indices indices_
Definition: features.hpp:72
void setInputCloud(const PointCloud &cloud)
PointXYZ NormalType
Definition: features.hpp:57
void setIndices(const Indices &indices)
void setRadiusSearch(float radius, int max_results)
PointCloud surface_
Definition: features.hpp:71