Point Cloud Library (PCL)  1.8.1
label_common.h
1 /*
2  * Software License Agreement (BSD License)
3  *
4  * Point Cloud Library (PCL) - www.pointclouds.org
5  * Copyright (c) 2010-2012, 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  * $Id: $
37  * @author: Koen Buys
38  */
39 
40 #ifndef PCL_GPU_PEOPLE_LABEL_COMMON_H_
41 #define PCL_GPU_PEOPLE_LABEL_COMMON_H_
42 
43 #include <pcl/gpu/containers/device_array.h>
44 #include <cuda_runtime.h> // for float4, uchar4, delete this in future
45 
46 namespace pcl
47 {
48  namespace gpu
49  {
50  namespace people
51  {
52  // Some types for the tree
53  enum
54  {
55  NO_CHILD = -3,
56  LEAF = -2,
57  ROOT = -1,
58  NO_DATA = 255 /** \brief We have no depth data for this part of the image **/
59  };
60 
61  enum { NUM_PARTS = 25 }; /** \brief We have 25 body parts defined **/
62  enum { MAX_CHILD = 4 }; /** \brief a parent node has maximum 4 children **/
63  enum { NR_TREES = 4 }; /** \brief The maximum supported number of trees **/
64 
65  // Some defines for geometry
66  enum { FOCAL = 525 }; /** \brief Focal length of rgb camera in pixels **/
67  enum { WIDTH = 640 };
68  enum { HEIGHT = 480 };
69  enum { RATIO = WIDTH/HEIGHT };
70  enum { XML_VERSION = 1}; /** \brief This indicates the current used xml file version (for people lib only) **/
71 
72  enum { NUM_ATTRIBS = 2000 };
73  enum { NUM_LABELS = 32 }; /** \brief Our code is forseen to use maximal use 32 labels **/
74 
75  /** @todo implement label 25 to 29 **/
76  enum part_t
77  {
78  Lfoot = 0,
79  Lleg = 1,
80  Lknee = 2,
81  Lthigh = 3,
82  Rfoot = 4,
83  Rleg = 5,
84  Rknee = 6,
85  Rthigh = 7,
86  Rhips = 8,
87  Lhips = 9,
88  Neck = 10,
89  Rarm = 11,
90  Relbow = 12,
91  Rforearm = 13,
92  Rhand = 14,
93  Larm = 15,
94  Lelbow = 16,
95  Lforearm = 17,
96  Lhand = 18,
97  FaceLB = 19,
98  FaceRB = 20,
99  FaceLT = 21,
100  FaceRT = 22,
101  Rchest = 23,
102  Lchest = 24,
103  Lshoulder = 25,
104  Rshoulder = 26,
106  Ceiling = 28,
108  Plane = 30,
109  NOLABEL = 31
110  };
111 
114 
119 
120  /**
121  * @brief This LUT contains the max primary eigenvalue for each part
122  * @todo read this from XML file
123  **/
124  static const float LUT_max_part_size[] =
125  {
126  0.5f, // 0 Lfoot
127  0.7f, // 1 Lleg
128  0.6f, // 2 Lknee
129  0.6f, // 3 Lthigh
130  0.5f, // 4 Rfoot
131  0.7f, // 5 Rleg
132  0.6f, // 6 Rknee
133  0.6f, // 7 Rthigh
134  0.9f, // 8 Rhips
135  0.9f, // 9 Lhips
136  0.5f, // 10 Neck
137  0.7f, // 11 Rarm
138  0.5f, // 12 Relbow
139  0.7f, // 13 Rforearm
140  0.5f, // 14 Rhand
141  0.7f, // 15 Larm
142  0.5f, // 16 Lelbow
143  0.7f, // 17 Lforearm
144  0.5f, // 18 Lhand
145  0.5f, // 19 FaceLB
146  0.5f, // 20 FaceRB
147  0.5f, // 21 FaceLT
148  0.5f, // 22 FaceRT
149  0.9f, // 23 Rchest
150  0.9f // 24 Lchest
151  };
152 
153  /**
154  * @brief This LUT contains the ideal lenght between this part and his children
155  **/
156  static const float LUT_ideal_length[][4] =
157  {
158  { -1.0f, -1.0f, -1.0f, -1.0f}, // 0 Lfoot
159  { 0.2f, -1.0f, -1.0f, -1.0f}, // 1 Lleg
160  { 0.2f, -1.0f, -1.0f, -1.0f}, // 2 Lknee
161  { 0.3f, -1.0f, -1.0f, -1.0f}, // 3 Lthigh
162  { -1.0f, -1.0f, -1.0f, -1.0f}, // 4 Rfoot
163  { 0.2f, -1.0f, -1.0f, -1.0f}, // 5 Rleg
164  { 0.2f, -1.0f, -1.0f, -1.0f}, // 6 Rknee
165  { 0.3f, -1.0f, -1.0f, -1.0f}, // 7 Rthigh
166  { 0.3f, -1.0f, -1.0f, -1.0f}, // 8 Rhips
167  { 0.3f, -1.0f, -1.0f, -1.0f}, // 9 Lhips
168  { 0.15f, 0.15f, 0.2f, 0.2f}, // 10 Neck
169  { 0.15f, -1.0f, -1.0f, -1.0f}, // 11 Rarm
170  { 0.1f, -1.0f, -1.0f, -1.0f}, // 12 Relbow
171  { 0.15f, -1.0f, -1.0f, -1.0f}, // 13 Rforearm
172  { -1.0f, -1.0f, -1.0f, -1.0f}, // 14 Rhand
173  { 0.15f, -1.0f, -1.0f, -1.0f}, // 15 Larm
174  { 0.1f, -1.0f, -1.0f, -1.0f}, // 16 Lelbow
175  { 0.15f, -1.0f, -1.0f, -1.0f}, // 17 Lforearm
176  { -1.0f, -1.0f, -1.0f, -1.0f}, // 18 Lhand
177  { 0.15f, -1.0f, -1.0f, -1.0f}, // 19 FaceLB
178  { 0.15f, -1.0f, -1.0f, -1.0f}, // 20 FaceRB
179  { -1.0f, -1.0f, -1.0f, -1.0f}, // 21 FaceLT
180  { -1.0f, -1.0f, -1.0f, -1.0f}, // 22 FaceRT
181  { 0.3f, 0.3f, -1.0f, -1.0f}, // 23 Rchest
182  { 0.3f, 0.3f, -1.0f, -1.0f} // 24 Lchest
183  };
184 
185  /**
186  * @brief This LUT contains the max lenght between this part and his children
187  **/
188  static const float LUT_max_length_offset[][4] =
189  {
190  { 0.15f, 0.15f, 0.15f, 0.15f}, // 0 Lfoot
191  { 0.15f, 0.15f, 0.15f, 0.15f}, // 1 Lleg
192  { 0.15f, 0.15f, 0.15f, 0.15f}, // 2 Lknee
193  { 0.15f, 0.15f, 0.15f, 0.15f}, // 3 Lthigh
194  { 0.15f, 0.15f, 0.15f, 0.15f}, // 4 Rfoot
195  { 0.15f, 0.15f, 0.15f, 0.15f}, // 5 Rleg
196  { 0.15f, 0.15f, 0.15f, 0.15f}, // 6 Rknee
197  { 0.15f, 0.15f, 0.15f, 0.15f}, // 7 Rthigh
198  { 0.15f, 0.15f, 0.15f, 0.15f}, // 8 Rhips
199  { 0.15f, 0.15f, 0.15f, 0.15f}, // 9 Lhips
200  { 0.15f, 0.15f, 0.15f, 0.15f}, // 10 Neck
201  { 0.15f, 0.15f, 0.15f, 0.15f}, // 11 Rarm
202  { 0.15f, 0.15f, 0.15f, 0.15f}, // 12 Relbow
203  { 0.15f, 0.15f, 0.15f, 0.15f}, // 13 Rforearm
204  { 0.15f, 0.15f, 0.15f, 0.15f}, // 14 Rhand
205  { 0.15f, 0.15f, 0.15f, 0.15f}, // 15 Larm
206  { 0.15f, 0.15f, 0.15f, 0.15f}, // 16 Lelbow
207  { 0.15f, 0.15f, 0.15f, 0.15f}, // 17 Lforearm
208  { 0.15f, 0.15f, 0.15f, 0.15f}, // 18 Lhand
209  { 0.15f, 0.15f, 0.15f, 0.15f}, // 19 FaceLB
210  { 0.15f, 0.15f, 0.15f, 0.15f}, // 20 FaceRB
211  { 0.3f, 0.15f, 0.15f, 0.15f}, // 21 FaceLT
212  { 0.3f, 0.15f, 0.15f, 0.15f}, // 22 FaceRT
213  { 0.15f, 0.15f, 0.15f, 0.15f}, // 23 Rchest
214  { 0.15f, 0.15f, 0.15f, 0.15f} // 24 Lchest
215  };
216 
217  /**
218  * @brief This LUT contains the number of children for each parent
219  **/
220  static const unsigned int LUT_nr_children[] =
221  {
222  0, // 0 Lfoot
223  1, // 1 Lleg
224  1, // 2 Lknee
225  1, // 3 Lthigh
226  0, // 4 Rfoot
227  1, // 5 Rleg
228  1, // 6 Rknee
229  1, // 7 Rthigh
230  1, // 8 Rhips
231  1, // 9 Lhips
232  4, // 10 Neck
233  1, // 11 Rarm
234  1, // 12 Relbow
235  1, // 13 Rforearm
236  0, // 14 Rhand
237  1, // 15 Larm
238  1, // 16 Lelbow
239  1, // 17 Lforearm
240  0, // 18 Lhand
241  1, // 19 FaceLB
242  1, // 20 FaceRB
243  0, // 21 FaceLT
244  0, // 22 FaceRT
245  2, // 23 Rchest
246  2 // 24 Lchest
247  };
248  } // End namespace people
249  } // End namespace gpu
250 } // End namespace pcl
251 
252 
253 // All typedefs to be used in device name space:
254 // Moved to common because of multiple declarations conflicting
255 // TODO solve this for Image, also declared as pcl::RGB
256 namespace pcl
257 {
258  namespace device
259  {
261  {
262  float probs[pcl::gpu::people::NUM_LABELS]; /** \brief A single float probability for each body part **/
263  };
264 
266 
267  }
268 }
269 
270 /** @TODO get this to work:
271 std::string part_k[NUM_PARTS] = {"Lfoot","Lleg", "Lknee","Lthigh",
272  "Rfoot","Rleg","Rknee","Rthigh",
273  "Rhips","Lhips","Neck",
274  "Rarm","Relbow","Rforearm","Rhand",
275  "Larm","Lelbow","Lforearm","Lhand",
276  "FaceLB","FaceRB","FaceLT","FaceRT",
277  "Rchest","Lchest"};
278 
279 inline std::ostream& operator << (std::ostream& os, const part_t& p)
280 {
281  os << part_k[(int) p];
282  return (os);
283 }
284  **/
285 
286 #endif
DeviceArray2D< uchar4 > Image
Definition: label_common.h:113
static const float LUT_ideal_length[][4]
This LUT contains the ideal lenght between this part and his children.
Definition: label_common.h:156
part_t
Our code is forseen to use maximal use 32 labels.
Definition: label_common.h:76
DeviceArray2D class
Definition: device_array.h:154
DeviceArray2D< unsigned char > Labels
Definition: label_common.h:116
DeviceArray2D< unsigned char > Mask
Definition: label_common.h:118
static const float LUT_max_part_size[]
This LUT contains the max primary eigenvalue for each part.
Definition: label_common.h:124
DeviceArray2D< unsigned short > Depth
Definition: label_common.h:115
DeviceArray2D< prob_histogram > LabelProbability
Definition: label_common.h:265
static const float LUT_max_length_offset[][4]
This LUT contains the max lenght between this part and his children.
Definition: label_common.h:188
static const unsigned int LUT_nr_children[]
This LUT contains the number of children for each parent.
Definition: label_common.h:220
DeviceArray2D< float > HueImage
Definition: label_common.h:117
float probs[pcl::gpu::people::NUM_LABELS]
Definition: label_common.h:262
DeviceArray2D< float4 > Cloud
Definition: label_common.h:112