-
Notifications
You must be signed in to change notification settings - Fork 0
/
zfttracks.h
118 lines (83 loc) · 3.97 KB
/
zfttracks.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#ifndef ZFTTRACKS
#define ZFTTRACKS
#include <opencv2/opencv.hpp>
#include <opencv2/core/core.hpp>
#include "opencv2/core/utility.hpp"
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/features2d.hpp>
#include <string>
#include <QTextStream>
#define CV_TRACK_RENDER_ID 0b00000001 ///< Print the ID of each track in the image. \see cvRenderTrack
#define CV_TRACK_RENDER_BOUNDING_BOX 0b00000010 ///< Draw bounding box of each track in the image. \see cvRenderTrack
#define CV_TRACK_RENDER_BOUNDING_CIRCLE 0b00000100 ///< Draw bounding box of each track in the image. \see cvRenderTrack
#define CV_TRACK_RENDER_TO_LOG 0b00001000 ///< Print track info to log out. \see cvRenderTrack
#define CV_TRACK_RENDER_TO_STD 0b00010000 ///< Print track info to log out. \see cvRenderTrack
#define CV_TRACK_RENDER_PATH 0b00100000 ///< Draw polyline of track positions \see cvRenderTrack
#define CV_TRACK_RENDER_HIGHLIGHT 0b01000000 ///Draw Colour Indicate Highlight
/// \brief Type of identification numbers.
typedef unsigned int zftID;
typedef unsigned int zfdID;
/// \var typedef std::vector<cv:Point2f> TrackPoints
/// \brief stores the stacked List of past centroid points that define this track.
/// \see CvPoint2D64f
/// \see CvTrack
typedef cv::Point2f zftTrackPoint;
typedef std::vector<zftTrackPoint> zftTrackPoints;
typedef std::list<cv::Point> zftRenderedTrackPoints; //Used only For Rendering on image /Shorter vector And Integer based
///// \var typedef std::map<CvID, CvTrack *> CvTracks
///// \brief List of tracks.
///// \see CvID
///// \see CvTrack
//typedef std::map<CvID, CvTrack *> CvTracks;
///// \var typedef std::pair<CvID, CvTrack *> CvIDTrack
///// \brief Pair (identification number, track).
///// \see CvID
///// \see CvTrack
//typedef std::pair<CvID, CvTrack *> CvIDTrack;
//CvFont* defaultFont = NULL;
/// \brief Struct that contain information about one track.
/// \see CvID
/// \see ltROI
/// \see pointStack
/// \note zftTrack Maintains two list of track Points - the detailed floating point one is used for
/// analysis of movement, while the RenderPoints is optimized for rendering tracks, its integer and only holds
/// points which are displaced above D>=0.5, making the list shorted and quicker to render.
struct zftTrack
{
zftTrack()
{
//Random colour
int c1 = rand() % 200 + 30;
int c2 = rand() % 200 + 30;
int c3 = rand() % 200 + 30;
colour = CV_RGB(c1,c2,c3);
lifetime = 0;
active = 0;
inactive = 0;
effectiveDisplacement = 0.0;
}
//Default Constructor
zftTrack(zftID ID):zftTrack()
{
id = ID;
}
void addRenderPoint(cv::Point2f& pt);
zftID id; ///< Track identification number.
//ltROI* pROI; ///< Pointer To Region of Interest structure to which this track belongs
cv::Scalar colour = CV_RGB(255., 0., 0.); ///> Colourwhen drawing Countour
cv::Rect boundingBox;
cv::Point2f centroid; ///< Centroid.
zftTrackPoints pointStack; /// <Holds list of past centroid positions along the track
zftRenderedTrackPoints pointStackRender; //List Of Int Points Used for rendering Only
std::vector<cv::Point> vplotPts;//(track.pointStackRender.begin(), track.pointStackRender.end());
double effectiveDisplacement; ///< Used to indicate a px speed measure so as to estimate possible blob distance from track on next frame.
unsigned int lifetime; ///< Indicates how much frames the object has been in scene.
unsigned int active; ///< Indicates number of frames that has been active from last inactive period.
unsigned int inactive; ///< Indicates number of frames that has been missing.
};
/// \brief Render A zftracker Track
///
void zftRenderTrack(zftTrack& track, const cv::Mat& frameIn, cv::Mat& frameOut, unsigned short mode, int fontface,float fontScale );
std::ostream& operator<<(std::ostream& out, const zftTrack& h);
QTextStream& operator<<(QTextStream& out, const zftTrack& h);
#endif // ZFTTRACKS