-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathImageProcessingEngine.h
108 lines (85 loc) · 2.62 KB
/
ImageProcessingEngine.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
#ifndef IMAGE_PROCESSING_ENGINE_H
#define IMAGE_PROCESSING_ENGINE_H
#include "PipelinePlugin.h"
#include "Parameters.h"
#include "Capture.h"
#include <vector>
#include <iostream>
#include <thread>
#include <mutex>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/features2d/features2d.hpp>
class Blob;
struct ImageProcessingEngine
{
// about source
Capture* capture = nullptr;
/* // about frames */
int frameNumber = 0;
int lastFrameNumber = 0;
bool staticFrame = true;
// about image processing
cv::Mat background;
cv::Mat zoneMap;
cv::Mat marked;
cv::Mat labels;
std::vector<cv::KeyPoint> keypoints;
std::vector<Blob> blobs;
// about visualisation
cv::Mat pipelineSnapshot;
cv::Mat pipelineSnapshotMarked;
bool takeSnapshot;
unsigned int snapshotPos;
cv::Mat hud;
// about threads
unsigned int threadsCount = 0;
std::vector<std::thread> threads;
std::vector<std::mutex*> threadsStart; // unlocked by ipEngine exclusively
std::vector<std::mutex*> threadsDone; // unlocked by threads exclusively
std::vector<std::mutex*> threadsPause; // unlocked by special thread exclusively
std::vector<std::mutex*> threadsRestart; // unlocked by threads exclusively
bool threadsStop;
bool threadsDrawHud;
bool threadsOutput;
std::vector<Pipeline> pipelines;
// about time :-)
/* float currentTime; */
// ...parameters
float startTime = 0.0;
float durationTime = 0.0;
float timestep = 0.0;
float nextStepTime = 0.0;
bool useTimeBoundaries = false;
// background
enum BgCalcType {BG_MEAN, BG_MEDIAN};
BgCalcType bgCalcType = BG_MEAN;
std::string bgFilename;
bool bgRecalculate = false;
int bgFrames = 11;
float bgEndTime = 0.0;
float bgStartTime = 0.0;
unsigned char bgLowThreshold = 0;
unsigned char bgHighThreshold = 255;
// zones of interest
std::string zonesFilename;
// output
bool output = false;
// main operation
ImageProcessingEngine ();
~ImageProcessingEngine ();
void Reset (Parameters& parameters);
void Reset();
void LoadXML (cv::FileNode& fn);
void SaveXML (cv::FileStorage& fs);
void Step (bool drawHud = false);
bool GetNextFrame();
void OpenOutput();
void CloseOutput();
// about pipeline and threads
void PipelineThread (unsigned int id);
void SetupThreads ();
void PushBack (std::vector<PipelinePlugin*> pfv, bool reset = false);
void Insert (int pos, std::vector<PipelinePlugin*> pfv, bool reset = false);
std::vector<PipelinePlugin*> Erase (unsigned int pos);
};
#endif