Point Cloud Library (PCL)  1.11.1-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 
161  void compute(DeviceArray<VFHSignature308>& feature);
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_ */
pcl::device::PPFRGBSignature
Definition: internal.hpp:84
pcl
Definition: convolution.h:46
pcl::device::PPFRGBSignature::f1
float f1
Definition: internal.hpp:86
pcl::device::repackToAosForPfhRgb
void repackToAosForPfhRgb(const PointCloud &cloud, const Normals &normals, const NeighborIndices &neighbours, DeviceArray2D< float > &data_rpk, int &max_elems_rpk)
pcl::device::computeSpinImagesOrigigNormal
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)
pcl::device::PPFSignature::f1
float f1
Definition: internal.hpp:80
pcl::device::VFHEstimationImpl::size_component
bool size_component
Definition: internal.hpp:158
pcl::device::PPFRGBSignature::alpha_m
float alpha_m
Definition: internal.hpp:88
pcl::device::computeSpinImagesCustomAxesCloud
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)
pcl::device::computePPFRGBRegion
void computePPFRGBRegion(const PointXYZRGBCloud &cloud, const Normals &normals, const Indices &indices, const NeighborIndices &nn_indices, DeviceArray< PPFRGBSignature > &output)
pcl::device::VFHEstimationImpl::normals
Normals normals
Definition: internal.hpp:155
pcl::gpu::DeviceArray2D
DeviceArray2D class
Definition: device_array.h:153
pcl::device::PrincipalCurvatures::principal_curvature
float principal_curvature[3]
Definition: internal.hpp:95
pcl::device::computeMask
void computeMask(const NeighborIndices &neighbours, int min_neighb, DeviceArray< unsigned char > &mask)
pcl::device::VFHEstimationImpl::normal_centroid
float3 normal_centroid
Definition: internal.hpp:150
pcl::device::PPFSignature::alpha_m
float alpha_m
Definition: internal.hpp:81
pcl::device::VFHEstimationImpl::compute
void compute(DeviceArray< VFHSignature308 > &feature)
pcl::device::computePPFRGB
void computePPFRGB(const PointXYZRGBCloud &input, const Normals &normals, const Indices &indices, DeviceArray< PPFRGBSignature > &output)
pcl::device::Histogram
Definition: internal.hpp:68
pcl::device::PPFSignature
Definition: internal.hpp:78
pcl::device::VFHEstimationImpl
Definition: internal.hpp:147
pcl::device::computeNormals
void computeNormals(const PointCloud &cloud, const NeighborIndices &nn_indices, Normals &normals)
pcl::device::repackToAosForPfh
void repackToAosForPfh(const PointCloud &cloud, const Normals &normals, const NeighborIndices &neighbours, DeviceArray2D< float > &data_rpk, int &max_elems_rpk)
pcl::device::PPFRGBSignature::b_ratio
float b_ratio
Definition: internal.hpp:87
pcl::device::computeSpinImagesCustomAxes
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)
pcl::gpu::NeighborIndices
Definition: device_format.hpp:46
pcl::device::PPFRGBSignature::f4
float f4
Definition: internal.hpp:86
pcl::device::VFHEstimationImpl::indices
Indices indices
Definition: internal.hpp:153
pcl::device::PointType
float4 PointType
Definition: internal.hpp:58
pcl::device::PPFRGBSignature::f2
float f2
Definition: internal.hpp:86
pcl::device::flipNormalTowardsViewpoint
void flipNormalTowardsViewpoint(const PointCloud &cloud, const float3 &vp, Normals &normals)
pcl::device::PPFSignature::f3
float f3
Definition: internal.hpp:80
pcl::device::compute3DCentroid
void compute3DCentroid(const DeviceArray< PointT > &cloud, float3 &centroid)
pcl::device::computeUniqueIndices
int computeUniqueIndices(std::size_t surface_size, const NeighborIndices &neighbours, DeviceArray< int > &unique_indices, DeviceArray< int > &lookup)
pcl::device::PrincipalCurvatures
Definition: internal.hpp:91
pcl::device::PrincipalCurvatures::pc1
float pc1
Definition: internal.hpp:103
pcl::device::computePointPrincipalCurvatures
void computePointPrincipalCurvatures(const Normals &normals, const Indices &indices, const NeighborIndices &neighbours, DeviceArray< PrincipalCurvatures > &output, DeviceArray2D< float > &proj_normals_buf)
pcl::gpu::DeviceArray
DeviceArray class
Definition: device_array.h:56
pcl::device::PrincipalCurvatures::principal_curvature_y
float principal_curvature_y
Definition: internal.hpp:99
pcl::device::PPFSignature::f4
float f4
Definition: internal.hpp:80
pcl::device::VFHEstimationImpl::normalize_distances
bool normalize_distances
Definition: internal.hpp:157
pcl::device::NormalType
float4 NormalType
Definition: internal.hpp:59
pcl::device::PrincipalCurvatures::principal_curvature_x
float principal_curvature_x
Definition: internal.hpp:98
pcl::device::PrincipalCurvatures::principal_curvature_z
float principal_curvature_z
Definition: internal.hpp:100
pcl::device::PPFRGBSignature::g_ratio
float g_ratio
Definition: internal.hpp:87
pcl::device::PointXYZRGB
float4 PointXYZRGB
Definition: internal.hpp:60
pcl::device::getMaxDistance
float3 getMaxDistance(const DeviceArray< PointT > &cloud, const float3 &pivot)
pcl::device::computePPF
void computePPF(const PointCloud &input, const Normals &normals, const Indices &indices, DeviceArray< PPFSignature > &output)
pcl::device::PPFRGBSignature::f3
float f3
Definition: internal.hpp:86
pcl::device::VFHEstimationImpl::viewpoint
float3 viewpoint
Definition: internal.hpp:151
pcl::device::PrincipalCurvatures::pc2
float pc2
Definition: internal.hpp:104
pcl::device::computePfh125
void computePfh125(const DeviceArray2D< float > &data_rpk, int max_elems_rpk, const NeighborIndices &neighbours, DeviceArray2D< PFHSignature125 > &features)
pcl::device::VFHEstimationImpl::xyz_centroid
float3 xyz_centroid
Definition: internal.hpp:149
pcl::device::PPFRGBSignature::r_ratio
float r_ratio
Definition: internal.hpp:87
pcl::device::computeFPFH
void computeFPFH(const PointCloud &cloud, const NeighborIndices &neighbours, const DeviceArray2D< FPFHSignature33 > &spfh, DeviceArray2D< FPFHSignature33 > &features)
pcl::gpu::PtrStep
Definition: kernel_containers.h:74
pcl::device::VFHEstimationImpl::normalize_bins
bool normalize_bins
Definition: internal.hpp:159
pcl::device::computePfhRgb250
void computePfhRgb250(const DeviceArray2D< float > &data_rpk, int max_elems_rpk, const NeighborIndices &neighbours, DeviceArray2D< PFHRGBSignature250 > &features)
pcl::device::Histogram::histogram
float histogram[N]
Definition: internal.hpp:70
pcl::device::VFHEstimationImpl::points
PointCloud points
Definition: internal.hpp:154
pcl::device::PPFSignature::f2
float f2
Definition: internal.hpp:80
pcl::device::computeSPFH
void computeSPFH(const PointCloud &surface, const Normals &normals, const Indices &indices, const NeighborIndices &neighbours, DeviceArray2D< FPFHSignature33 > &spfh33)