VAT  3.0
Video Analysis Tool
DeguTrackingModel.h
1 #ifndef DEGUTRACKINGMODEL_H
2 #define DEGUTRACKINGMODEL_H
3 
4 #include "Blob2DFromBGSubstractionModel.h"
5 #include <opencv2/opencv.hpp>
6 
7 #include <QDomNode>
8 #include <QImage>
9 #include <vector>
10 #include <QSharedPointer>
11 
12 #include "reliabilitysinglemodelinterface.h"
13 #include "src/blob.h"
14 #include "src/hullmodel.h"
15 
16 class Datapool;
17 
19 {
20 public:
22 
24 
25  void initDynamicsAttributes();
26 
27  //sets activation criteria for each model: reliability on input (distance, bad data),
28  // needs (occlusion, priority),
29  //sets priority of models (hierarchy).
30  void setParameters(QDomNode &i_parameters);
31 
32 
33 
34 
35  //updates every activated model dynamics
36  void updateDynamics();
37 
38 
39  //sets blob enclosing the model.
40  void setBlobInterface();
41 
42 
43  void initAttribute(ReliabilityDynamicsAttribute &d, AttributeDupletValue &i);
44 
45  void copy(SpReliabilitySingleModelInterface);
46 
47 
48  void makeHistoryGraph();
49  void makeHistoryGraph_Dynamics();
50 
51  void checkHistory();
52  void checkHistory_Dynamics();
53 
54  bool shapeAnalysis();
55  bool shapeAnalysis_Dynamics();
56 
57  float Hues[360];
58 
59  std::vector<uchar> pixels;
60 
61  SpHullModel deguShape;
62 
63  //int Hues[36];
64 
65  int pSize;
66  int pDiscard;
67  int nFrames;
68 
69  float colorAccuracy;
70 
71  int m_first_color_range;
72  int m_second_color_range;
73 
74 
75  static bool movementFound(cv::Mat f, int wsize, int i0, int j0);
76  static bool movementFound(cv::Mat f, int wsize, int i0, int j0, cv::Rect roi);
77  static double histogramDistance(cv::MatND h1, cv::MatND h2);
78  static double distanceToSegment(int i1, int i2, std::vector<cv::Point> &contour);
79  static bool lineSegmentIntersection(cv::Point3f &line,
80  cv::Point2f &p1, cv::Point2f &p2, cv::Point2f &r);
81  static bool getGeneralLineForm(cv::Point2f p1, cv::Point2f p2,
82  cv::Point3f &rline);
83  static bool getGeneralLineForm(float x, float y, float dx, float dy,
84  cv::Point3f &rline);
85 
86 
87  //Get intersection points r1 and r2 between line 'rline' and contour 'hull' (oriented to
88  //convex hull). If non NULL n1 and n2 pointers, are used to store indexes of contour segments
89  //where intersections were found (to be used later on pixel distance function construction).
90  static int getContourToLineIntersection(std::vector<cv::Point> &hull,
91  cv::Point3f &rline,
92  cv::Point2f &r1, cv::Point2f &r2,
93  int *n1 = NULL, int *n2 = NULL);
94 
95  //Fills a segments vector with moving pixel bounds for each normal on the axis
96  void getNormalIntersections(cv::Mat &f, cv::Rect &roi, std::vector<cv::Point> &hull,
97  cv::Point2f &r1, cv::Point2f &r2, int n1, int n2,
98  float dx, float dy, std::vector< segment2D<float> > &segs,
99  std::vector< segment2D<float> > &hull_segs);
100 
101  //Sets the moving segment for one normal
102  void setForegroundSegment(cv::Mat &f, cv::Rect &roi, std::vector<cv::Point> &hull,
103  segment2D<float> &seg, segment2D<float> &hseg, float x, float y,
104  float dx, float dy, int &I1, int &I2);
105 
106 
107  //Gets the intersection betweel a line and a contour, in current or next contour
108  //segment.
109  static int getContourToLineIntersectionIndexed(std::vector<cv::Point> &polygon,
110  cv::Point3f &rline,
111  cv::Point2f &r1, cv::Point2f &r2,
112  int &n1, int &n2);
113 
114  //Counts foreground pixels on a window
115  static int movementCount(cv::Mat f, int wsize, int i0, int j0, cv::Rect roi);
116 
117  void findHead(SpHullModel hull);
118 
119 
120  cv::Point2f headLocation;
121 };
122 
123 //typedef QSharedPointer<Blob2DFromBGSubstractionModelDynamics> SpBlob2DFromBGSubstractionModelDynamics;
124 
125 #endif // DEGUTRACKINGMODEL_H
Definition: geometric.h:103
Definition: reliabilityattribute.h:101
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: DeguTrackingModel.h:18
Definition: Blob2DFromBGSubstractionModel.h:14