forked from elador/FeatureDetection
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBenchmark.hpp
123 lines (105 loc) · 4.06 KB
/
Benchmark.hpp
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
/*
* Benchmark.hpp
*
* Created on: 10.09.2013
* Author: poschmann
*/
#ifndef BENCHMARK_HPP_
#define BENCHMARK_HPP_
#include "AlgorithmData.hpp"
#include "imageio/LabeledImageSource.hpp"
#include "imageprocessing/FeatureExtractor.hpp"
#include "classification/TrainableProbabilisticClassifier.hpp"
//#include "classification/TrainableOneClassSvmClassifier.hpp"
#include <memory>
#include <ostream>
using imageio::LabeledImageSource;
using imageprocessing::FeatureExtractor;
using classification::TrainableProbabilisticClassifier;
//using classification::TrainableOneClassSvmClassifier;
using cv::Rect_;
using std::vector;
using std::shared_ptr;
using std::ostream;
class Benchmark {
public:
Benchmark(float sizeMin, float sizeMax, float sizeScale, float step, float allowedOverlap = 0.5f, string outputDir = "results");
~Benchmark();
/**
* Adds a new combination of a feature extractor and a classifier for benchmarking.
*
* @param[in] name Name of the feature extractor classifier combination.
* @param[in] extractor Feature extractor.
* @param[in] classifier Trainable classifier.
* @param[in] confidenceThreshold Probability based confidence threshold for skipping learning on patches.
* @param[in] negatives Maximum amount of negative training examples per frame.
* @param[in] initialNegatives Amount of negative training examples in the first frame.
*/
void add(string name, shared_ptr<FeatureExtractor> extractor, shared_ptr<TrainableProbabilisticClassifier> classifier,
float confidenceThreshold, size_t negatives, size_t initialNegatives);
/**
* Runs the benchmark using the given image and ground truth source, evaluating the previously added feature extractor
* classifier combinations. For each extractor-classifier-combo there will be a text file that is named after the combo
* and this benchmark, containing the collected evaluated data.
*
* @param[in] name Name of the benchmark data.
* @param[in] source Source of image and ground truth data.
*/
void run(string name, shared_ptr<LabeledImageSource> source) const;
/**
* TODO
*
* @param[in] source Source of image and annotations (ground truth).
* @param[in] extractor TODO
* @param[in] classifier TODO
* @param[in] confidenceThreshold
* @param[in] negatives
* @param[in] initialNegatives
* @param[in] frameOut
* @param[in] resultOut
*/
void run(shared_ptr<LabeledImageSource> source, shared_ptr<FeatureExtractor> extractor, shared_ptr<TrainableProbabilisticClassifier> classifier,
float confidenceThreshold, size_t negatives, size_t initialNegatives, ostream& frameOut, ostream& resultOut) const;
//void runOneClass(shared_ptr<LabeledImageSource> source, shared_ptr<FeatureExtractor> extractor, shared_ptr<TrainableOneClassSvmClassifier> classifier);
/**
* @return Minimum size (height) of the patches relative to the image height.
*/
float getSizeMin() {
return sizeMin;
}
/**
* @return Maximum size (height) of the patches relative to the image height.
*/
float getSizeMax() {
return sizeMax;
}
/**
* @return Incremental scale factor of the size.
*/
float getSizeScale() {
return sizeScale;
}
/**
* @return Shifting distance relative to the patch size.
*/
float getStep() {
return step;
}
private:
/**
* Computes the overlap between two rectangular areas (e.g. the ground truth and a patch).
*
* @param[in] groundTruth TODO
* @param[in] patch TODO
* @return The overlap between TODO
*/
float computeOverlap(Rect_<float> groundTruth, Rect_<float> patch) const;
float sizeMin; ///< Minimum size (height) of the patches relative to the image height.
float sizeMax; ///< Maximum size (height) of the patches relative to the image height.
float sizeScale; ///< Incremental scale factor of the size.
float step; ///< Shifting distance relative to the patch size.
float allowedOverlap; ///< Maximum overlap with the ground truth allowed for negative patches.
string outputDir; ///< Directory of the output files.
vector<AlgorithmData> algorithmData; ///< Data of the extractor-classifier-combinations.
};
#endif /* BENCHMARK_HPP_ */