00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include <ros/ros.h>
00028 #include <image_transport/image_transport.h>
00029 #include <opencv/cvwimage.h>
00030 #include <opencv/highgui.h>
00031 #include <cv_bridge/cv_bridge.h>
00032 #include <sensor_msgs/image_encodings.h>
00033 #include <cv.h>
00034 #include <ros/package.h>
00035 #include <boost/filesystem.hpp>
00036 #include <iostream>
00037 #include <iterator>
00038 #include <algorithm>
00039 #include <vector>
00040 #include <math.h>
00041 #include "opencv/ml.h"
00042 #include <fstream>
00043 #include <cstdlib>
00044
00045
00046 #define PI 3.14159265359
00047 #define CHANNELNR 10
00048 #define STEP 4
00049 #define NRFEATURE 15000
00050 #define NRFEATURE2 NRFEATURE/CHANNELNR
00051 #define DWHEIGHT 128
00052 #define DWWIDTH 64
00053 #define SEED 1234
00054 #define MINAREA 8
00055 #define MAXAREAWIDTH 64
00056 #define MAXAREAHEIGHT 48
00057 #define THRESHOLD 11
00058 #define NOCTUP 0
00059 #define SCALEPOCT 8
00060
00061
00062 using namespace boost::filesystem;
00063 using namespace std;
00064 using namespace cv;
00065 namespace enc = sensor_msgs::image_encodings;
00066
00067 typedef struct
00068 {
00069 int nFtrs;
00070 int width;
00071 int height;
00072 int x;
00073 int y;
00074 } FtrParams2;
00075
00076 typedef struct
00077 {
00078 int x;
00079 int y;
00080 Size Scale;
00081 } PedRoi;
00082
00083
00084
00085
00086
00087 typedef vector<PedRoi> PedRoiVec;
00088 typedef vector<path> PVector;
00089 typedef vector<Mat> MatVector;
00090 typedef Vec<float, CHANNELNR> vec10d;
00091 typedef vector<vec10d> d10Vector;
00092 typedef vector<FtrParams2> FtrVecParams2;
00093 typedef vector<float> DVector;
00094
00095
00096
00097 void GetFileList(string folder_path, PVector & dest_vect);
00098
00099 Mat GradientMagnitude(Mat src);
00100 Mat GradientMagnitude(Mat xsobel, Mat ysobel);
00101
00102
00103 MatVector OrientedGradientsDiagram(Mat GradMag, Mat xsobel, Mat ysobel);
00104
00105 MatVector LUVcolourchannels(Mat Img);
00106
00107
00108 void GetChnFtrsOverImagePyramid(Mat Image , CvRect & region , vector<float> & features, int nOctUp, Size minSize, int nPerOct, FtrVecParams2 Params, PedRoiVec & PedRect, CvBoost & boost_classifier);
00109 void GetChnFtrsOverImagePyramid(Mat Image , CvRect & region , vector<float> & features, vector<DVector> & WindowFtrs, int nOctUp, Size minSize, int nPerOct, FtrVecParams2 Params);
00110
00111
00112 void GetChnFtrsOverImage(Mat IntegralChannels , CvRect & region ,vector<float> & features, FtrVecParams2 Params, PedRoiVec & PedRect,CvBoost & boost_classifier);
00113 void GetChnFtrsOverImage(Mat IntegralChannels , CvRect & region ,vector<float> & features,vector<DVector> & WindowFtrs, FtrVecParams2 Params);
00114
00115 void GetChnFtrsOverWindow(Mat IntegralChannels , vector<float> & features ,FtrVecParams2 Params, CvRect region,PedRoiVec & PedRect,CvBoost & boost_classifier);
00116 void GetChnFtrsOverWindow(Mat IntegralChannels , vector<float> & features,vector<DVector> & WindowFtrs ,FtrVecParams2 Params, CvRect region);
00117
00118 void GetIntegralSum(Mat IntegralChannels, vector<float> & features, FtrParams2 Params,CvRect region);
00119
00120 void ComputeChannels(Mat Image, Mat & MergedChannels);
00121
00122 void GetRandParams(int seed, int NrFtrs, FtrVecParams2 & RandParams, Rect region);
00123
00124 void GetChnFtrsOverWindow(Mat IntegralChannels , vector<float> & features, FtrVecParams2 Params, CvRect region,PedRoiVec & PedRect);
00125 void GetChnFtrsOverWindow(Mat IntegralChannels , vector<float> & features,vector<DVector> & WindowFtrs, FtrVecParams2 Params);
00126
00127
00128 void GetIntegralSum(Mat IntegralChannels, vector<float> & features, FtrParams2 Params,CvRect region);
00129
00130 void PostProcess(Mat Img, vector<Rect> PedRect, FtrVecParams2 randparams, CvBoost & boost_classifier, PedRoiVec & PedRect_Post);