VAT  3.0
Video Analysis Tool
HullToObjectModule.h
1 #ifndef HULLTOOBJECTMODULE_H
2 #define HULLTOOBJECTMODULE_H
3 
4 #include <map>
5 #include <string>
6 #include <QImage>
7 #include "Datapool.h"
8 #include "ModuleInterface.h"
9 #include "src/hullmodel.h"
10 
11 #include <QDir>
12 
14 public:
17 
18  //Set module configuration parameters
19  bool setParameters(QDomNode& config);
20 
21  //Initialization after reading parameters
22  bool init();
23 
24  //Function executed at each frame
25  bool run();
26 
27  //update parameters at runtime.
28  bool updateParameters();
29 
30  void completeBlobs(std::deque<SpRMMMobileObject> &objects, QImage *fg, QImage *current);
31  static bool movementFound(cv::Mat f, int wsize, int i0, int j0);
32  static bool movementFound(cv::Mat f, int wsize, int i0, int j0, cv::Rect roi);
33  static double histogramDistance(cv::MatND h1, cv::MatND h2);
34  static double distanceToSegment(int i1, int i2, std::vector<cv::Point> &contour);
35  static bool lineSegmentIntersection(cv::Point3f &line,
36  cv::Point2f &p1, cv::Point2f &p2, cv::Point2f &r);
37  static bool getGeneralLineForm(cv::Point2f p1, cv::Point2f p2,
38  cv::Point3f &rline);
39  static bool getGeneralLineForm(float x, float y, float dx, float dy,
40  cv::Point3f &rline);
41 
42 
43  //Get intersection points r1 and r2 between line 'rline' and contour 'hull' (oriented to
44  //convex hull). If non NULL n1 and n2 pointers, are used to store indexes of contour segments
45  //where intersections were found (to be used later on pixel distance function construction).
46  static int getContourToLineIntersection(std::vector<cv::Point> &hull,
47  cv::Point3f &rline,
48  cv::Point2f &r1, cv::Point2f &r2,
49  int *n1 = NULL, int *n2 = NULL);
50 
51  //Fills a segments vector with moving pixel bounds for each normal on the axis
52  void getNormalIntersections(cv::Mat &f, cv::Rect &roi, std::vector<cv::Point> &hull,
53  cv::Point2f &r1, cv::Point2f &r2, int n1, int n2,
54  float dx, float dy, std::vector< segment2D<float> > &segs,
55  std::vector< segment2D<float> > &hull_segs);
56 
57  //Sets the moving segment for one normal
58  void setForegroundSegment(cv::Mat &f, cv::Rect &roi, std::vector<cv::Point> &hull,
59  segment2D<float> &seg, segment2D<float> &hseg, float x, float y,
60  float dx, float dy, int &I1, int &I2);
61 
62  //Gets the intersection betweel a line and a contour, in current or next contour
63  //segment.
64  static int getContourToLineIntersectionIndexed(std::vector<cv::Point> &polygon,
65  cv::Point3f &rline,
66  cv::Point2f &r1, cv::Point2f &r2,
67  int &n1, int &n2);
68 
69  //Counts foreground pixels on a window
70  static int movementCount(cv::Mat f, int wsize, int i0, int j0, cv::Rect roi);
71 
72  int line;
73  int cont;
74 
75  int m_bins;
76  int w_size;
77  int m_hullOffset;
78  float m_K;
79 };
80 
81 #endif // HULLTOOBJECTMODULE_H
Definition: geometric.h:103
Definition: HullToObjectModule.h:13
Definition: ModuleInterface.h:43
An object of this class is instantiated at main code, and this object is used by every class to push ...
Definition: Datapool.h:39