forked from Smorodov/Multitarget-tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAsyncDetector.h
74 lines (58 loc) · 1.86 KB
/
AsyncDetector.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
#pragma once
#include <iostream>
#include <vector>
#include <map>
#include <thread>
#include <mutex>
#include <chrono>
#include <atomic>
#include <condition_variable>
#include "BaseDetector.h"
#include "Ctracker.h"
// ----------------------------------------------------------------------
///
/// \brief The FrameInfo class
///
struct FrameInfo
{
cv::Mat m_frame;
cv::UMat m_clFrame;
regions_t m_regions;
std::vector<TrackingObject> m_tracks;
int64 m_dt = 0;
float m_fps = 0;
size_t m_frameInd = 0;
std::atomic<int> m_inDetector; // 0 - not in Detector, 1 - detector started processing, 2 - objects was detected
std::atomic<int> m_inTracker; // 0 - not in Tracker, 1 - tracker started processing, 2 - objects was tracked
FrameInfo(size_t frameInd)
: m_frameInd(frameInd), m_inDetector(0), m_inTracker(0)
{
}
};
#include "Queue.h"
// ----------------------------------------------------------------------
///
/// \brief The AsyncDetector class
///
class AsyncDetector
{
public:
AsyncDetector(const cv::CommandLineParser& parser);
~AsyncDetector();
void Process();
private:
bool m_showLogs = false;
float m_fps = 0;
std::string m_inFile;
std::string m_outFile;
int m_startFrame = 0;
int m_endFrame = 0;
int m_finishDelay = 0;
std::vector<cv::Scalar> m_colors;
FramesQueue m_framesQue;
void DrawData(frame_ptr frameInfo, int framesCounter, int currTime);
void DrawTrack(cv::Mat frame, int resizeCoeff, const TrackingObject& track, bool drawTrajectory = true);
static void CaptureThread(std::string fileName, int startFrame, float* fps, FramesQueue* framesQue, bool* stopFlag);
static void DetectThread(const config_t& config, cv::Mat firstFrame, FramesQueue* framesQue, bool* stopFlag);
static void TrackingThread(const TrackerSettings& settings, FramesQueue* framesQue, bool* stopFlag);
};