VAT  3.0
Video Analysis Tool
playermodelfromprobabilitymaps.h
1 #ifndef PLAYERMODELFROMPROBABILITYMAPS_H
2 #define PLAYERMODELFROMPROBABILITYMAPS_H
3 
4 #include <QDomNode>
5 #include <QImage>
6 
7 #include "reliabilitysinglemodelinterface.h"
8 #include "src/templateclass.h"
9 
10 typedef struct mapStruct mapMapStruct;
11 struct mapStruct
12 {
13  mapStruct( float _maxVal, float _minVal, float _diff , QString _name) :
14  maxVal(_maxVal), minVal(_minVal),diff(_diff),name(_name){}
15  mapStruct() : maxVal(0.0), minVal(1000.0), diff(0.0), name("UNK"){}
16 
17  float maxVal;
18  float minVal;
19  float diff;
20  float alpha, beta;
21  float probValue;
22  QString name;
23 
24 };
25 
27 {
28 public:
29  PlayerModelFromProbabilityMaps(int buffer_size);
30 
32 
33  //IMPLEMENT!! Initializes the model attributes for the interface.
34  //The function is called by the interface constructor
35  virtual void initInstanceAttributes();
36 
37  //IMPLEMENT!! Initializes the dynamics model attributes for the interface.
38  //The function is called by the interface constructor
39  virtual void initDynamicsAttributes();
40 
41  //IMPLEMENT!! Copy function for specific data from the instance (general_copy calls it after copying base info)
42  virtual void copy(SpReliabilitySingleModelInterface);
43 
44  //IMPLEMENT!! Copy general structures and parameters of specific model, without considering instance specific data
45  virtual void copy_structure(SpReliabilitySingleModelInterface);
46 
47  //IMPLEMENT!! sets parameters from xml file
48  virtual void setParameters(QDomNode &i_parameters);
49 
50  //IMPLEMENT!! sets activation criteria for each model: reliability on input (distance, bad data),
51  // needs (occlusion, priority),
52  //sets priority of models (hierarchy).
53  //Checked before update phase
54  virtual void activate(BoundingBox &);
55 
56  //IMPLEMENT!! initializes every activated model, according to their own input (region-blob-segments schema)
57  //Executed only once at the begginning of single model creation (after 'copy_structure' and 'copy' methods
58  //are used to copy the information).
59  virtual void init();
60 
61  //IMPLEMENT!! updates activated model instance attributes for current frame, and returns the set of detected/enriched objects.
62  // It notifies if roi (bounding box, or segmentation) changes compared to the input, for reprocessing.
63  virtual bool updateInstance(BoundingBox &, std::set<SpRMMHypothesis, hypothesesOrderedByBestProbabilityOperator> &);
64 
65  //IMPLEMENT!! updates activated model instance attributes for current frame and object, and returns the detected/enriched object.
66  // It notifies if roi (bounding box, or segmentation) changes compared to the input, for reprocessing.
67  // This function does NOT generate mobiles or hypotheses. It processes attributes for the current object.
68  // This function could be used by updateInstance to generate mobile information.
69  virtual void updateSingleInstance(BoundingBox &);
70 
71 
72  //IMPLEMENT!! updates model dynamics, based on instances information
73  virtual void updateModelDynamics();
74 
75  //IMPLEMENT!! sets global probability for the model (how good is the model)
76  virtual void setProbabilityAndReliability();
77 
78  //IMPLEMENT!! sets blob enclosing the model in forward process (update)
79  virtual void setForwardInterface();
80 
81  //OPTIONAL
82  virtual bool draw(QPainter &painter);
83 
84  virtual bool draw(QPainter &painter, int r, int g, int b);
85 
86  virtual void printGeneral();
87 
88  virtual BoundingBox getEstimator(double &R);
89 
90  bool getCentersForMultipleClasses(int x_leftBlob, int x_rightBlob, int y_topBlob, int y_bottomBlob);
91 
92  BoundingBox setRectModel(cv::Point center);
93 
94 private:
95  //Mapas de Probabilidad
96  cv::Mat compactnessMap;
97  cv::Mat heightMap;
98  cv::Mat widthMap;
99  cv::Mat probMap;
100  std::map<soccerClass, cv::Mat> colorMapTeam_Map; //Mapa de Probabilidad de Color
101  std::map<soccerClass, cv::Mat> probability_Map; //Mapa de Probabilidad 32 bits un canal
102 
103  //Directorio donde se encuentran las tablas del modelo de color para cada parte del cuerpo
104  std::map<soccerClass, bool > classesIncluded;
105  templateClass *Template;
106 
107  QVector<QRgb> colorTable;//Tabla de Color para dibujar los mapas de probabilidad
108 
109  int candidate_to_draw;
110  int currentBlob_id;//Id for current Analized Blob
111 
112  bool drawFlag;
113 
114  bool valid;
115 
116  //Parametros que faltan por setear
117  int thresholdPeakImage;
118 
119  cv::Mat obtainDistancesIntegralImage(const cv::Mat &frame, cv::Rect roi,soccerClass team, playerPart part);
120 
121  //Color Maps
122  //0: Red 1 : Blue
123  QImage matToQImageOneColor(const cv::Mat& mat);
124 
125  void writeMapToSCV(cv::Mat data, QString name);
126 
127  void setTemplateColors();
128 
129  //Functions to find de Maximun values for center of players
130  std::vector<cv::Point> bhContoursCenter(const std::vector<std::vector<cv::Point>>& contours,bool centerOfMass,int contourIdx=-1);
131  std::vector<cv::Point> bhFindLocalMaximum(cv::Mat _src, QString name = "UNK");
132 
133  std::vector<int> getExtendedRegion(int blob_xleft, int blob_xright, int blob_ytop, int blob_ybottom);
134 
135  void obtainIntegralImagesForTemplate(soccerClass team, cv::Rect rect);
136 
137  cv::Rect setPlayerSizeAt(int j, int i, int upPart, int height, int width);
138  double getHeightMapProbValue(int i, int top, int bottom, int topPart, int bottomPart, int type);
139  std::vector<int> getForegroundLimitPoints(const uchar *data,int bpl, int blob_xleft, int blob_xright, int blob_ytop, int blob_ybottom);
140  void mapSetParamStepOne(mapStruct &vT);
141  void mapSetParamStepTwo(mapStruct &vT);
142  void showMaps(int objectId, double scaleFactor);
143  void showImageGroup(std::vector<cv::Mat> imagesToShow, QString windowName);
144  double getWidthMapProbValue(int j, int left, int right, int ratio, int type);
145 
146  double setCandidatesToObjectDistances();
147 
148  std::vector<playerCandidate> plCandidates;
149 
150  playerCandidate *c;
151 
152  BoundingBox m_roi;
153  BoundingBox usedRoi;
154 
155  double R;
156 
157  cv::RotatedRect getProyectedTorso();
158 };
159 
160 typedef QSharedPointer<PlayerModelFromProbabilityMaps> SpPlayerModelFromProbabilityMaps;
161 
162 #endif // PLAYERMODELFROMPROBABILITYMAPS_H
Definition: playermodelfromprobabilitymaps.h:26
Definition: reliabilitysinglemodelinterface.h:96
Definition: templateclass.h:40
Definition: footballConstants.h:92
Definition: playermodelfromprobabilitymaps.h:11
Definition: BackgroundRecLigth.h:20