VAT  3.0
Video Analysis Tool
fivelink2dbodymodel.h
1 #ifndef FIVELINK2DBODYMODEL_H
2 #define FIVELINK2DBODYMODEL_H
3 
4 #include "opencv2/opencv.hpp"
5 #include <QString>
6 
7 #define TORSO 0
8 #define LIMBSTOPLEFT 1
9 #define LIMBSTOPRIGHT 2
10 #define LIMBSBOTTOMLEFT 3
11 #define LIMBSBOTTOMRIGHT 4
12 #define HEAD 5
13 
14 typedef struct posture posture;
15 
16 struct posture{
17  /*Centros del Modelo*/
18  cv::Point2f center;//Center of the model
19  cv::Point2f centerthighsLeft;
20  cv::Point2f centerthighsRight;
21  /*Vector de inclinación representando los angulos entre los ejes de las partes del cuerpo y
22  el eje vertical y*/
23  std::vector<double> angles;
24 };
25 
26 typedef struct shape shape;
27 struct shape{
28  //Base-to-height Ratio (alpha = b/l base and length of each rectangle). K= {a1,...,a6}
29  std::vector<double> K;
30  //Vector de Altura Relativas (ri = li/l1), R = {r1,...,r6}
31  std::vector<double> R;
32 };
33 
34 typedef struct baseModel baseModel;
35 struct baseModel{
36  //Base-to-height Ratio (alpha = b/l base and length of each rectangle). K= {a1,...,a6}
37  posture T;
38  //Vector de Altura Relativas (ri = li/l1), R = {r1,...,r6}
39  shape S;
40 };
41 
42 typedef struct postureDraw postureDraw;
43 struct postureDraw
44 {
45  float x, y;
46  float base;
47  float height;
48  float angle; //Rad
49 
50  float x_prev, y_prev;
51 };
52 
54 {
55 
56 public:
57 
59  FiveLink2DBodyModel(int id_p);
61 
62  void drawModel(cv::Mat &img, bool paintExModel = true, int part = TORSO);
63 
64  void saveModel(); //SaveModel in .xml File
65  bool initModel(cv::Rect roi, bool extPar, int w, int h);
66  void setId(unsigned int index);
67 
68  bool torsoModelPoints(double height, double width);
69  bool thighsModelPoints(double height);
70  bool calvesModelPoints(double height);
71  bool headModelPoints(double height);
72 
73  void setModelRectangle(cv::Point2f center, cv::Size2f size, float angle,int part);
74 
75  cv::Mat getDatasetOfModel();
76 
77  bool initOKAll();
78 
79  int id;
80  baseModel Mb; //Modelo Base
81  cv::Rect M; //Rectangulo vecino que se le agrega al modelo Base
82 
83  /*28 points of the model in a current position of player
84  * This points should be in concordance with the position of the player on the image
85  */
86  std::vector<cv::RotatedRect> modelRectangles;
87  void printModelRectangleInfo(int part);
88 
89  std::vector<bool> initOK; //Vector que indica si los parámetros de cada una de las partes del cuerpo han sido inicializadas
90 
91  double constExtModel; //Constraint for the Extendend body Model
92  double torsoPropLF; //Proporción entre la vista lateral y frontal del torso
93  double torsoPropLD; //Proporción entre la vista lateral y diagonal del torso
94 
95  double beta; //Factor para desplazar la articulación de la parte inferior de la extr.
96  double alpha; //Factor para desplazar la articulación de la cabeza
97  double gama; //Factor para desplazar la parte inferior de los pies
98 
99  //Objetos que actualmente cumplen el Modelo
100  std::vector<int> associatedObj;
101 
102  //Parametros cálculo función de costo
103  double par_Mm_i; //Parámetro de Mediciones faltantes interno del modelo (puede haber uno global en el modulo)
104  double par_Ou_i; //Parámetro de Mediciones sin explicación interno del modelo (puede haber uno global en el modulo)
105  double costThreshold;//Parámetro para definir el umbral que considera una optimización del modelo adecuada
106 
107 
108  double ratio_Torso_height;
109  double ratio_Torso_width;
110  double ratio_Limbs_height;
111  double ratio_Limbs_width;
112  double ratio_Head_height;
113  double ratio_Head_width;
114 
115  double relativePos_LimbsTorso;
116 
117  double init_angleHead;
118  double init_angleTorso;
119  double init_angleLimbsTopLeft;
120  double init_angleLimbsTopRight;
121  double init_angleLimbsBottomLeft;
122  double init_angleLimbsBottomRight;
123 
124  cv::Point2f centerROI; //Centro de la region de interes
125 
126 
127 };
128 
129 #endif // FIVELINK2DBODYMODEL_H
Definition: fivelink2dbodymodel.h:35
Definition: fivelink2dbodymodel.h:16
Definition: fivelink2dbodymodel.h:53
Definition: fivelink2dbodymodel.h:27
Definition: fivelink2dbodymodel.h:43