41#include <pcl/people/person_classifier.h>
43#ifndef PCL_PEOPLE_PERSON_CLASSIFIER_HPP_
44#define PCL_PEOPLE_PERSON_CLASSIFIER_HPP_
46template <
typename Po
intT>
49template <
typename Po
intT>
52template <
typename Po
intT>
bool
61 window_height_ = std::atoi(
line.substr(
tok_pos+1, std::string::npos -
tok_pos-1).c_str());
65 window_width_ = std::atoi(
line.substr(
tok_pos+1, std::string::npos -
tok_pos-1).c_str());
69 SVM_offset_ = std::atof(
line.substr(
tok_pos+1, std::string::npos -
tok_pos-1).c_str());
82 if (SVM_weights_.empty ())
84 PCL_ERROR (
"[pcl::people::PersonClassifier::loadSVMFromFile] Invalid SVM file!\n");
90template <
typename Po
intT>
void
99template <
typename Po
intT>
void
108template <
typename Po
intT>
void
128 Eigen::Matrix3f
T_inv;
137 for (
int i = 0; i < height; i++)
139 for (
int j = 0; j < width; j++)
141 A =
T_inv * Eigen::Vector3f(i, j, 1);
142 c1 = std::ceil(
A(0));
143 f1 = std::floor(
A(0));
144 c2 = std::ceil(
A(1));
145 f2 = std::floor(
A(1));
159 g1 = (*input_image)(f2, c1);
160 g3 = (*input_image)(f2, f1);
161 g4 = (*input_image)(c2, f1);
162 g2 = (*input_image)(c2, c1);
176template <
typename Po
intT>
void
211template <
typename Po
intT>
double
217 if (SVM_weights_.empty ())
219 PCL_ERROR (
"[pcl::people::PersonClassifier::evaluate] SVM has not been set!\n");
223 int height = std::floor((
height_person * window_height_) / (0.75 * window_height_) + 0.5);
224 int width = std::floor((
height_person * window_width_) / (0.75 * window_height_) + 0.5);
225 int xmin = std::floor(
xc - width / 2 + 0.5);
226 int ymin = std::floor(
yc - height / 2 + 0.5);
233 copyMakeBorder(image,
box,
xmin,
ymin, width, height);
237 resize(
box, sample, window_width_, window_height_);
240 float*
sample_float =
new float[sample->width * sample->height * 3];
241 int delta = sample->height * sample->width;
242 for (std::uint32_t
row = 0;
row < sample->height;
row++)
244 for (std::uint32_t
col = 0;
col < sample->width;
col++)
254 float *descriptor = (
float*)
calloc(SVM_weights_.size(),
sizeof(
float));
259 for(std::size_t i = 0; i < SVM_weights_.size(); i++)
261 confidence += SVM_weights_[i] * descriptor[i];
264 confidence -= SVM_offset_;
271 confidence = std::numeric_limits<double>::quiet_NaN();
277template <
typename Po
intT>
double
279 Eigen::Vector3f& bottom,
280 Eigen::Vector3f& top,
281 Eigen::Vector3f& centroid,
Iterator class for point clouds with or without given indices.
PointCloud represents the base class in PCL for storing collections of 3D points.
HOG represents a class for computing the HOG descriptor described in Dalal, N.
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.
PersonClassifier()
Constructor.
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.
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.
void getSVM(int &window_height, int &window_width, std::vector< float > &SVM_weights, float &SVM_offset)
Get trained SVM for person confidence estimation.
void resize(PointCloudPtr &input_image, PointCloudPtr &output_image, int width, int height)
Resize an image represented by a pointcloud containing RGB information.
A point structure representing Euclidean xyz coordinates, and the RGB color.