-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathBioTracker3ImageStream.h
More file actions
137 lines (111 loc) · 4 KB
/
BioTracker3ImageStream.h
File metadata and controls
137 lines (111 loc) · 4 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
#ifndef BIOTRACKER3IMAGESTREAM_H
#define BIOTRACKER3IMAGESTREAM_H
#include <memory> // std::unique_ptr
#include <opencv2/opencv.hpp> // cv::Mat
#include <vector> // std::vector
#include <string> // std::string
#include <boost/filesystem.hpp>
#include <QObject>
#include "settings/ParamNames.h" // GUIPARAM::MediaType
namespace BioTracker {
namespace Core {
class BioTracker3ImageStream : public QObject {
Q_OBJECT
public:
explicit BioTracker3ImageStream(QObject *parent = 0);
/**
* @return the stream's MediaType i.e. "Video", "Images", "NoMedia"
*/
virtual GuiParam::MediaType type() const = 0;
/**
* @return the total number of frames
*/
virtual size_t numFrames() const = 0;
/**
* @return the current frame number
*/
size_t currentFrameNumber() const;
/**
* @return true, if the current frame is the last frame
*/
bool lastFrame() const;
/**
* @return true, if the stream's end is reached; i.e. current frame points behind it's last frame
*/
bool end() const;
/**
* @return true, if currentFrame().empty();
*/
bool currentFrameIsEmpty() const;
/**
* @return the media's fps rate
*/
virtual double fps() const = 0;
/**
* @return the filename of the current file defined through the frameNumber
*/
virtual std::string currentFilename() const = 0;
/**
* returns the current frame.
* - if the current frame position is invalid or an error occurred, an empty image is returned.
*/
const cv::Mat ¤tFrame() const;
/**
* sets the current frame number and updates the current frame.
* - if frame_number is invalid, the current frame is invalidated.
* @return true if the operation was successful, i.e. the frame number is valid and no error occurred.
*/
bool setFrameNumber(size_t frame_number);
/**
* advances the current frame frame.
* - if this function is called on the media's last frame, the current frame is invalidated.
* @return true if the operation was successful, i.e. the current frame isn't the last frame and no error occurred.
*/
bool nextFrame();
/**
* sets the current frame position to the previous frame.
* - if this function is called on the media's first frame, the current frame is invalidated.
* @return true if the operation was successful, i.e. the current frame isn't the first one and no error occurred.
*/
bool previousFrame();
virtual ~BioTracker3ImageStream();
protected:
/**
* sets the image returned by this->currentFrame();
*/
void set_current_frame(const cv::Mat &img);
private:
/**
* empties m_current_frame & sets m_current_frame_number to this->numFrames();
*/
void clearImage();
/**
* - called by ImageStreamImpl::setFrameNumber
* if frame_number < numFrames() && frame_number != this->currentFrameNumber();
* - m_current_frame_number is updated afterwards
*/
virtual bool setFrameNumber_impl(size_t frame_number) = 0;
/**
* - called by ImageStreamImpl::nextFrame()
* if currentFrameNumber() + 1 < numFrames();
* - m_current_frame_number is updated afterwards
*/
virtual bool nextFrame_impl();
/**
* - called by ImageStreamImpl::previousFrame()
* if currentFrameNumber() > 0;
* - m_current_frame_number is updated afterwards
*/
virtual bool previousFrame_impl();
cv::Mat m_current_frame;
size_t m_current_frame_number;
};
std::shared_ptr<BioTracker3ImageStream> make_ImageStream3NoMedia();
std::shared_ptr<BioTracker3ImageStream> make_ImageStream3Pictures(
std::vector<boost::filesystem::path> filenames);
std::shared_ptr<BioTracker3ImageStream> make_ImageStream3Video(const boost::filesystem::path
&filename);
std::shared_ptr<BioTracker3ImageStream> make_ImageStream3Camera(int device);
}
}
#endif // BIOTRACKER3IMAGESTREAM_H