peddetect.h
Go to the documentation of this file.
1 /**************************************************************************************************
2  Software License Agreement (BSD License)
3 
4  Copyright (c) 2011-2013, LAR toolkit developers - University of Aveiro - http://lars.mec.ua.pt
5  All rights reserved.
6 
7  Redistribution and use in source and binary forms, with or without modification, are permitted
8  provided that the following conditions are met:
9 
10  *Redistributions of source code must retain the above copyright notice, this list of
11  conditions and the following disclaimer.
12  *Redistributions in binary form must reproduce the above copyright notice, this list of
13  conditions and the following disclaimer in the documentation and/or other materials provided
14  with the distribution.
15  *Neither the name of the University of Aveiro nor the names of its contributors may be used to
16  endorse or promote products derived from this software without specific prior written permission.
17 
18  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
19  IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
20  FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
21  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
24  IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
25  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 ***************************************************************************************************/
27 #include <ros/ros.h>
28 #include <image_transport/image_transport.h>
29 #include <opencv/cvwimage.h>
30 #include <opencv/highgui.h>
31 #include <cv_bridge/cv_bridge.h>
32 #include <sensor_msgs/image_encodings.h>
33 #include <cv.h>
34 #include <ros/package.h>
35 #include <boost/filesystem.hpp>
36 #include <iostream>
37 #include <iterator>
38 #include <algorithm>
39 #include <vector>
40 #include <math.h>
41 #include "opencv/ml.h"
42 #include <fstream>
43 #include <cstdlib>
44 
45 
46 #define PI 3.14159265359
47 #define CHANNELNR 10
48 #define STEP 4
49 #define NRFEATURE 15000
50 #define NRFEATURE2 NRFEATURE/CHANNELNR
51 #define DWHEIGHT 128
52 #define DWWIDTH 64
53 #define SEED 1234
54 #define MINAREA 8
55 #define MAXAREAWIDTH 64
56 #define MAXAREAHEIGHT 48
57 #define THRESHOLD 11
58 #define NOCTUP 0
59 #define SCALEPOCT 8
60 
61 
62 using namespace boost::filesystem;
63 using namespace std;
64 using namespace cv;
65 namespace enc = sensor_msgs::image_encodings;
66 
67 typedef struct
68 {
69  int nFtrs;
70  int width;
71  int height;
72  int x;
73  int y;
74 } FtrParams2;
75 
76 typedef struct
77 {
78  int x;
79  int y;
80  Size Scale;
81 } PedRoi;
82 
83 
84 
85 
86 
87 typedef vector<PedRoi> PedRoiVec;
88 typedef vector<path> PVector;
89 typedef vector<Mat> MatVector;
90 typedef Vec<float, CHANNELNR> vec10d;
91 typedef vector<vec10d> d10Vector;
92 typedef vector<FtrParams2> FtrVecParams2;
93 typedef vector<float> DVector;
94 
95 
96 
97 void GetFileList(string folder_path, PVector & dest_vect);
98 
99 Mat GradientMagnitude(Mat src);
100 Mat GradientMagnitude(Mat xsobel, Mat ysobel);
101 
102 
103 MatVector OrientedGradientsDiagram(Mat GradMag, Mat xsobel, Mat ysobel);
104 
106 
107 
108 void GetChnFtrsOverImagePyramid(Mat Image , CvRect & region , vector<float> & features, int nOctUp, Size minSize, int nPerOct, FtrVecParams2 Params, PedRoiVec & PedRect, CvBoost & boost_classifier);
109 void GetChnFtrsOverImagePyramid(Mat Image , CvRect & region , vector<float> & features, vector<DVector> & WindowFtrs, int nOctUp, Size minSize, int nPerOct, FtrVecParams2 Params);
110 
111 
112 void GetChnFtrsOverImage(Mat IntegralChannels , CvRect & region ,vector<float> & features, FtrVecParams2 Params, PedRoiVec & PedRect,CvBoost & boost_classifier);
113 void GetChnFtrsOverImage(Mat IntegralChannels , CvRect & region ,vector<float> & features,vector<DVector> & WindowFtrs, FtrVecParams2 Params);
114 
115 void GetChnFtrsOverWindow(Mat IntegralChannels , vector<float> & features ,FtrVecParams2 Params, CvRect region,PedRoiVec & PedRect,CvBoost & boost_classifier);
116 void GetChnFtrsOverWindow(Mat IntegralChannels , vector<float> & features,vector<DVector> & WindowFtrs ,FtrVecParams2 Params, CvRect region);
117 
118 void GetIntegralSum(Mat IntegralChannels, vector<float> & features, FtrParams2 Params,CvRect region);
119 
120 void ComputeChannels(Mat Image, Mat & MergedChannels);
121 
122 void GetRandParams(int seed, int NrFtrs, FtrVecParams2 & RandParams, Rect region);
123 
124 void GetChnFtrsOverWindow(Mat IntegralChannels , vector<float> & features, FtrVecParams2 Params, CvRect region,PedRoiVec & PedRect);
125 void GetChnFtrsOverWindow(Mat IntegralChannels , vector<float> & features,vector<DVector> & WindowFtrs, FtrVecParams2 Params);
126 
127 
128 void GetIntegralSum(Mat IntegralChannels, vector<float> & features, FtrParams2 Params,CvRect region);
129 
130 void PostProcess(Mat Img, vector<Rect> PedRect, FtrVecParams2 randparams, CvBoost & boost_classifier, PedRoiVec & PedRect_Post);
vector< PedRoi > PedRoiVec
Definition: peddetect.h:87
void GetRandParams(int seed, int NrFtrs, FtrVecParams2 &RandParams, Rect region)
Definition: pedfuncs.cpp:216
vector< Mat > MatVector
Definition: peddetect.h:89
void GetChnFtrsOverImagePyramid(Mat Image, CvRect &region, vector< float > &features, int nOctUp, Size minSize, int nPerOct, FtrVecParams2 Params, PedRoiVec &PedRect, CvBoost &boost_classifier)
Definition: pedfuncs.cpp:273
void ComputeChannels(Mat Image, Mat &MergedChannels)
Definition: pedfuncs.cpp:186
int nFtrs
Definition: peddetect.h:69
void GetChnFtrsOverImage(Mat IntegralChannels, CvRect &region, vector< float > &features, FtrVecParams2 Params, PedRoiVec &PedRect, CvBoost &boost_classifier)
Definition: pedfuncs.cpp:388
vector< vec10d > d10Vector
Definition: peddetect.h:91
Size Scale
Definition: peddetect.h:80
MatVector LUVcolourchannels(Mat Img)
Definition: pedfuncs.cpp:136
void GetIntegralSum(Mat IntegralChannels, vector< float > &features, FtrParams2 Params, CvRect region)
Definition: pedfuncs.cpp:493
int x
Definition: peddetect.h:78
vector< float > DVector
Definition: peddetect.h:93
int height
Definition: peddetect.h:71
Vec< float, CHANNELNR > vec10d
Definition: peddetect.h:90
MatVector OrientedGradientsDiagram(Mat GradMag, Mat xsobel, Mat ysobel)
Definition: pedfuncs.cpp:66
Mat GradientMagnitude(Mat src)
Definition: pedfuncs.cpp:30
void GetChnFtrsOverWindow(Mat IntegralChannels, vector< float > &features, FtrVecParams2 Params, CvRect region, PedRoiVec &PedRect, CvBoost &boost_classifier)
Definition: pedfuncs.cpp:514
void GetFileList(string folder_path, PVector &dest_vect)
Definition: pedfuncs.cpp:153
int width
Definition: peddetect.h:70
vector< path > PVector
Definition: peddetect.h:88
vector< FtrParams2 > FtrVecParams2
Definition: peddetect.h:92
int y
Definition: peddetect.h:79
void PostProcess(Mat Img, vector< Rect > PedRect, FtrVecParams2 randparams, CvBoost &boost_classifier, PedRoiVec &PedRect_Post)
Definition: pedfuncs.cpp:606


pedestrian_detect
Author(s): Pedro Batista
autogenerated on Mon Mar 2 2015 01:32:33