-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathBioTrackerApp.h
More file actions
195 lines (158 loc) · 5.1 KB
/
Copy pathBioTrackerApp.h
File metadata and controls
195 lines (158 loc) · 5.1 KB
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
#pragma once
#include <memory>
#include <exception>
#include <boost/filesystem.hpp>
#include <QObject>
#include <QKeyEvent>
#include <QMouseEvent>
#include "biotracker/core/TrackingThread.h"
#include "biotracker/core/ImageStream.h"
#include "biotracker/core/Registry.h"
#include "biotracker/core/settings/Settings.h"
namespace BioTracker {
namespace Core {
/* Used to be Facade */
class BioTrackerApp : public QObject {
Q_OBJECT
public:
BioTrackerApp();
~BioTrackerApp() override;
void initConnects();
void initializeOpenGL(QOpenGLContext *mainContext, TextureObject &texture);
Settings &getSettings() {
return m_settings;
}
Registry &getRegistry() {
return m_registry;
}
TrackingThread &getTrackingThread() {
return m_trackingThread;
}
TrackingThread::TrackerStatus getStatus() const {
return m_trackingThread.getStatus();
}
/**
* @throw boost::filesystem_error
* @brief openVideo opens a single video which type is supported by opencv and stores path in settings
*/
void openVideo(const boost::filesystem::path &path);
/**
* @throw boost::filesystem_error
* @brief openImages opens a set of images supported by opencv and stores path in settings
*/
void openImages(std::vector<boost::filesystem::path> paths);
/**
* @brief openCamera opens a video device supported by opencv VideoCapture
*/
void openCamera(int device);
/**
* @brief play starts playing the video
*/
void play();
/**
* @brief pause stops the video at the current frame + 1
*/
void pause();
/**
* @brief paint
* @param device
* @param painter
*/
void paint(QPaintDevice &device, QPainter &painter);
/**
* @return when True, the thread is still rendering a frame right now, even when
* paused
*/
bool isRendering();
/**
* Attention: This boolean does not reflect the actual state in the tracking thread but
* rather the attempted status; that means, that it might return false, when "pause" is
* called but the tracking thread might still render a last frame.
* @brief isRunning
* @return True if the biotracker is playing, if it set to pause, False is returned.
*/
bool isRunning();
/**
* @brief setFrame (0 .. getNumFrames() - 1) if the input does not meets the
* invariant the frame will stay at the current frame
*/
void setFrame(size_t frameNumber);
/**
* @brief setTargetFps
* if variant is invalid, input is ignored
* Default value is set by the data from the video, if this is not
* applicable, INFINITY is selected
* @param fps (0 .. INFINITY)
*/
void setTargetFps(double fps);
/**
* @brief getTargetFps
* @return the set FPS of the program
*/
double getTargetFps() const;
/**
* @brief getNumFrames
* @return the number of frames in the current stream
*/
size_t getNumFrames() const;
/**
* @brief getCurrentFrame
* @return the current frame number
*/
size_t getCurrentFrameNumber() const;
/**
* @brief setTrackingAlgorithm
* @param TrackingAlgorithm the selected algorithm
*/
void setTrackingAlgorithm(std::shared_ptr<TrackingAlgorithm> TrackingAlgorithm);
void mouseEvent(QMouseEvent *event);
void keyboardEvent(QKeyEvent *event);
private Q_SLOTS:
/**
* @brief notify
* Status messages for the user interface
*/
void notifyFromTrackingThread(const std::string &message,
const MSGS::MTYPE type);
/**
* @brief notify
* Status messages for the user interface
*/
void fileOpenedFromTrackingThread(const std::string fileName,
const size_t numFrame);
/**
* @brief notify
* Status messages for the user interface
* When currentFps = -1, we are not running the video stream but rather
* just clicked next or previous
*/
void frameCalculatedFromTrackingThread(const size_t frameNumber,
const std::string filename, const double currentFps);
Q_SIGNALS:
/**
* @brief notify
* Status messages for the user interface
*/
void notify(const std::string &message, const MSGS::MTYPE type);
/**
* @brief fileOpened
* Update event for title and slider
*/
void fileOpened(const std::string message, const size_t numFrame);
/**
* @brief frameCalculated
* Callback that gets called every time a new frame is calculated
* @param frameNumber the frame number of the calculated frame
* @param filename filename of the current frame
* @param currentFps actual fps of the calculation
*/
void frameCalculated(const size_t frameNumber, const std::string filename,
const double currentFps);
private:
bool m_isRunning;
Settings m_settings;
Registry &m_registry;
TrackingThread m_trackingThread;
};
} // Core
} // BioTracker