VAT  3.0
Video Analysis Tool
segmentationmodule.h
1 #ifndef SEGMENTATIONMODULE_H
2 #define SEGMENTATIONMODULE_H
3 
4 #include <map>
5 #include <string>
6 #include <QImage>
7 #include "Datapool.h"
8 #include "ModuleInterface.h"
9 #include <QDir>
10 #include "src/json.h"
11 #include "ReliabilityBg.h"
12 
13 #include "opencv2/opencv.hpp"
14 
15 
17 public:
20 
21  //Set module configuration parameters
22  bool setParameters(QDomNode& config);
23 
24  //Initialization after reading parameters
25  bool init();
26 
27  //Function executed at each frame
28  bool run();
29 
30  //update parameters at runtime.
31  bool updateParameters();
32 
33  //Global updating settings functions
34  bool setGlobalZones();
35  bool setGlobalMask();
36  bool insideInZone(int i, int j);
37  bool outsideOutZone(int i, int j);
38 
39  void updateBGGlobally(QImage *current);
40 
41  bool readImageOnDisk(QString dir,QImage **o_rpOutputImage);
42 
43  void tuneParameters();
44 
45  //Processes segmentation with provided data, and returns the number of foreground pixels in the region:
46  static int getSegmentation(cv::Mat& input, cv::Mat& output, cv::Mat& bg, cv::Mat& mask, int threshold);
47  static int getSegmentation(Datapool *dp, BoundingBox &roi, cv::Mat& output, int threshold);
48 
49  void getDiff(QImage *, QImage *);
50 
51  uchar T;
52 
53 private:
54  int currentFrame;
55  int line;
56  int cont;
57  bool BGup;
58  double alpha; //tasa de aprendizaje
59  bool m_global;
60  int m_N;
61  int m_K;
62  QString m_InZone;
63  QString m_OutZone;
64  bool m_inDefined;
65  bool m_outDefined;
66  bool m_aperture;
67  bool m_tuningActivated;
68  int m_currentTuneValue;
69  int m_tuneStep;
70  int m_maxTuneValue;
71 
72  bool globalMaskReady;
73  QImage *globalMask;
74  int globalValidPoints;
75  bool global_validated;
76  bool validate_once;
77  bool different_bg_current;
78  std::map<int, std::deque<RLESegment> > RLEglobal;
79 
80  zoneType zInType, zOutType;
81  QSharedPointer<world::Zone> zin3D, zout3D;
82  QSharedPointer<world::Zone2D> zin2D, zout2D;
83  QSharedPointer<world::ZoneH> zinH, zoutH;
84 
85  QString bgImName;
86  bool first;
87  bool globalNotSet;
88  bool m_mask;
89  QString m_maskImName;
90  void applyAperture(QImage *, QImage *);
91  void updateBG(QImage *);
92  std::map<int, std::deque<int> > globalPoints;
93  cv::Mat element;
94  cv::Mat featureMap, reliabilityMap;
95  float minScaleThreshold, maxScaleThreshold, minScaleThresholdRatio, maxScaleThresholdRatio;
96 
97  int width, height;
98 
99  bool chromaticSegmentationIsActivated;
100  int minGrade;
101  int maxGrade;
102  int minSaturation;
103  int maxLight;
104  // Added by Barrientos Nettle - CV 2014-1
105  bool chromaticSegmentationFromHSVdataFiles;
106  std::vector<std::vector<int> > hsvFGparams;
107  std::vector<std::vector<int> > hsvBGparams;
108  std::vector<std::vector<int> > readHSVparamsFile(QString fileName);
109  int BgED;
110  int FgED;
111  int BgSS;
112  int FgSS;
113 
114  enum BG_FG_ErodeDilate
115  {
116  erode,
117  dilate,
118  none
119  };
120 
121 };
122 
123 #endif // SEGMENTATIONMODULE_H
Definition: segmentationmodule.h:16
Definition: ModuleInterface.h:43
An object of this class is instantiated at main code, and this object is used by every class to push ...
Definition: Datapool.h:39