Point Cloud Library (PCL)  1.9.1
internal.h
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Point Cloud Library (PCL) - www.pointclouds.org
5  * Copyright (c) 2011, Willow Garage, Inc.
6  *
7  * All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  *
13  * * Redistributions of source code must retain the above copyright
14  * notice, this list of conditions and the following disclaimer.
15  * * Redistributions in binary form must reproduce the above
16  * copyright notice, this list of conditions and the following
17  * disclaimer in the documentation and/or other materials provided
18  * with the distribution.
19  * * Neither the name of Willow Garage, Inc. nor the names of its
20  * contributors may be used to endorse or promote products derived
21  * from this software without specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
26  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
27  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
28  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
29  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
33  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34  * POSSIBILITY OF SUCH DAMAGE.
35  *
36  * @authors: Cedric Cagniart, Koen Buys, Anatoly Baksheev
37  */
38 
39 #ifndef PCL_GPU_PEOPLE_INTERNAL_H_
40 #define PCL_GPU_PEOPLE_INTERNAL_H_
41 
42 #include <pcl/gpu/containers/device_array.h>
43 #include <pcl/gpu/utils/safe_call.hpp>
44 #include <pcl/gpu/people/label_common.h>
45 #include <pcl/gpu/people/tree.h>
46 
48 
49 namespace pcl
50 {
51  namespace device
52  {
55 
60 
62 
63  /** \brief The intrinsic camera calibration **/
64  struct Intr
65  {
66  float fx, fy, cx, cy;
67  Intr () {}
68  Intr (float fx_, float fy_, float cx_, float cy_) : fx(fx_), fy(fy_), cx(cx_), cy(cy_) {}
69 
70  void setDefaultPPIfIncorrect(int cols, int rows)
71  {
72  cx = cx > 0 ? cx : cols/2 - 0.5f;
73  cy = cy > 0 ? cy : rows/2 - 0.5f;
74  }
75  };
76 
77  void smoothLabelImage(const Labels& src, const Depth& depth, Labels& dst, int num_parts, int patch_size, int depthThres);
78  void colorLMap(const Labels& labels, const DeviceArray<uchar4>& cmap, Image& rgb);
79  void mixedColorMap(const Labels& labels, const DeviceArray<uchar4>& map, const Image& rgba, Image& output);
80 
81  ////////////// connected components ///////////////////
82 
84  {
85  static void initEdges(int rows, int cols, DeviceArray2D<unsigned char>& edges);
86  //static void computeEdges(const Labels& labels, const Cloud& cloud, int num_parts, float sq_radius, DeviceArray2D<unsigned char>& edges);
87  static void computeEdges(const Labels& labels, const Depth& depth, int num_parts, float sq_radius, DeviceArray2D<unsigned char>& edges);
88  static void labelComponents(const DeviceArray2D<unsigned char>& edges, DeviceArray2D<int>& comps);
89  };
90 
91  void computeCloud(const Depth& depth, const Intr& intr, Cloud& cloud);
92 
93  void setZero(Mask& mask);
94  void prepareForeGroundDepth(const Depth& depth1, Mask& inverse_mask, Depth& depth2);
95 
96  float computeHue(int rgba);
97  void computeHueWithNans(const Image& image, const Depth& depth, HueImage& hue);
98 
99  //void shs(const DeviceArray2D<float4> &cloud, float tolerance, const std::vector<int>& indices_in, float delta_hue, Mask& indices_out);
100 
101  struct Dilatation
102  {
104  enum
105  {
106  KSIZE_X = 5,
107  KSIZE_Y = 5,
110  };
111 
112  static void prepareRect5x5Kernel(Kernel& kernel);
113  static void invoke(const Mask& src, const Kernel& kernel, Mask& dst);
114  };
115 
116  /** \brief Struct that holds a single RDF tree in GPU **/
117  struct CUDATree
118  {
121 
123  int numNodes;
124 
127 
128  CUDATree (int treeHeight_, const std::vector<Node>& nodes, const std::vector<Label>& leaves);
129  };
130 
131  /** \brief Processor using multiple trees */
133  {
134  public:
135  /** \brief Constructor with default values, allocates multilmap device memory **/
136  MultiTreeLiveProc(int def_rows = 480, int def_cols = 640) : multilmap (def_rows, def_cols) {}
137  /** \brief Empty destructor **/
139 
140  void
141  process (const Depth& dmap, Labels& lmap);
142 
143  /** \brief same as process, but runs the trick of declaring as background any neighbor that is more than FGThresh away.**/
144  void
145  process (const Depth& dmap, Labels& lmap, int FGThresh);
146 
147  /** \brief output a probability map from the RDF.**/
148  void
149  processProb (const Depth& dmap, Labels& lmap, LabelProbability& prob, int FGThresh);
150 
151  std::vector<CUDATree> trees;
153  };
154 
155  /** \brief Implementation Class to process probability histograms on GPU **/
157  {
158  public:
159  /** \brief Default constructor **/
161  {
162  std::cout << "[pcl::device::ProbabilityProc:ProbabilityProc] : (D) : Constructor called" << std::endl;
163  //PCL_DEBUG("[pcl::device::ProbabilityProc:ProbabilityProc] : (D) : Constructor called");
164  }
165 
166  /** \brief Default destructor **/
168 
169  /** \brief This will merge the votes from the different trees into one final vote, including probabilistic's **/
170  void
171  CUDA_SelectLabel ( const Depth& depth, Labels& labels, LabelProbability& probabilities);
172 
173  /** \brief This will combine two probabilities according their weight **/
174  void
175  CUDA_CombineProb ( const Depth& depth, LabelProbability& probIn1, float weight1,
176  LabelProbability& probIn2, float weight2, LabelProbability& probOut);
177 
178  /** \brief This will sum a probability multiplied with it's weight **/
179  void
180  CUDA_WeightedSumProb ( const Depth& depth, LabelProbability& probIn, float weight, LabelProbability& probOut);
181 
182  /** \brief This will blur the input labelprobability with the given kernel **/
183  int
184  CUDA_GaussianBlur( const Depth& depth,
185  LabelProbability& probIn,
187  LabelProbability& probOut);
188  /** \brief This will blur the input labelprobability with the given kernel, this version avoids extended allocation **/
189  int
190  CUDA_GaussianBlur( const Depth& depth,
191  LabelProbability& probIn,
193  LabelProbability& probTemp,
194  LabelProbability& probOut);
195  };
196  }
197 }
198 
199 #endif /* PCL_GPU_PEOPLE_INTERNAL_H_ */
pcl
This file defines compatibility wrappers for low level I/O functions.
Definition: convolution.h:45
pcl::device::CUDATree::Label
pcl::gpu::people::trees::Label Label
Definition: internal.h:120
pcl::device::prepareForeGroundDepth
void prepareForeGroundDepth(const Depth &depth1, Mask &inverse_mask, Depth &depth2)
pcl::device::ConnectedComponents
Definition: internal.h:83
pcl::device::ConnectedComponents::computeEdges
static void computeEdges(const Labels &labels, const Depth &depth, int num_parts, float sq_radius, DeviceArray2D< unsigned char > &edges)
pcl::device::ProbabilityProc::ProbabilityProc
ProbabilityProc()
Default constructor.
Definition: internal.h:160
pcl::device::HueImage
DeviceArray2D< float > HueImage
Definition: internal.h:58
pcl::device::CUDATree::leaves_device
DeviceArray< Label > leaves_device
Definition: internal.h:126
pcl::device::computeHueWithNans
void computeHueWithNans(const Image &image, const Depth &depth, HueImage &hue)
pcl::device::Intr::Intr
Intr(float fx_, float fy_, float cx_, float cy_)
Definition: internal.h:68
pcl::device::computeHue
float computeHue(int rgba)
pcl::device::MultiTreeLiveProc::process
void process(const Depth &dmap, Labels &lmap)
pcl::gpu::DeviceArray2D
DeviceArray2D class
Definition: device_array.h:154
pcl::device::Intr
Camera intrinsics structure.
Definition: internal.h:67
pcl::device::Dilatation::Kernel
DeviceArray< unsigned char > Kernel
Definition: internal.h:103
pcl::device::MultiTreeLiveProc::multilmap
MultiLabels multilmap
Definition: internal.h:152
pcl::device::Intr::cx
float cx
Definition: internal.h:69
pcl::device::Dilatation
Definition: internal.h:101
pcl::device::smoothLabelImage
void smoothLabelImage(const Labels &src, const Depth &depth, Labels &dst, int num_parts, int patch_size, int depthThres)
pcl::device::Depth
DeviceArray2D< unsigned short > Depth
Definition: internal.h:56
pcl::device::MultiTreeLiveProc::trees
std::vector< CUDATree > trees
Definition: internal.h:151
pcl::device::ConnectedComponents::initEdges
static void initEdges(int rows, int cols, DeviceArray2D< unsigned char > &edges)
pcl::device::Dilatation::invoke
static void invoke(const Mask &src, const Kernel &kernel, Mask &dst)
pcl::device::MultiTreeLiveProc::~MultiTreeLiveProc
~MultiTreeLiveProc()
Empty destructor.
Definition: internal.h:138
pcl::device::MultiLabels
DeviceArray2D< char4 > MultiLabels
Definition: internal.h:61
pcl::device::Dilatation::ANCH_X
@ ANCH_X
Definition: internal.h:108
pcl::device::ProbabilityProc::CUDA_GaussianBlur
int CUDA_GaussianBlur(const Depth &depth, LabelProbability &probIn, DeviceArray< float > &kernel, LabelProbability &probOut)
This will blur the input labelprobability with the given kernel.
pcl::device::Dilatation::ANCH_Y
@ ANCH_Y
Definition: internal.h:109
pcl::device::CUDATree
Struct that holds a single RDF tree in GPU.
Definition: internal.h:117
pcl::device::Cloud
DeviceArray2D< float4 > Cloud
Definition: internal.h:53
pcl::device::ProbabilityProc::CUDA_SelectLabel
void CUDA_SelectLabel(const Depth &depth, Labels &labels, LabelProbability &probabilities)
This will merge the votes from the different trees into one final vote, including probabilistic's.
pcl::device::CUDATree::numNodes
int numNodes
Definition: internal.h:123
pcl::device::Image
DeviceArray2D< uchar4 > Image
Definition: internal.h:54
pcl::device::CUDATree::nodes_device
DeviceArray< Node > nodes_device
Definition: internal.h:125
pcl::device::Intr::cy
float cy
Definition: internal.h:69
pcl::gpu::people::NUM_PARTS
@ NUM_PARTS
Definition: label_common.h:61
pcl::gpu::people::trees::Node
Definition: tree.h:92
pcl::device::CUDATree::treeHeight
int treeHeight
Definition: internal.h:122
pcl::device::CUDATree::Node
pcl::gpu::people::trees::Node Node
Definition: internal.h:119
pcl::device::Dilatation::KSIZE_X
@ KSIZE_X
Definition: internal.h:106
pcl::gpu::DeviceArray
DeviceArray class
Definition: device_array.h:57
pcl::device::colorLMap
void colorLMap(const Labels &labels, const DeviceArray< uchar4 > &cmap, Image &rgb)
pcl::device::MultiTreeLiveProc::MultiTreeLiveProc
MultiTreeLiveProc(int def_rows=480, int def_cols=640)
Constructor with default values, allocates multilmap device memory.
Definition: internal.h:136
pcl::device::ProbabilityProc::CUDA_CombineProb
void CUDA_CombineProb(const Depth &depth, LabelProbability &probIn1, float weight1, LabelProbability &probIn2, float weight2, LabelProbability &probOut)
This will combine two probabilities according their weight.
pcl::device::computeCloud
void computeCloud(const Depth &depth, const Intr &intr, Cloud &cloud)
pcl::device::ProbabilityProc
Implementation Class to process probability histograms on GPU.
Definition: internal.h:156
pcl::device::Dilatation::prepareRect5x5Kernel
static void prepareRect5x5Kernel(Kernel &kernel)
pcl::device::Intr::fy
float fy
Definition: internal.h:69
pcl::device::ProbabilityProc::CUDA_WeightedSumProb
void CUDA_WeightedSumProb(const Depth &depth, LabelProbability &probIn, float weight, LabelProbability &probOut)
This will sum a probability multiplied with it's weight.
pcl::device::ProbabilityProc::~ProbabilityProc
~ProbabilityProc()
Default destructor.
Definition: internal.h:167
pcl::device::Mask
DeviceArray2D< unsigned char > Mask
Definition: internal.h:59
pcl::gpu::people::trees::Label
uint8_t Label
Definition: tree.h:74
pcl::device::CUDATree::CUDATree
CUDATree(int treeHeight_, const std::vector< Node > &nodes, const std::vector< Label > &leaves)
pcl::device::MultiTreeLiveProc::processProb
void processProb(const Depth &dmap, Labels &lmap, LabelProbability &prob, int FGThresh)
output a probability map from the RDF.
pcl::device::Dilatation::KSIZE_Y
@ KSIZE_Y
Definition: internal.h:107
pcl::device::Labels
DeviceArray2D< unsigned char > Labels
Definition: internal.h:57
pcl::device::Intr::fx
float fx
Definition: internal.h:69
pcl::device::Intr::setDefaultPPIfIncorrect
void setDefaultPPIfIncorrect(int cols, int rows)
Definition: internal.h:70
pcl::kernel
Definition: kernel.h:45
pcl::device::MultiTreeLiveProc
Processor using multiple trees.
Definition: internal.h:132
pcl::device::ConnectedComponents::labelComponents
static void labelComponents(const DeviceArray2D< unsigned char > &edges, DeviceArray2D< int > &comps)
pcl::device::Intr::Intr
Intr()
Definition: internal.h:67
pcl::device::mixedColorMap
void mixedColorMap(const Labels &labels, const DeviceArray< uchar4 > &map, const Image &rgba, Image &output)
pcl::device::setZero
void setZero(Mask &mask)