Point Cloud Library (PCL)  1.9.1
people_detector.h
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: Koen Buys
35  */
36 
37 #ifndef PCL_GPU_PEOPLE_PERSON_H_
38 #define PCL_GPU_PEOPLE_PERSON_H_
39 
40 #include <iostream>
41 #include <sstream>
42 #include <fstream>
43 
44 #include <pcl/point_types.h>
45 #include <pcl/console/print.h>
46 #include <pcl/gpu/containers/device_array.h>
47 #include <pcl/gpu/people/label_common.h>
48 #include <pcl/gpu/people/tree.h>
49 #include <pcl/gpu/people/person_attribs.h>
50 //#include <opencv2/core/core.hpp>
51 
52 #include <pcl/gpu/people/bodyparts_detector.h>
53 #include <pcl/gpu/people/face_detector.h>
54 #include <pcl/gpu/people/organized_plane_detector.h>
55 #include <pcl/gpu/people/probability_processor.h>
56 
57 namespace pcl
58 {
59  namespace gpu
60  {
61  namespace people
62  {
63  /*
64  struct OtherDetector
65  {
66  typedef boost::shared_ptr<OtherDetector> Ptr;
67  };
68  */
69  class PCL_EXPORTS PeopleDetector
70  {
71  public:
72  typedef boost::shared_ptr<PeopleDetector> Ptr;
73 
78 
79  // ALL THE DETECTOR OBJECTS
83  //OtherDetector::Ptr other_detector_;
84 
85  // ALL THE OTHER PEOPLE STUFF
88 
89  /** \brief Class constructor. */
90  PeopleDetector ();
91 
92  /** \brief Class destructor. */
94 
95  /** \brief User must set non standard intrinsics */
96  void
97  setIntrinsics (float fx, float fy, float cx = -1, float cy = -1);
98 
99  /** \brief Possible will be removed because of extra overheads */
100  int
101  process (const PointCloud<PointTC>::ConstPtr &cloud);
102 
103  int
104  processProb (const PointCloud<PointTC>::ConstPtr &cloud);
105 
106  int
107  process (const Depth& depth, const Image& rgba);
108 
109  /** \brief Set the tolerance for the delta on the Hue in Seeded Hue Segmentation step */
110  inline void
111  setDeltaHueTolerance (unsigned int delta_hue_tolerance)
112  {
113  delta_hue_tolerance_ = delta_hue_tolerance;
114  }
115 
116  /** \brief Get the tolerance for the delta on the Hue in Seeded Hue Segmentation step, defaults to 5 */
117  inline unsigned int
119  {
120  return (delta_hue_tolerance_);
121  }
122 
123  /** \brief Class getName method. */
124  inline const std::string getClassName () const { return "PeopleDetector"; }
125 
129 
130  /** \brief indicates first time callback (allows for tracking features to start from second frame) **/
132  float fx_, fy_, cx_, cy_;
133  unsigned int delta_hue_tolerance_;
134 
136 
142 
144 
146 
149 
152 
153  int
154  process ();
155 
156  /**
157  * \brief Process the depth based on probabilities supporting tracking, person specific files used
158  **/
159  int
160  processProb ();
161 
162  void
163  allocate_buffers (int rows = 480, int cols = 640);
164 
165  void
166  shs5 (const pcl::PointCloud<PointT> &cloud, const std::vector<int>& indices, unsigned char *mask);
167 
168  //!!! only for debug purposes TODO: remove this.
169  friend class PeoplePCDApp;
170  };
171  }
172  }
173 }
174 #endif // PCL_GPU_PEOPLE_PERSON_H_
pcl::gpu::people::OrganizedPlaneDetector::Ptr
boost::shared_ptr< OrganizedPlaneDetector > Ptr
Definition: organized_plane_detector.h:62
pcl
This file defines compatibility wrappers for low level I/O functions.
Definition: convolution.h:45
pcl::gpu::people::PeopleDetector::Hue
DeviceArray2D< float > Hue
Definition: people_detector.h:128
point_types.h
pcl::gpu::people::PeopleDetector::Ptr
boost::shared_ptr< PeopleDetector > Ptr
Definition: people_detector.h:72
pcl::gpu::people::PeopleDetector::org_plane_detector_
OrganizedPlaneDetector::Ptr org_plane_detector_
Definition: people_detector.h:81
pcl::gpu::people::PeopleDetector::~PeopleDetector
~PeopleDetector()
Class destructor.
Definition: people_detector.h:93
pcl::gpu::DeviceArray2D< unsigned short >
pcl::gpu::people::PeopleDetector::rdf_detector_
RDFBodyPartsDetector::Ptr rdf_detector_
Definition: people_detector.h:80
pcl::PointCloud
PointCloud represents the base class in PCL for storing collections of 3D points.
Definition: projection_matrix.h:53
pcl::gpu::people::PeopleDetector::fy_
float fy_
Definition: people_detector.h:132
pcl::gpu::people::PeopleDetector::Depth
DeviceArray2D< unsigned short > Depth
Definition: people_detector.h:76
pcl::gpu::people::PeopleDetector::cloud_host_
PointCloud< PointT > cloud_host_
Definition: people_detector.h:137
pcl::gpu::people::PeopleDetector::face_detector_
FaceDetector::Ptr face_detector_
Definition: people_detector.h:82
pcl::gpu::people::PeopleDetector
Definition: people_detector.h:69
pcl::PointXYZRGBA
A point structure representing Euclidean xyz coordinates, and the RGBA color.
Definition: point_types.hpp:552
pcl::gpu::people::PeopleDetector::setDeltaHueTolerance
void setDeltaHueTolerance(unsigned int delta_hue_tolerance)
Set the tolerance for the delta on the Hue in Seeded Hue Segmentation step.
Definition: people_detector.h:111
pcl::gpu::people::PeopleDetector::depth_device1_
Depth depth_device1_
Definition: people_detector.h:147
pcl::PointXYZ
A point structure representing Euclidean xyz coordinates.
Definition: point_types.hpp:287
pcl::gpu::people::PeopleDetector::hue_host_
PointCloud< float > hue_host_
Definition: people_detector.h:139
pcl::gpu::people::PeopleDetector::Labels
DeviceArray2D< unsigned char > Labels
Definition: people_detector.h:126
pcl::gpu::DeviceArray< unsigned char >
pcl::gpu::people::PeopleDetector::first_iteration_
bool first_iteration_
indicates first time callback (allows for tracking features to start from second frame)
Definition: people_detector.h:131
pcl::gpu::people::PeopleDetector::fg_mask_grown_
Mask fg_mask_grown_
Definition: people_detector.h:151
pcl::gpu::people::ProbabilityProcessor::Ptr
boost::shared_ptr< ProbabilityProcessor > Ptr
Definition: probability_processor.h:63
pcl::gpu::people::PeopleDetector::probability_processor_
ProbabilityProcessor::Ptr probability_processor_
Definition: people_detector.h:87
pcl::gpu::people::FaceDetector::Ptr
boost::shared_ptr< FaceDetector > Ptr
Definition: face_detector.h:61
pcl::gpu::people::PeopleDetector::depth_host_
PointCloud< unsigned short > depth_host_
Definition: people_detector.h:140
pcl::gpu::people::PeopleDetector::hue_device_
Hue hue_device_
Definition: people_detector.h:145
pcl::gpu::people::PeopleDetector::getClassName
const std::string getClassName() const
Class getName method.
Definition: people_detector.h:124
pcl::PointCloud::ConstPtr
boost::shared_ptr< const PointCloud< PointT > > ConstPtr
Definition: point_cloud.h:429
pcl::gpu::people::PeopleDetector::Image
DeviceArray2D< pcl::RGB > Image
Definition: people_detector.h:77
pcl::gpu::people::PeopleDetector::cloud_host_color_
PointCloud< PointTC > cloud_host_color_
Definition: people_detector.h:138
pcl::gpu::people::PeopleDetector::depth_device2_
Depth depth_device2_
Definition: people_detector.h:148
pcl::gpu::people::RDFBodyPartsDetector::Ptr
boost::shared_ptr< RDFBodyPartsDetector > Ptr
Definition: bodyparts_detector.h:68
pcl::gpu::people::PeopleDetector::Mask
DeviceArray2D< unsigned char > Mask
Definition: people_detector.h:127
pcl::gpu::people::PeopleDetector::kernelRect5x5_
DeviceArray< unsigned char > kernelRect5x5_
Definition: people_detector.h:135
pcl::gpu::people::PeopleDetector::fg_mask_
Mask fg_mask_
Definition: people_detector.h:150
pcl::gpu::people::PeopleDetector::PointTC
pcl::PointXYZRGBA PointTC
Definition: people_detector.h:74
pcl::gpu::people::PeopleDetector::getDeltaHueTolerance
unsigned int getDeltaHueTolerance() const
Get the tolerance for the delta on the Hue in Seeded Hue Segmentation step, defaults to 5.
Definition: people_detector.h:118
pcl::gpu::people::PeopleDetector::cloud_device_
DeviceArray2D< PointT > cloud_device_
Definition: people_detector.h:143
pcl::gpu::people::PeopleDetector::person_attribs_
PersonAttribs::Ptr person_attribs_
Definition: people_detector.h:86
pcl::gpu::people::PeopleDetector::delta_hue_tolerance_
unsigned int delta_hue_tolerance_
Definition: people_detector.h:133
pcl::gpu::people::PeopleDetector::PointT
pcl::PointXYZ PointT
Definition: people_detector.h:75
pcl::gpu::people::PersonAttribs::Ptr
boost::shared_ptr< PersonAttribs > Ptr
Definition: person_attribs.h:20
pcl::gpu::people::PeopleDetector::flowermat_host_
PointCloud< unsigned char > flowermat_host_
Definition: people_detector.h:141