Ocean
ImageSequenceRecorder.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_SQUENCE_RECORDER_H
9 #define META_OCEAN_MEDIA_IMAGE_SQUENCE_RECORDER_H
10 
11 #include "ocean/media/Media.h"
14 
15 namespace Ocean
16 {
17 
18 namespace Media
19 {
20 
21 // Forward declaration.
22 class ImageSequenceRecorder;
23 
24 /**
25  * Definition of a object reference holding an image sequence recorder.
26  * @see SmartObjectRef, ImageSequenceRecorder.
27  * @ingroup media
28  */
30 
31 /**
32  * This class implements an image sequence recorder.
33  * @ingroup media
34  */
35 class OCEAN_MEDIA_EXPORT ImageSequenceRecorder :
36  public FileRecorder,
37  public FrameRecorder
38 {
39  public:
40 
41  /**
42  * Definition of individual recorder modes.
43  */
45  {
46  /// Invalid recorder mode.
48  /// Immediate mode for immediate image saving.
50  /// Parallel mode for image saving in parallel
52  /// Explicit mode for image saving due to an explicit invocation.
53  RM_EXPLICIT
54  };
55 
56  public:
57 
58  /**
59  * Returns the mode of this recorder.
60  * The default is RM_IMMEDIATE.
61  * @return Current recorder mode
62  * @see setMode().
63  */
64  virtual RecorderMode mode() const;
65 
66  /**
67  * Returns the stat index with which the filename of the first frame starts.
68  * @return The start index of the first frame, the default is 0u
69  * @see setStartIndex().
70  */
71  virtual unsigned int startIndex() const;
72 
73  /**
74  * Returns the number of currently buffered images.
75  * @return Number of images
76  */
77  virtual unsigned int pendingImages() const = 0;
78 
79  /**
80  * Sets the mode of this recorder.
81  * @param mode Mode to be set
82  * @return True, if succeeded
83  * @see mode().
84  */
85  virtual bool setMode(const RecorderMode mode);
86 
87  /**
88  * Sets the start index with which the filename of the first frame will start.
89  * @param index Start index
90  * @return True, if succeeded
91  * @see startIndex().
92  */
93  virtual bool setStartIndex(const unsigned int index);
94 
95  /**
96  * Adds a given frame explicity.
97  * @param frame The frame to be added
98  * @return True, if succeeded
99  */
100  virtual bool addImage(const Frame& frame);
101 
102  /**
103  * Explicitly invokes the image saving if the recorder is in RM_EXPLICIT mode.
104  * This function returns if all images have been saved.
105  * @return True, if all images could be saved successfully
106  */
107  virtual bool forceSaving() = 0;
108 
109  protected:
110 
111  /**
112  * Creates a new image sequence recorder.
113  */
115 
116  /**
117  * Destructs an image sequence recorder.
118  */
120 
121  protected:
122 
123  /// Mode of this image sequence recorder.
125 
126  /// Start index of the first frame.
127  unsigned int recorderStartIndex;
128 };
129 
130 }
131 
132 }
133 
134 #endif // META_OCEAN_MEDIA_IMAGE_SQUENCE_RECORDER_H
This class implements Ocean's image class.
Definition: Frame.h:1792
This class is the base class for all file recorders.
Definition: FileRecorder.h:37
This class is the base class for all frame recorders.
Definition: FrameRecorder.h:38
This class implements an image sequence recorder.
Definition: ImageSequenceRecorder.h:38
~ImageSequenceRecorder() override
Destructs an image sequence recorder.
virtual RecorderMode mode() const
Returns the mode of this recorder.
unsigned int recorderStartIndex
Start index of the first frame.
Definition: ImageSequenceRecorder.h:127
virtual bool setStartIndex(const unsigned int index)
Sets the start index with which the filename of the first frame will start.
virtual bool forceSaving()=0
Explicitly invokes the image saving if the recorder is in RM_EXPLICIT mode.
virtual bool setMode(const RecorderMode mode)
Sets the mode of this recorder.
RecorderMode
Definition of individual recorder modes.
Definition: ImageSequenceRecorder.h:45
@ RM_IMMEDIATE
Immediate mode for immediate image saving.
Definition: ImageSequenceRecorder.h:49
@ RM_INVALID
Invalid recorder mode.
Definition: ImageSequenceRecorder.h:47
@ RM_PARALLEL
Parallel mode for image saving in parallel.
Definition: ImageSequenceRecorder.h:51
virtual bool addImage(const Frame &frame)
Adds a given frame explicity.
virtual unsigned int startIndex() const
Returns the stat index with which the filename of the first frame starts.
RecorderMode recorderMode
Mode of this image sequence recorder.
Definition: ImageSequenceRecorder.h:124
ImageSequenceRecorder()
Creates a new image sequence recorder.
virtual unsigned int pendingImages() const =0
Returns the number of currently buffered images.
This template class implements a smart object reference which is a specialization of an ObjectRef obj...
Definition: SmartObjectRef.h:90
Ocean::SmartObjectRef< ImageSequenceRecorder, Recorder > ImageSequenceRecorderRef
Definition of a object reference holding an image sequence recorder.
Definition: ImageSequenceRecorder.h:22
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15