forked from BloodAxe/OpenCV-Features-Comparison
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CollectedStatistics.hpp
93 lines (71 loc) · 2.63 KB
/
CollectedStatistics.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
#ifndef CollectedStatistics_hpp
#define CollectedStatistics_hpp
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <opencv2/opencv.hpp>
typedef enum
{
StatisticsElementPointsCount,
StatisticsElementPercentOfCorrectMatches,
StatisticsElementPercentOfMatches,
StatisticsElementMeanDistance,
StatisticsElementMatchingRatio,
StatisticsElementHomographyError,
StatisticsElementPatternLocalization,
StatisticsElementAverageReprojectionError,
StatisticsElementRecall,
StatisticsElementPrecision
} StatisticElement;
struct FrameMatchingStatistics
{
FrameMatchingStatistics();
int totalKeypoints;
float argumentValue;
float percentOfMatches;
float ratioTestFalseLevel;
float meanDistance;
float stdDevDistance;
float correctMatchesPercent;
float homographyError;
float recall;
float precision;
float consumedTimeMs;
cv::Scalar reprojectionError;
bool isValid;
inline float matchingRatio() const { return correctMatchesPercent * percentOfMatches * 100.0f; };
inline float patternLocalization() const { return correctMatchesPercent * percentOfMatches * (1.0f - homographyError); }
std::ostream& writeElement(std::ostream& str, StatisticElement elem) const;
bool tryGetValue(StatisticElement element, float& value) const;
};
typedef std::vector<FrameMatchingStatistics> SingleRunStatistics;
float average(const SingleRunStatistics& statistics, StatisticElement element);
float maximum(const SingleRunStatistics& statistics, StatisticElement element);
struct Line
{
float argument;
std::vector<const FrameMatchingStatistics*> stats;
};
struct GroupedByArgument
{
std::vector<std::string> algorithms;
std::vector<Line> lines;
};
class CollectedStatistics
{
public:
typedef std::map<std::string, const SingleRunStatistics*> InnerGroup;
typedef std::map<std::string, InnerGroup> OuterGroup;
typedef std::map<std::string, GroupedByArgument> OuterGroupLine;
SingleRunStatistics& getStatistics(std::string algorithmName, std::string transformationName);
OuterGroup groupByAlgorithmThenByTransformation() const;
OuterGroupLine groupByTransformationThenByAlgorithm() const;
std::ostream& printPerformanceStatistics(std::ostream& str) const;
std::ostream& printStatistics(std::ostream& str, StatisticElement elem) const;
std::ostream& printAverage(std::ostream& str, StatisticElement elem) const;
private:
typedef std::pair<std::string, std::string> Key;
std::map<Key, SingleRunStatistics> m_allStats;
};
#endif