Point Cloud Library (PCL) 1.12.0
person_classifier.h
1/*
2 * Software License Agreement (BSD License)
3 *
4 * Point Cloud Library (PCL) - www.pointclouds.org
5 * Copyright (c) 2013-, Open Perception, 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 the copyright holder(s) 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 * person_classifier.h
37 * Created on: Nov 30, 2012
38 * Author: Matteo Munaro
39 */
40
41#pragma once
42
43#include <pcl/people/person_cluster.h>
44#include <pcl/people/hog.h>
45
46namespace pcl
47{
48 namespace people
49 {
50 template <typename PointT> class PersonClassifier;
51
52 template <typename PointT>
54 {
55 protected:
56
57 /** \brief Height of the image patch to classify. */
59
60 /** \brief Width of the image patch to classify. */
62
63 /** \brief SVM offset. */
65
66 /** \brief SVM weights vector. */
67 std::vector<float> SVM_weights_;
68
69 public:
70
73
74 /** \brief Constructor. */
76
77 /** \brief Destructor. */
78 virtual ~PersonClassifier ();
79
80 /** \brief Load SVM parameters from a text file.
81 *
82 * \param[in] svm_filename Filename containing SVM parameters.
83 *
84 * \return true if SVM has been correctly set, false otherwise.
85 */
86 bool
87 loadSVMFromFile (std::string svm_filename);
88
89 /**
90 * \brief Set trained SVM for person confidence estimation.
91 *
92 * \param[in] window_height Detection window height.
93 * \param[in] window_width Detection window width.
94 * \param[in] SVM_weights SVM weights vector.
95 * \param[in] SVM_offset SVM offset.
96 */
97 void
98 setSVM (int window_height, int window_width, std::vector<float> SVM_weights, float SVM_offset);
99
100 /**
101 * \brief Get trained SVM for person confidence estimation.
102 *
103 * \param[out] window_height Detection window height.
104 * \param[out] window_width Detection window width.
105 * \param[out] SVM_weights SVM weights vector.
106 * \param[out] SVM_offset SVM offset.
107 */
108 void
109 getSVM (int& window_height, int& window_width, std::vector<float>& SVM_weights, float& SVM_offset);
110
111 /**
112 * \brief Resize an image represented by a pointcloud containing RGB information.
113 *
114 * \param[in] input_image A pointer to a pointcloud containing RGB information.
115 * \param[out] output_image A pointer to the output pointcloud.
116 * \param[in] width Output width.
117 * \param[in] height Output height.
118 */
119 void
120 resize (PointCloudPtr& input_image, PointCloudPtr& output_image,
121 int width, int height);
122
123 /**
124 * \brief Copies an image and makes a black border around it, where the source image is not present.
125 *
126 * \param[in] input_image A pointer to a pointcloud containing RGB information.
127 * \param[out] output_image A pointer to the output pointcloud.
128 * \param[in] xmin x coordinate of the top-left point of the bbox to copy from the input image.
129 * \param[in] ymin y coordinate of the top-left point of the bbox to copy from the input image.
130 * \param[in] width Output width.
131 * \param[in] height Output height.
132 */
133 void
134 copyMakeBorder (PointCloudPtr& input_image, PointCloudPtr& output_image,
135 int xmin, int ymin, int width, int height);
136
137 /**
138 * \brief Classify the given portion of image.
139 *
140 * \param[in] height The height of the image patch to classify, in pixels.
141 * \param[in] xc The x-coordinate of the center of the image patch to classify, in pixels.
142 * \param[in] yc The y-coordinate of the center of the image patch to classify, in pixels.
143 * \param[in] image The whole image (pointer to a point cloud containing RGB information) containing the object to classify.
144 * \return The classification score given by the SVM.
145 */
146 double
147 evaluate (float height, float xc, float yc, PointCloudPtr& image);
148
149 /**
150 * \brief Compute person confidence for a given PersonCluster.
151 *
152 * \param[in] image The input image (pointer to a point cloud containing RGB information).
153 * \param[in] bottom Theoretical bottom point of the cluster projected to the image.
154 * \param[in] top Theoretical top point of the cluster projected to the image.
155 * \param[in] centroid Theoretical centroid point of the cluster projected to the image.
156 * \param[in] vertical If true, the sensor is considered to be vertically placed (portrait mode).
157 * \return The person confidence.
158 */
159 double
160 evaluate (PointCloudPtr& image, Eigen::Vector3f& bottom, Eigen::Vector3f& top, Eigen::Vector3f& centroid,
161 bool vertical);
162 };
163 } /* namespace people */
164} /* namespace pcl */
165#include <pcl/people/impl/person_classifier.hpp>
PointCloud represents the base class in PCL for storing collections of 3D points.
Definition: point_cloud.h:173
shared_ptr< PointCloud< PointT > > Ptr
Definition: point_cloud.h:413
void copyMakeBorder(PointCloudPtr &input_image, PointCloudPtr &output_image, int xmin, int ymin, int width, int height)
Copies an image and makes a black border around it, where the source image is not present.
virtual ~PersonClassifier()
Destructor.
double evaluate(float height, float xc, float yc, PointCloudPtr &image)
Classify the given portion of image.
bool loadSVMFromFile(std::string svm_filename)
Load SVM parameters from a text file.
int window_height_
Height of the image patch to classify.
typename PointCloud::Ptr PointCloudPtr
void setSVM(int window_height, int window_width, std::vector< float > SVM_weights, float SVM_offset)
Set trained SVM for person confidence estimation.
std::vector< float > SVM_weights_
SVM weights vector.
void getSVM(int &window_height, int &window_width, std::vector< float > &SVM_weights, float &SVM_offset)
Get trained SVM for person confidence estimation.
int window_width_
Width of the image patch to classify.
void resize(PointCloudPtr &input_image, PointCloudPtr &output_image, int width, int height)
Resize an image represented by a pointcloud containing RGB information.