33 #include <condition_variable>
39 #include "../common.h"
117 static void detach(std::unique_ptr<Recorder>&& ptr)
118 { detached_recorders.push_back(std::move(ptr)); }
166 bool open(
const std::string& filename,
int fourcc,
167 double fps, cv::Size frameSize,
bool isColor =
true);
204 enum class RecorderStatus { ALIVE, STOP, TERMINATE };
213 inline bool fetch(std::unique_lock<std::mutex>& guard);
219 static void flushDetached();
226 inline cv::Mat pop();
234 inline void setStatus(RecorderStatus new_status);
243 bool is_open =
false;
246 std::deque<cv::Mat> buffer;
247 std::mutex buffer_mutex;
248 cv::Mat latest_image;
249 RecorderStats statistics = EMPTY_RECORDER_STATS;
250 RecorderStatus status = RecorderStatus::ALIVE;
251 std::condition_variable wake_worker;
252 std::unique_ptr<std::thread> worker =
nullptr;
257 std::unique_ptr<cv::VideoWriter> writer =
nullptr;
260 static std::vector<std::unique_ptr<Recorder>> detached_recorders;
unsigned int missed_frames
The number of the frames that have missed the recording.
Definition: recorder.h:54
bool open(const std::string &filename, int fourcc, double fps, cv::Size frameSize, bool isColor=true)
Opens the video recorder.
Definition: recorder.cpp:116
unsigned int getRecordedFrames()
Returns the recorded frames.
Definition: recorder.cpp:103
unsigned int countBuffered()
Counts the currently buffered images.
Definition: recorder.cpp:60
bool repush()
Repushes the last image again to the buffer.
Definition: recorder.cpp:189
The buffered recorder class creates the video file from the images.
Definition: recorder.h:91
void stop()
Softly stops the recording.
Definition: recorder.cpp:224
bool isTerminated()
Retrieves the recorder status.
Definition: recorder.cpp:109
unsigned int written_frames
The frames that have been written by the recorder.
Definition: recorder.h:59
RecorderStats push(const cv::Mat &image)
Pushes the new image to the buffer.
Definition: recorder.cpp:163
Statistics structure used for Recorder.
Definition: recorder.h:48
static void detach(std::unique_ptr< Recorder > &&ptr)
Detaches the recorder.
Definition: recorder.h:117
unsigned int getMissedFrames()
Returns the count of the missed frames.
Definition: recorder.cpp:97
bool isOpen()
Returns the initialization status of the recorder.
Definition: recorder.h:144
DISALLOW_COPY_AND_ASSIGN(Recorder)
Copy and assign of the class is not allowed.