VAT  3.0
Video Analysis Tool
BlobLRBTFromBGSubstractionModel3.h
1 #ifndef BLOBLRBTFROMBGSUBSTRACTIONMODEL3_H
2 #define BLOBLRBTFROMBGSUBSTRACTIONMODEL3_H
3 
4 #include <QDomNode>
5 #include <QImage>
6 #include <vector>
7 #include <QSharedPointer>
8 
9 #include <opencv2/core.hpp>
10 
11 #include "reliabilitysinglemodelinterface.h"
12 #include "src/blob.h"
13 
14 class Datapool;
15 
17 public:
18  enum Bound {
19  B_LEFT,
20  B_RIGHT,
21  B_TOP,
22  B_BOTTOM,
23  };
24 
25  BlobLRBTFromBGSubstractionModel3(int buffer_size);
26 
28 
29  //IMPLEMENT!! Initializes the model attributes for the interface.
30  //The function is called by the interface constructor
31  virtual void initInstanceAttributes();
32 
33  //IMPLEMENT!! Initializes the dynamics model attributes for the interface.
34  //The function is called by the interface constructor
35  virtual void initDynamicsAttributes();
36 
37  //IMPLEMENT!! Copy function for specific data from the instance (general_copy calls it after copying base info)
38  virtual void copy(SpReliabilitySingleModelInterface);
39 
40  //IMPLEMENT!! Copy general structures and parameters of specific model, without considering instance specific data
41  virtual void copy_structure(SpReliabilitySingleModelInterface);
42 
43  //IMPLEMENT!! sets parameters from xml file
44  virtual void setParameters(QDomNode &i_parameters);
45 
46  //IMPLEMENT!! sets activation criteria for each model: reliability on input (distance, bad data),
47  // needs (occlusion, priority),
48  //sets priority of models (hierarchy).
49  //Checked before update phase
50  virtual void activate(BoundingBox &);
51 
52  //IMPLEMENT!! initializes every activated model, according to their own input (region-blob-segments schema)
53  //Executed only once at the begginning of single model creation (after 'copy_structure' and 'copy' methods
54  //are used to copy the information).
55  virtual void init();
56 
57  //IMPLEMENT!! updates activated model instance attributes for current frame, and returns the set of detected/enriched objects.
58  // It notifies if roi (bounding box, or segmentation) changes compared to the input, for reprocessing.
59  virtual bool updateInstance(BoundingBox &, std::set<SpRMMHypothesis, hypothesesOrderedByBestProbabilityOperator> &);
60 
61  //IMPLEMENT!! updates activated model instance attributes for current frame and object, and returns the detected/enriched object.
62  // It notifies if roi (bounding box, or segmentation) changes compared to the input, for reprocessing.
63  // This function does NOT generate mobiles or hypotheses. It processes attributes for the current object.
64  // This function could be used by updateInstance to generate mobile information.
65  virtual void updateSingleInstance(BoundingBox &);
66 
67 
68  //IMPLEMENT!! updates model dynamics, based on instances information
69  virtual void updateModelDynamics();
70 
71  //IMPLEMENT!! sets global probability for the model (how good is the model)
72  virtual void setProbabilityAndReliability();
73 
74  //IMPLEMENT!! sets blob enclosing the model in forward process (update)
75  virtual void setForwardInterface();
76 
77  //OPTIONAL
78  virtual bool draw(QPainter &painter);
79 
80  virtual bool draw(QPainter &painter, int r, int g, int b);
81 
82  //Initialize attribute with instance value
83  void initAttribute(ReliabilityDynamicsAttribute &d, AttributeDupletValue &i);
84 
85  //Standard attribute dynamics update, with no attribute value constraints
86  void updateAttribute(const QString &name, ReliabilityDynamicsAttribute &d);
87 
88  double getAttributeEstimate(ReliabilityDynamicsAttribute &d, double time_diff);
89 
90 
91  void updateAttributeDynamics(double data, double RData, double acuity,
92  double estimate, double currentCooling, AttributeTripletValue &att);
93 
94  void updateAttributeDynamicsNoData(double estimate, double acuity, double currentCooling,
96 
97  double projectAttributeValue(ReliabilityDynamicsAttribute &, double &R);
98 
99  virtual BoundingBox getEstimator(double &R);
100 
101  //Reliability by parameter
102  double getLeftReliability(BoundingBox &boundingBox);
103  double getRightReliability(BoundingBox &boundingBox);
104  double getBottomReliability(BoundingBox &boundingBox);
105  double getTopReliability(BoundingBox &boundingBox);
106 
107  double contrastGaussianMean(int x, int y, QImage &cn);
108  double contrastGaussianMeanFG(int x, int y, QImage *cn, QImage *fg);
109  void addLocalBoundPoints(BoundingBox &r, Bound bound, float reliability);
110 
111 
112  static const double R_MIN;
113  static const bool USE_GAUSSIAN;
114  static const int GAUSSIAN_SIZE;
115  static const bool USE_FG;
116  static const bool USE_SQUARE_DISTANCE;
117  static const bool USE_MAX;
118  static const bool USE_MEAN;
119  static const bool USE_MAX_WEIGHTED;
120  static const bool USE_MEAN_WEIGHTED;
121 
122  static const int GF7[];
123  static const int GF5[];
124  static const int GF3[];
125 
126  double m_minimalAttributeVelocityReliability;
127  double m_minimalAttributeAccelerationReliability;
128  double m_minimalWidth;
129  double m_minimalHeight;
130  int m_pixelAcuity;
131  bool m_useReliability;
132  bool m_useFeatureMap;
133 
134  int *GF;
135  double GFactor;
136 
137  bool m_showId;
138  bool m_blackId;
139  bool m_build2DBoundReliabilityImage;
140  bool m_activateProjectedBlobCorrection;
141  QImage boundsReliability;
142  double localMaxBound;
143  bool currentBoundImageOK;
144  std::map< int, std::map<int, double> > localBoundList;
145 
146  std::vector<float> leftBoundListRel;
147  std::vector<cv::Point2d> leftBoundListPos;
148  std::vector<float> rightBoundListRel;
149  std::vector<cv::Point2d> rightBoundListPos;
150  std::vector<float> topBoundListRel;
151  std::vector<cv::Point2d> topBoundListPos;
152  std::vector<float> bottomBoundListRel;
153  std::vector<cv::Point2d> bottomBoundListPos;
154 
155 // int xbound, ybound;
156 };
157 
158 typedef QSharedPointer<BlobLRBTFromBGSubstractionModel3> SpBlobLRBTFromBGSubstractionModel3;
159 
160 
161 #endif // BLOB2DFROMBGSUBSTRACTIONMODEL3_H
Definition: BlobLRBTFromBGSubstractionModel3.h:16
Definition: reliabilityattribute.h:101
Definition: reliabilitysinglemodelinterface.h:96
Definition: reliabilityattribute.h:10
An object of this class is instantiated at main code, and this object is used by every class to push ...
Definition: Datapool.h:39
Definition: reliabilityattribute.h:76
Definition: gtstructures.h:32
Definition: BackgroundRecLigth.h:20