forked from kimphg/FireDetector
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFeatureAnalyzer.h
91 lines (72 loc) · 2.2 KB
/
FeatureAnalyzer.h
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
//
// FeatureAnalyzer.h
// FlameDetection
//
// Created by liberize on 14-4-14.
// Copyright (c) 2014年 liberize. All rights reserved.
//
#ifndef __FlameDetection__FeatureAnalyzer__
#define __FlameDetection__FeatureAnalyzer__
#include "common.h"
//#include "cvplot.h"
struct Target;
class Region;
class Feature {
private:
Mat mTargetFrame;
Mat mMask;
double mArea;
static const int MAX_AREA_VEC_SIZE = 64;
// if we use list here, we need to convert it to vector each time. so use vector instead.
vector<double> mAreaVec;
vector<double> aspectRatioVec;
vector<double> circularityVec;
vector<double> squarenessVec;
vector<double> frameDiffVec;
void calcColorFeature();
void calcGeometryFeature(const Region& region);
void calcTexture(int levels = 16, int dx = 3, int dy = 3);
void calcFrequency();
void calcDynamicFeatures();
public:
static const int LEN = 13;
bool dataReady;
// color features
//double red[4];
//double gray[4];
//double saturation[4];
// geometric features
double roughness;
double diffInOut;
// structural features
double texture[4];
// dynamic features
double aspectRatioMean, aspectRatioVar;
double circularityMean, circularityVar;
double squarenessMean, squarenessVar;
double frameDiffVar,frameDiffMean;
double frequency;
double areaVar;
void calc(const Region& region, const Mat& frame, Mat iMask);
static void merge(const vector<const Feature*>& src, Feature& feature);
void printValue()const;
bool checkValid();
operator Mat() const;
public:
Feature();
#ifdef PHUONGS_ALGORITHM
void printAreaVec() const;
#endif
};
ifstream& operator>>(ifstream& ifs, Feature& feature);
ofstream& operator<<(ofstream& ofs, const Feature& feature);
class FeatureAnalyzer {
private:
Mat mFrame;
void featureUpdate(Target& target);
void featureMerge(Target& target, const map<int, Target>& targets, const vector<int>& keys);
void targetUpdate(map<int, Target>& targets, Mat iMask);
public:
void analyze(const Mat& frame, map<int, Target>& targets, Mat iMask);
};
#endif /* defined(__FlameDetection__FeatureAnalyzer__) */