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