-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMain.h
More file actions
90 lines (68 loc) · 2.93 KB
/
Copy pathMain.h
File metadata and controls
90 lines (68 loc) · 2.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <iostream>
#include <cstdlib>
#include <pthread.h>
#include <time.h>
#include <stdlib.h> /* abs */
#include <math.h> /* pow */
#include <ctime> // std::time
#include "Helper/FileManager.h"
#include "error.h"
// The VLFeat header files need to be declared external.
extern "C" {
#include "lib_vlfeat/vl/generic.h"
#include "lib_vlfeat/vl/lbp.h"
}
#define OPERATE_TRAIN 1
#define OPERATE_CLASSIFY 2
#define OPERATE_VALIDATE 3
#define OPERATE_TRAIN_HARDNEG 4
#define OPERATE_TRAIN_NEG 5
using namespace std;
using namespace cv;
int cnt_TrainingImages, cnt_DiscardedTrainingImages;
vector<JSONImage> getTrainingSet(char *trainingPath);
vector<JSONImage> getValidationSet(char *validationPath);
vector<JSONImage> getTestSet(char *testPath);
vector<string> getTestVideos(char *testPath, bool isVideoToMerge = false);
vector<JSONImage> getNegativeSet(char *negativePath);
int doSlidingOperation(Classifier &model, vector<JSONImage> &imageSet, int scale_n, float scale_factor, float initial_scale, int w_rows,
int w_cols, int step_rows, int step_cols, const int operation, int originalImageHeight, string dir = "./ClassificationResults/");
int doSlidingImageOperation(Classifier &model, Mat frame, ClipperLib::Path labelPolygon, int scale_n, float scale_factor, float initial_scale, int w_rows,
int w_cols, int step_rows, int step_cols, const int operation, int originalImageHeight, string dir = "./ClassificationResults/", bool mergeVideo = false);
int calculateBestSlidingWindow(vector<JSONImage> &imageSet, bool showResult, float initial_scale, int w_rows, int w_cols);
void loadLBPConfiguration();
void loadHOGConfiguration();
static string getTimeString();
static string TimeString;
static int imageCounter;
int train(Classifier &model, bool loadSVMFromFile, string svm_loadpath, string svm_savepath, vector<JSONImage> trainingSet, vector<JSONImage> negativeSet);
int validate(Classifier &model, vector<JSONImage> validationSet);
int classify(Classifier &model, vector<JSONImage> testSet, vector<string> testVideos, string dir = "./ClassificationResults/");
int classify(Classifier &model, vector<JSONImage> testSet, string dir = "./ClassificationResults/");
int classify(Classifier &model, vector<string> testVideos, string dir = "./ClassificationResults/");
void printScaleSteps();
void createVideo(string dir);
// training parameters
int originalImageHeight;
int scale_n_times;
float scaling_factor;
float initial_scale;
bool doHardNegativeMining;
bool doJitter;
// sliding window
int windows_n_rows;
int windows_n_cols;
int step_slide_row;
int step_slide_col;
// classification parameters
float overlapThreshold;
float predictionThreshold;
float overlapThreshold2;
//video output
int ex_video_output;
double fps_video_output;
vector<string> outputVideoToMerge;
Mat frameToMerge;