Ocean
Loading...
Searching...
No Matches
OILImageSequenceRecorder.h
Go to the documentation of this file.
1/*
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 */
7
8#ifndef META_OCEAN_MEDIA_OPEN_IMAGE_LIBRARIES_OL_IMAGE_SEQUENCE_RECORDER_H
9#define META_OCEAN_MEDIA_OPEN_IMAGE_LIBRARIES_OL_IMAGE_SEQUENCE_RECORDER_H
10
13
15
16#include "ocean/base/Thread.h"
17
18#include <queue>
19
20namespace Ocean
21{
22
23namespace Media
24{
25
26namespace OpenImageLibraries
27{
28
29/**
30 * This class implements an OpenImageLibraries image sequence recorder.
31 * @ingroup mediaoil
32 */
33class OCEAN_MEDIA_OIL_EXPORT OILImageSequenceRecorder :
35 public Thread
36{
37 friend class OILLibrary;
38
39 protected:
40
41 /**
42 * Definition of a queue holding frame references and frame indices.
43 */
44 typedef std::queue<std::pair<FrameRef, unsigned int>> FrameQueue;
45
46 public:
47
48 /**
49 * Returns the mode of this recorder.
50 * @see ImageSequenceRecorder::mode().
51 */
52 RecorderMode mode() const override;
53
54 /**
55 * Returns the number of currently buffered images.
56 * @see ImageSequenceRecorder::pendingImages().
57 */
58 unsigned int pendingImages() const override;
59
60 /**
61 * Returns a list of possible frame encoders for this recorder.
62 * @see FrameRecorder::frameEncoders().
63 */
64 Encoders frameEncoders() const override;
65
66 /**
67 * Sets the mode of this recorder.
68 * @see ImageSequenceRecorder::setMode().
69 */
70 bool setMode(const RecorderMode mode) override;
71
72 /**
73 * Sets the start index with witch the filename of the first frame will start.
74 * @see ImageSequenceRecorder::setStartIndex().
75 */
76 bool setStartIndex(const unsigned int index) override;
77
78 /**
79 * Adds a given frame explicity.
80 * @see ImageSequenceRecorder::addImage().
81 */
82 bool addImage(const Frame& frame) override;
83
84 /**
85 * Sets the recorder.
86 * @see FileRecorder::start().
87 */
88 bool start() override;
89
90 /**
91 * Stops the recorder.
92 * @see FileRecorder::stop().
93 */
94 bool stop() override;
95
96 /**
97 * Returns whether this recorder is currently recording.
98 * @see Recorder::isRecording().
99 */
100 bool isRecording() const override;
101
102 /**
103 * Explicitly invokes the image saving if the recorder is in RM_EXPLICIT mode.
104 * @see ImageSequenceRecorder::invokeSaving().
105 */
106 bool forceSaving() override;
107
108 /**
109 * Returns a pointer to the most recent buffer to be filled immediately and locks it.
110 * @see FrameRecorder::lockBufferToFill().
111 */
112 bool lockBufferToFill(Frame& recorderFrame, const bool respectFrameFrequency = true) override;
113
114 /**
115 * Unlocks the filled buffer.
116 * @see FrameBuffer::unlockBufferToFill().
117 */
118 void unlockBufferToFill() override;
119
120 protected:
121
122 /**
123 * Creates a new image sequence recorder object.
124 */
126
127 /**
128 * Destructs an image sequence recorder object.
129 */
131
132 /**
133 * Thread run function.
134 * @see Thread::threadRun().
135 */
136 void threadRun() override;
137
138 protected:
139
140 /// Recorder for single frames.
142
143 /// Queue holding the frames to be saved.
145
146 /// Frame counter.
147 unsigned int frameCounter_ = 0u;
148
149 /// Start timestamp.
151
152 /// Intermediate frame receiving the frame data.
154
155 /// State determining whether the recorder is currently recording.
156 bool isRecording_ = false;
157
158 /// Frame queue lock.
160};
161
162}
163
164}
165
166}
167
168#endif // META_OCEAN_MEDIA_OPEN_IMAGE_LIBRARIES_OL_IMAGE_SEQUENCE_RECORDER_H
This class implements Ocean's image class.
Definition Frame.h:1808
This class implements a recursive lock object.
Definition Lock.h:31
This class implements an image sequence recorder.
Definition ImageSequenceRecorder.h:38
RecorderMode
Definition of individual recorder modes.
Definition ImageSequenceRecorder.h:45
This class implements an image recorder for OpenImageLibraries.
Definition OILImageRecorder.h:30
This class implements an OpenImageLibraries image sequence recorder.
Definition OILImageSequenceRecorder.h:36
Encoders frameEncoders() const override
Returns a list of possible frame encoders for this recorder.
RecorderMode mode() const override
Returns the mode of this recorder.
bool setMode(const RecorderMode mode) override
Sets the mode of this recorder.
Frame frame_
Intermediate frame receiving the frame data.
Definition OILImageSequenceRecorder.h:153
~OILImageSequenceRecorder() override
Destructs an image sequence recorder object.
bool addImage(const Frame &frame) override
Adds a given frame explicity.
unsigned int pendingImages() const override
Returns the number of currently buffered images.
std::queue< std::pair< FrameRef, unsigned int > > FrameQueue
Definition of a queue holding frame references and frame indices.
Definition OILImageSequenceRecorder.h:44
OILImageRecorder imageRecorder_
Recorder for single frames.
Definition OILImageSequenceRecorder.h:141
bool setStartIndex(const unsigned int index) override
Sets the start index with witch the filename of the first frame will start.
bool forceSaving() override
Explicitly invokes the image saving if the recorder is in RM_EXPLICIT mode.
bool lockBufferToFill(Frame &recorderFrame, const bool respectFrameFrequency=true) override
Returns a pointer to the most recent buffer to be filled immediately and locks it.
Timestamp startTimestamp_
Start timestamp.
Definition OILImageSequenceRecorder.h:150
OILImageSequenceRecorder()
Creates a new image sequence recorder object.
FrameQueue frameQueue_
Queue holding the frames to be saved.
Definition OILImageSequenceRecorder.h:144
bool isRecording() const override
Returns whether this recorder is currently recording.
void unlockBufferToFill() override
Unlocks the filled buffer.
Lock frameQueueLock_
Frame queue lock.
Definition OILImageSequenceRecorder.h:159
This class implements the OpenImageLibraries library.
Definition OILLibrary.h:30
std::vector< std::string > Encoders
Definition of a vector holding encoder names.
Definition Recorder.h:80
This class implements a thread.
Definition Thread.h:115
This class implements a timestamp.
Definition Timestamp.h:36
The namespace covering the entire Ocean framework.
Definition Accessor.h:15