VAT  3.0
Video Analysis Tool
bipedarticulatedmodel.h
1 #ifndef BIPEDARTICULATEDMODEL_H
2 #define BIPEDARTICULATEDMODEL_H
3 
4 #include <QDomNode>
5 #include <QImage>
6 #include "reliabilitysinglemodelinterface.h"
7 #include "src/fivelink2dbodymodel.h"
8 
9 /*
10  * Autor: Cristobal Barrientos Low - mail: cbarrientoslow@gmail.com
11  * Interfaz de que implementa el Modelo de objeto articulado Bípedo con 5 articulaciones.
12  * Fuente: Detection and Tracking of Humans in Single View Sequences Using 2D Articulated Model.
13  * Autores: Filip Korc and Vaclav Hlavac
14 */
15 
16 //Estructura que define las variables para representar el ROI de un objeto persona
17 typedef struct personROI personROI;
18 struct personROI
19 {
20  cv::Rect ROI;
21  cv::Point center;
22  double valueCorrelation;
23 };
24 
26 {
27 public:
28  BipedArticulatedModel(int buffer_size);
29 
30  //IMPLEMENT!!
31  virtual ~BipedArticulatedModel();
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 &bb);
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 BoundingBox getEstimator(double &R);
87 
88 
89 
90 private:
91 
92  /*
93  * Entrega la zona de interes (ROI's) donde se puede encontrar el jugador, verifica que la
94  * altura del jugador sea acorde a la posición del blob en la imagen
95  */
96  cv::Rect humanCandidatesDetection(BoundingBox &bb);
97 
98  //Junto con el Modelo extendido y el ROI se verifica que el área de interes cumpla la apariencia de un humano
99  double modelValidation(cv::Rect ROI, cv::Mat im);
100 
101  //Mean Shift Algorithm
102  void meanShift_STEP1_TORSO(const cv::Rect &roi);
103  void meanShift_STEP2_TORSO(const cv::Rect &roi);
104  void meanShift_STEP2_THIGHS();
105  void meanShift_STEP3_CALVES();
106  void meanShift_STEP4_HEAD();
107 
108  //Test Parameters of Biped Model when Drawing and generating mask
109  void getSilhouetteMask(cv::Rect roi, cv::Mat &image2);
110 
111  void setParamModel();
112 
113  std::vector< cv::Rect > roi_evaluados;
114  FiveLink2DBodyModel bipedModel;
115 
116  //Razón para calcular el modelo de Altura
117  double hwRatio;
118 
119  //Threshold Detección de Candidatos Humanos
120  double detectThreshold;
121 
122  //Paŕametros evaluación del modelo
123  bool externalPar;
124  double costThreshold; //Threshold para la función de costo
125  double par_Mm; //Paŕametro para mediciones faltantes (a en paper)
126  double par_Ou; //Paŕametro para observaciones sin explicación (b en el paper)
127  int iterMeanShift;
128 
129  //MeanSHift
130  int n_samples; //Número de muestras en la vecindad utilizadas para MeanShift
131 
132  double ratio_Torso_height;
133  double ratio_Torso_width;
134  double ratio_Limbs_height;
135  double ratio_Limbs_width;
136  double ratio_Head_height;
137  double ratio_Head_width;
138 
139  //Razón de distancia entre los muslos y el centro del modelo (Depende de la vista actual)
140  double relativePos_LimbsTorso;
141 
142  //Razón de distancia entre partes del cuerpo
143  double beta;
144  double gama;
145  double alpha;
146 
147  //Ángulos iniciales del Modelo
148  double init_angleHead;
149  double init_angleTorso;
150  double init_angleLimbsTopLeft;
151  double init_angleLimbsTopRight;
152  double init_angleLimbsBottomLeft;
153  double init_angleLimbsBottomRight;
154 
155  //Parámetros que definen la vecindad donde se generarán los valores aleatorios para Meanshift
156  double neighboring_X_axis;
157  double neighboring_Y_axis;
158  double neighboring_Torso_angle;
159  double neighboring_Thigs_angle;
160  double neighboring_Calves_angle;
161  double neighboring_Head_angle;
162 
163  //Umbral basado en distancia entre modelos para definir cuando Meanshift converge
164  double diffDistModel_Threshold;
165 
166  bool drawFlag;
167 
168  cv::Point2f *getRectModelPoints(int part);
169  double calculateStdDesv(QString attName);
170 };
171 
172 #endif // BIPEDARTICULATEDMODEL_H
Definition: fivelink2dbodymodel.h:53
Definition: bipedarticulatedmodel.h:18
Definition: reliabilitysinglemodelinterface.h:96
Definition: bipedarticulatedmodel.h:25