Point Cloud Library (PCL)  1.14.0-dev
internal.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_INTERNAL_HPP_
38 #define PCL_GPU_FEATURES_INTERNAL_HPP_
39 
40 #include <pcl/gpu/containers/device_array.h>
41 #include <pcl/gpu/octree/device_format.hpp>
42 
43 #include <cuda_runtime.h>
44 
45 #undef PI
46 #ifndef PI
47  #define PI 3.1415926535897931f
48 #endif
49 
50 namespace pcl
51 {
52  namespace device
53  {
57 
58  using PointType = float4;
59  using NormalType = float4;
60  using PointXYZRGB = float4;
61 
65 
67 
68  template <int N> struct Histogram
69  {
70  float histogram[N];
71  };
72 
77 
78  struct PPFSignature
79  {
80  float f1, f2, f3, f4;
81  float alpha_m;
82  };
83 
85  {
86  float f1, f2, f3, f4;
88  float alpha_m;
89  };
90 
92  {
93  union
94  {
96  struct
97  {
101  };
102  };
103  float pc1;
104  float pc2;
105  };
106 
107  // normals estimation
108  void computeNormals(const PointCloud& cloud, const NeighborIndices& nn_indices, Normals& normals);
109  void flipNormalTowardsViewpoint(const PointCloud& cloud, const float3& vp, Normals& normals);
110  void flipNormalTowardsViewpoint(const PointCloud& cloud, const Indices& indices, const float3& vp, Normals& normals);
111 
112  // pfh estimation
113  void repackToAosForPfh(const PointCloud& cloud, const Normals& normals, const NeighborIndices& neighbours, DeviceArray2D<float>& data_rpk, int& max_elems_rpk);
114  void computePfh125(const DeviceArray2D<float>& data_rpk, int max_elems_rpk, const NeighborIndices& neighbours, DeviceArray2D<PFHSignature125>& features);
115 
116  void repackToAosForPfhRgb(const PointCloud& cloud, const Normals& normals, const NeighborIndices& neighbours, DeviceArray2D<float>& data_rpk, int& max_elems_rpk);
117  void computePfhRgb250(const DeviceArray2D<float>& data_rpk, int max_elems_rpk, const NeighborIndices& neighbours, DeviceArray2D<PFHRGBSignature250>& features);
118 
119 
120  // fpfh estimation
121  void computeSPFH(const PointCloud& surface, const Normals& normals, const Indices& indices, const NeighborIndices& neighbours, DeviceArray2D<FPFHSignature33>& spfh33);
122  void computeFPFH(const PointCloud& cloud, const NeighborIndices& neighbours, const DeviceArray2D<FPFHSignature33>& spfh, DeviceArray2D<FPFHSignature33>& features);
123 
124  void computeFPFH(const PointCloud& cloud, const Indices& indices, const PointCloud& surface,
125  const NeighborIndices& neighbours, DeviceArray<int>& lookup, const DeviceArray2D<FPFHSignature33>& spfh, DeviceArray2D<FPFHSignature33>& features);
126 
127  int computeUniqueIndices(std::size_t surface_size, const NeighborIndices& neighbours, DeviceArray<int>& unique_indices, DeviceArray<int>& lookup);
128 
129  // ppf estimation
130  void computePPF(const PointCloud& input, const Normals& normals, const Indices& indices, DeviceArray<PPFSignature>& output);
131  void computePPFRGB(const PointXYZRGBCloud& input, const Normals& normals, const Indices& indices, DeviceArray<PPFRGBSignature>& output);
132  void computePPFRGBRegion(const PointXYZRGBCloud& cloud, const Normals& normals, const Indices& indices,
133  const NeighborIndices& nn_indices, DeviceArray<PPFRGBSignature>& output);
134 
135  //PrincipalCurvatures estimation
136  void computePointPrincipalCurvatures(const Normals& normals, const Indices& indices, const NeighborIndices& neighbours,
137  DeviceArray<PrincipalCurvatures>& output, DeviceArray2D<float>& proj_normals_buf);
138 
139 
140  //vfh estimation
141  template<typename PointT> void compute3DCentroid(const DeviceArray<PointT>& cloud, float3& centroid);
142  template<typename PointT> void compute3DCentroid(const DeviceArray<PointT>& cloud, const Indices& indices, float3& centroid);
143 
144  template<typename PointT> float3 getMaxDistance(const DeviceArray<PointT>& cloud, const float3& pivot);
145  template<typename PointT> float3 getMaxDistance(const DeviceArray<PointT>& cloud, const Indices& indices, const float3& pivot);
146 
148  {
149  float3 xyz_centroid;
151  float3 viewpoint;
152 
156 
160 
162  };
163 
164  //spinimages estimation
165  void computeSpinImagesOrigigNormal(bool radial, bool angular, float support_angle_cos, const Indices& indices, const PointCloud& input_cloud, const Normals& input_normals,
166  const PointCloud& surface, const Normals& normals, const NeighborIndices& neighbours, int min_neighb, int image_width, float bin_size, PtrStep<float> output);
167 
168  void computeSpinImagesCustomAxes(bool radial, bool angular, float support_angle_cos, const Indices& indices, const PointCloud& input_cloud, const Normals& input_normals,
169  const PointCloud& surface, const Normals& normals, const NeighborIndices& neighbours, int min_neighb, int image_width, float bin_size, const float3& rotation_axis, PtrStep<float> output);
170 
171  void computeSpinImagesCustomAxesCloud(bool radial, bool angular, float support_angle_cos, const Indices& indices, const PointCloud& input_cloud, const Normals& input_normals,
172  const PointCloud& surface, const Normals& normals, const NeighborIndices& neighbours, int min_neighb, int image_width, float bin_size, const Normals& rotation_axes_cloud, PtrStep<float> output);
173 
174  void computeMask(const NeighborIndices& neighbours, int min_neighb, DeviceArray<unsigned char>& mask);
175  }
176 }
177 
178 #endif /* PCL_GPU_FEATURES_INTERNAL_HPP_ */
DeviceArray2D class
Definition: device_array.h:188
DeviceArray class
Definition: device_array.h:54
void computePfhRgb250(const DeviceArray2D< float > &data_rpk, int max_elems_rpk, const NeighborIndices &neighbours, DeviceArray2D< PFHRGBSignature250 > &features)
void computeSPFH(const PointCloud &surface, const Normals &normals, const Indices &indices, const NeighborIndices &neighbours, DeviceArray2D< FPFHSignature33 > &spfh33)
void computeFPFH(const PointCloud &cloud, const NeighborIndices &neighbours, const DeviceArray2D< FPFHSignature33 > &spfh, DeviceArray2D< FPFHSignature33 > &features)
void computeSpinImagesCustomAxesCloud(bool radial, bool angular, float support_angle_cos, const Indices &indices, const PointCloud &input_cloud, const Normals &input_normals, const PointCloud &surface, const Normals &normals, const NeighborIndices &neighbours, int min_neighb, int image_width, float bin_size, const Normals &rotation_axes_cloud, PtrStep< float > output)
void computePointPrincipalCurvatures(const Normals &normals, const Indices &indices, const NeighborIndices &neighbours, DeviceArray< PrincipalCurvatures > &output, DeviceArray2D< float > &proj_normals_buf)
void computePPFRGBRegion(const PointXYZRGBCloud &cloud, const Normals &normals, const Indices &indices, const NeighborIndices &nn_indices, DeviceArray< PPFRGBSignature > &output)
void flipNormalTowardsViewpoint(const PointCloud &cloud, const float3 &vp, Normals &normals)
void computePfh125(const DeviceArray2D< float > &data_rpk, int max_elems_rpk, const NeighborIndices &neighbours, DeviceArray2D< PFHSignature125 > &features)
float4 PointType
Definition: internal.hpp:58
int computeUniqueIndices(std::size_t surface_size, const NeighborIndices &neighbours, DeviceArray< int > &unique_indices, DeviceArray< int > &lookup)
void repackToAosForPfhRgb(const PointCloud &cloud, const Normals &normals, const NeighborIndices &neighbours, DeviceArray2D< float > &data_rpk, int &max_elems_rpk)
void repackToAosForPfh(const PointCloud &cloud, const Normals &normals, const NeighborIndices &neighbours, DeviceArray2D< float > &data_rpk, int &max_elems_rpk)
void compute3DCentroid(const DeviceArray< PointT > &cloud, float3 &centroid)
void computeMask(const NeighborIndices &neighbours, int min_neighb, DeviceArray< unsigned char > &mask)
void computeNormals(const PointCloud &cloud, const NeighborIndices &nn_indices, Normals &normals)
float3 getMaxDistance(const DeviceArray< PointT > &cloud, const float3 &pivot)
float4 PointXYZRGB
Definition: internal.hpp:60
float4 NormalType
Definition: internal.hpp:59
void computeSpinImagesCustomAxes(bool radial, bool angular, float support_angle_cos, const Indices &indices, const PointCloud &input_cloud, const Normals &input_normals, const PointCloud &surface, const Normals &normals, const NeighborIndices &neighbours, int min_neighb, int image_width, float bin_size, const float3 &rotation_axis, PtrStep< float > output)
void computeSpinImagesOrigigNormal(bool radial, bool angular, float support_angle_cos, const Indices &indices, const PointCloud &input_cloud, const Normals &input_normals, const PointCloud &surface, const Normals &normals, const NeighborIndices &neighbours, int min_neighb, int image_width, float bin_size, PtrStep< float > output)
void computePPF(const PointCloud &input, const Normals &normals, const Indices &indices, DeviceArray< PPFSignature > &output)
void computePPFRGB(const PointXYZRGBCloud &input, const Normals &normals, const Indices &indices, DeviceArray< PPFRGBSignature > &output)
void compute(DeviceArray< VFHSignature308 > &feature)