Ocean
Loading...
Searching...
No Matches
ImageFileSequence.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_IMAGE_FILE_SEQUENCE_H
9#define META_OCEAN_MEDIA_IMAGE_FILE_SEQUENCE_H
10
11#include "ocean/media/Media.h"
13
14#include "ocean/base/Thread.h"
15
16namespace Ocean
17{
18
19namespace Media
20{
21
22/*
23 * This class implements the base class for all image sequences based on actual files (and not on databases containing images).
24 * the class is mainly an intermediate helper class to simplify the implementation of an ImageSequence based on files.
25 * @ingroup media
26 */
27class OCEAN_MEDIA_EXPORT ImageFileSequence :
28 public virtual ImageSequence,
29 protected Thread
30{
31 public:
32
33 /**
34 * Returns the duration of the finite medium.
35 * @see FiniteMedium::duration().
36 */
37 double duration() const override;
38
39 /**
40 * Returns the duration without speed consideration.
41 * @see FiniteMedium::normalDuration().
42 */
43 double normalDuration() const override;
44
45 /**
46 * Returns the recent position of the finite medium.
47 * @see FiniteMedium::position().
48 */
49 double position() const override;
50
51 /**
52 * Returns the speed of the finite medium.
53 * The speed of an image sequence is identical with the preferred frame rate (fps).
54 * @return The current speed of this image sequence in fps, with range [0, infinity)
55 */
56 float speed() const override;
57
58 /**
59 * Returns the url of the current image.
60 * @see ImageSequence::currentUrl().
61 */
62 std::string currentUrl() const override;
63
64 /**
65 * Returns the number of images part of the sequence.
66 * @see ImageSequence::images().
67 */
68 unsigned int images() const override;
69
70 /**
71 * Starts the medium.
72 * @see Medium::start().
73 */
74 bool start() override;
75
76 /**
77 * Pauses the medium.
78 * @see Medium::pause().
79 */
80 bool pause() override;
81
82 /**
83 * Stops the medium.
84 * @see Medium::stop().
85 */
86 bool stop() override;
87
88 /**
89 * Returns whether the medium is started currently.
90 * @see Medium::isStarted().
91 */
92 bool isStarted() const override;
93
94 /**
95 * Returns the start timestamp.
96 * @see FiniteMedium::startTimestamp().
97 */
98 Timestamp startTimestamp() const override;
99
100 /**
101 * Returns the pause timestamp.
102 * @see FiniteMedium::pauseTimestamp().
103 */
104 Timestamp pauseTimestamp() const override;
105
106 /**
107 * Returns the stop timestamp.
108 * @see FiniteMedium::stopTimestamp().
109 */
110 Timestamp stopTimestamp() const override;
111
112 /**
113 * Sets the recent position of the finit medium.
114 * @see FiniteMedium::setPosition().
115 */
116 bool setPosition(const double position) override;
117
118 /**
119 * Sets the speed of the finite medium.
120 * The speed of an image sequence is identical with the preferred frame rate (fps).
121 * @param speed The speed to be set in fps, with range [0, infinity)
122 * @see setPreferredFrameFrequency().
123 */
124 bool setSpeed(const float speed) override;
125
126 /**
127 * Forces the loading of the next image in the sequence.
128 * @see ImageSequence::forceNextFrame().
129 */
130 bool forceNextFrame() override;
131
132 protected:
133
134 /**
135 * Creates a new image file sequence by a given url.
136 * @param url Url of the image
137 */
138 explicit ImageFileSequence(const std::string& url);
139
140 /**
141 * Destructs an image file sequence object.
142 */
144
145 /**
146 * Thread run function.
147 * @see Thread::threadRun().
148 */
149 void threadRun() override;
150
151 /**
152 * Determines the image sequence parameters.
153 * @return True, if succeeded
154 */
156
157 /**
158 * Returns the filename of a specific sequence image.
159 * @param index Index of the sequence image to create the filename for
160 * @return Sequence image filename
161 */
162 std::string imageFilename(const unsigned int index) const;
163
164 /**
165 * Loads a new image specified by the filename.
166 * @param filename Filename of the image to be loaded
167 * @param timestamp Frame timestamp to be used
168 * @param frame Optional frame receiving the image data, otherwise the frame will be added to the frame container
169 * @return True, if succeeded
170 */
171 virtual bool loadImage(const std::string& filename, const Timestamp timestamp, Frame* frame = nullptr) = 0;
172
173 protected:
174
175 /// Start timestamp.
177
178 /// Pause timestamp.
180
181 /// Stop timestamp.
183
184 /// Image sequence prefix filename.
186
187 /// Image sequence filename type.
189
190 /// Next frame in the sequence.
192};
193
194}
195
196}
197
198#endif // META_OCEAN_MEDIA_IMAGE_FILE_SEQUENCE_H
This class implements Ocean's image class.
Definition Frame.h:1808
Definition ImageFileSequence.h:30
std::string mediumFilenamePrefix
Image sequence prefix filename.
Definition ImageFileSequence.h:185
std::string currentUrl() const override
Returns the url of the current image.
Timestamp startTimestamp() const override
Returns the start timestamp.
std::string imageFilename(const unsigned int index) const
Returns the filename of a specific sequence image.
void threadRun() override
Thread run function.
Timestamp mediumStopTimestamp
Stop timestamp.
Definition ImageFileSequence.h:182
bool forceNextFrame() override
Forces the loading of the next image in the sequence.
bool setPosition(const double position) override
Sets the recent position of the finit medium.
unsigned int images() const override
Returns the number of images part of the sequence.
bool stop() override
Stops the medium.
double normalDuration() const override
Returns the duration without speed consideration.
bool isStarted() const override
Returns whether the medium is started currently.
ImageFileSequence(const std::string &url)
Creates a new image file sequence by a given url.
Timestamp mediumStartTimestamp
Start timestamp.
Definition ImageFileSequence.h:176
Timestamp stopTimestamp() const override
Returns the stop timestamp.
float speed() const override
Returns the speed of the finite medium.
std::string mediumFilenameType
Image sequence filename type.
Definition ImageFileSequence.h:188
double position() const override
Returns the recent position of the finite medium.
bool setSpeed(const float speed) override
Sets the speed of the finite medium.
Frame mediumNextFrame
Next frame in the sequence.
Definition ImageFileSequence.h:191
Timestamp mediumPauseTimestamp
Pause timestamp.
Definition ImageFileSequence.h:179
Timestamp pauseTimestamp() const override
Returns the pause timestamp.
double duration() const override
Returns the duration of the finite medium.
virtual bool loadImage(const std::string &filename, const Timestamp timestamp, Frame *frame=nullptr)=0
Loads a new image specified by the filename.
bool start() override
Starts the medium.
~ImageFileSequence() override
Destructs an image file sequence object.
bool pause() override
Pauses the medium.
bool determineSequence()
Determines the image sequence parameters.
This class is the base class for all image sequences.
Definition ImageSequence.h:52
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