SDK Core Pipeline

For a basic usage guide, refer to Building Pipeline.

template<typename Algorithm, typename OutputEventType = EventCD, typename InputEventType = EventCD>
class Metavision::AlgorithmStage : public Metavision::BaseStage

Stage that wraps an algorithm in the consuming callback.

The easiest way to use this stage is to use Pipeline::add_algorithm_stage, rather than trying to instantiate it yourself.

Be mindful of the order of the template arguments, the output event type is given first, because most of the time the InputEventType is EventCD, while the OutputEventType varies.

Template Parameters
  • Algorithm – the type of wrapped algorithm

  • OutputEventType – optionally, the type of event produced by this stage in produce

  • InputEventType – optionally, the type of event consumed by this stage in the consuming callback

Public Functions

inline AlgorithmStage(std::unique_ptr<Algorithm> &&algo)

Constructor.

Parameters

algo – The wrapped algorithm for which process will be called

template<typename TOutputEventType = OutputEventType, typename TInputEventType = InputEventType>
inline AlgorithmStage(std::unique_ptr<Algorithm> &&algo, bool enabled = true)

Constructor.

Overload constructor available when the type of event consumed is the same as the type of events produced.

See also

enable, disable, set_enabled.

inline AlgorithmStage(std::unique_ptr<Algorithm> &&algo, BaseStage &prev_stage)

Constructor.

Overload constructor that simplifies setting the previous stage.

Parameters
  • algo – The wrapped algorithm for which process will be called

  • prev_stage – The previous stage of this stage

template<typename TOutputEventType = OutputEventType, typename TInputEventType = InputEventType>
inline AlgorithmStage(std::unique_ptr<Algorithm> &&algo, BaseStage &prev_stage, bool enabled = true)

Constructor.

Overload constructor that simplifies setting the previous stage and is only available when the type of event consumed is the same as the type of events produced.

See also

enable, disable, set_enabled.

Parameters
  • algo – The wrapped algorithm for which process will be called

  • prev_stage – The previous stage of this stage

  • enabled – true if the algorithm is enabled by default, false otherwise

inline Algorithm &algo()

Returns the wrapped algorithm.

Returns

Algorithm & the wrapped algorithm

inline const Algorithm &algo() const

Returns the wrapped algorithm.

Returns

Algorithm & the wrapped algorithm

template<typename TOutputEventType = OutputEventType, typename TInputEventType = InputEventType>
inline void enable()

Enables calling the process function of the algorithm in the consuming callback.

When the algorithm is enabled, the (default) consuming callback calls process on the consumed data and produces as output, the output of the algorithm. When the algorithm is disabled, this stage acts as a passthrough and directly produces the consumed data. Therefore, to avoid mistakes, this function is only available if the type of output event (produced) is the same as the type of input events (consumed).

template<typename TOutputEventType = OutputEventType, typename TInputEventType = InputEventType>
inline void disable()

Disables calling the process function of the algorithm in the consuming callback.

When the algorithm is enabled, the (default) consuming callback calls process on the consumed data and produces as output, the output of the algorithm. When the algorithm is disabled, this stage acts as a passthrough and directly produces the consumed data. Therefore, to avoid mistakes, this function is only available if the type of output event (produced) is the same as the type of input events (consumed).

template<typename TOutputEventType = OutputEventType, typename TInputEventType = InputEventType>
inline void set_enabled(bool enabled)

Enable/disables calling the process function of the algorithm in the consuming callback.

This does the same as calling enable or disable according to the value of enabled.

Parameters

enabled – True if the algorithm should be enabled, false otherwise

template<typename TOutputEventType = OutputEventType, typename TInputEventType = InputEventType>
inline bool is_enabled() const

Returns the status of the wrapped algorithm.

Returns

true if the algorithm is enabled, false otherwise

class Metavision::BaseStage

Base class for all stages added in the pipeline.

A stage can produce and/or consume data. When data are produced by a stage, they are forwarded to the next stages, so that they can consume these data and also produce some data on their own.

The consumption of data is handled by the consuming callback which, by default, does nothing with the data. You can customize this behavior by calling set_consuming_callback function.

The production of data is triggered by calling produce, which will call the consuming callback of the next stages. The notion of previous/next stage is defined by either passing the previous stage in the constructor or by calling set_previous_stage. It can also be expressed by customizing the consuming callback of a previous stage by calling set_consuming_callback.

Note that when data are produced, each producing callback is not executed synchronously. Instead, the callback execution is scheduled to run either on the main thread (by default) or on its own (dedicated) processing thread. In any case, the callbacks of a stage are never called concurrently : the callbacks will be either run synchronously in the main thread, or synchronously in a dedicated processing thread detach. This holds true for all consuming callbacks of a stage.

Subclassed by Metavision::AlgorithmStage< Algorithm, OutputEventType, InputEventType >, Metavision::FrameCompositionStage, Metavision::FrameGenerationStage, Metavision::Stage, Metavision::StreamLoggingStage< EventType >, Metavision::VideoWritingStage

Public Types

enum class Status

Enum class representing the status of a stage.

Values:

enumerator Inactive

if the stage has not yet been started

enumerator Started

if the stage is started

enumerator Completed

if the stage has completed its work

enumerator Cancelled

if the stage has been cancelled

enum class NotificationType

Enum class representing the type of a notification sent from a stage.

Values:

enumerator Status

change of status

using EventBuffer = std::vector<EventCD>

Convenience alias for a typical buffer of events.

using EventBufferPool = SharedObjectPool<EventBuffer>

Convenience alias for a pool of buffer of events.

using EventBufferPtr = EventBufferPool::ptr_type

Convenience alias for a pointer to a buffer of events allocated in a pool.

Public Functions

inline virtual ~BaseStage()

Destructor.

inline void set_previous_stage(BaseStage &prev_stage)

Sets the previous stage of this stage.

When called, this will setup each stage of the prev_stage to call the default consuming callback of this stage when data is produced. If you need to customize the consuming callback that should be called for a previous stage, you should use set_consuming_callback instead.

Parameters

prev_stage – the previous stage of this stage

inline const std::unordered_set<BaseStage*> &previous_stages() const

Gets the previous stages of this stage.

Warning

The reference to the set of previous stages can be invalidated by subsequent calls to set_previous_stage or set_consuming_callback. The returned value won’t change once the associated pipeline is started.

Returns

The previous stages

inline const std::unordered_set<BaseStage*> &next_stages() const

Gets the next stages of this stage.

Warning

The reference to the set of next stages can be invalidated by subsequent calls to set_previous_stage or set_consuming_callback. The returned value won’t change once the associated pipeline is started.

Returns

The next stages

inline Status status() const

Returns the status of the stage.

Returns

Status the status of the stage

inline void set_receiving_callback(const std::function<void(BaseStage&, const NotificationType&, const boost::any&)> &cb)

Sets the (generic) receiving callback for any previous stages.

Whenever a stage wants to notify other stages of changes (e.g. status update, etc), it can do so by calling notify. When a notification is emitted at a stage, the receiving callback for each of the following stages is scheduled to be run with the corresponding type and data. This function sets the callback that will be scheduled when a notification is emitted by any previous stage.

Parameters

cb – The callback that will be called when a notification is emitted from one of the previous stages

inline void set_receiving_callback(const std::function<void(const NotificationType&, const boost::any&)> &cb)

Sets the (generic) receiving callback for any previous stages.

Convenience overload to be used when the receiving callback does not need to receive the emitting stage as an argument.

See also

set_receiving_callback(const std::function<void(BaseStage &, const NotificationType &, const boost::any &)> &cb)

Parameters

cb – The callback that will be called when a notification is emitted from one of the previous stages

inline void set_receiving_callback(BaseStage &prev_stage, const std::function<void(const NotificationType&, const boost::any&)> &cb)

Sets the (specific) receiving callback for a previous stage.

When a notification is emitted at a stage, the receiving callback for each of the following stages is scheduled to be run with the corresponding type and data. This function sets the callback that will be scheduled when a notification is emitted by a specific prev_stage.

According to the stage that produced the data, the generic consuming callback will be called if no specific consuming callback has been set. According to the stage that emitted the notification, the generic receiving callback will be called if no specific receiving callback has been set.

See also

set_receiving_callback(const std::function<void(BaseStage &, const NotificationType &, const boost::any &)> &cb)

Parameters
  • prev_stage – the previous stage for which the cb is set

  • cb – The callback that will be called when a notification is sent from one of the previous stages

inline void set_starting_callback(const std::function<void()> &cb)

Sets the starting callback.

The starting callback is called the first time Pipeline::run or Pipeline::step is called. This callback should set up a stage so that it can produce and/or consume data : for example, it can start a producing thread or configure an algorithm with parameters that were not known during construction.

Warning

This callback must not block, it can however create a thread to schedule some work to be done during the time the pipeline is run.

Parameters

cb – The callback that will be called when this stage is started by the pipeline via Pipeline::run or Pipeline::step

inline void set_stopping_callback(const std::function<void()> &cb)

Sets the stopping callback.

Parameters

cb – The callback that will be called when this stage is being stopped either because the previous stages have completed or when the pipeline is cancelled via Pipeline::cancel

inline void set_setup_callback(const std::function<void()> &cb)

Sets the setup callback.

The setup callback is called just after a valid reference to the pipeline has been set to the stage. The setup callback allows the stage to setup everything needing a valid reference to the pipeline (e.g. setting pre and post step callbacks).

Parameters

cb – The callback that will be called when this stage has been set a valid reference to the pipeline

inline void set_consuming_callback(const std::function<void(BaseStage&, const boost::any&)> &cb)

Sets the (generic) consuming callback for any previous stage.

When data is produced at a stage, the consuming callback for each of the following steps is scheduled to be run with the produced data. This function sets the callback that will be scheduled when data is produced by any previous stage.

The role of a consuming callback is, often, to produce data for next stages to consume. If you don’t set a consuming callback, the data produced by a previous stage will not be used and, in particular, no data will be produced for following stages to consume. Therefore, for a stage to be useful, one of the set_consuming_callback function must be called.

Parameters

cb – The callback that will be called by the producing callback of a previous stage

inline void set_consuming_callback(const std::function<void(const boost::any&)> &cb)

Sets the (generic) consuming callback for any previous stage.

Convenience overload to be used when the receiving callback does not need to receive the emitting stage as an argument.

Parameters

cb – The callback that will be called by the producing callback of a previous stage

inline void set_consuming_callback(BaseStage &prev_stage, const std::function<void(boost::any)> &cb)

Sets the (specific) consuming callback for a previous stage.

When data is produced at a stage, the consuming callback for each of the following steps is scheduled to be run with the produced data. This function sets the callback that will be scheduled when data is produced by a specific prev_stage.

According to the stage that produced the data, the generic consuming callback will be called if no specific consuming callback has been set.

Parameters
  • prev_stage – the previous stage for which the cb is set

  • cb – The callback to be called when data is produced by produce

inline bool detach()

Detaches this thread and schedules the execution of any callback on its own dedicated processing thread of the pipeline.

When detach is called, the stage will now schedules the execution of any callback (the default or custom consuming callback set for this stage on any previous stages) on its own dedicated processing thread. A stage can be detached or undetached as long as the pipeline has not been started.

Returns

true if stage has been detached (if it schedules the execution of callbacks on its own processing thread) and false otherwise

inline bool is_detached() const

Gets the detached status of this stage.

Returns

true if stage is detached (if it schedules the execution of callbacks on its own processing thread) and false if stage schedules the execution of its callback on the main thread

inline Pipeline &pipeline()

Returns the associated pipeline Throws std::runtime_error if no pipeline has been set yet.

Warning

The function throws if no pipeline has been associated (i.e. if the stage was not created by the pipeline nor added to it).

Returns

Pipeline& the pipeline that owns this stage

inline const Pipeline &pipeline() const

Returns the associated pipeline Throws std::runtime_error if no pipeline has been set yet.

Warning

The function throws if no pipeline has been associated (i.e. if the stage was not created by the pipeline nor added to it).

Returns

Pipeline& the pipeline that owns this stage

Protected Functions

inline BaseStage(bool detachable = true)

Constructor.

Parameters

detachable – If this stage can be detached (i.e. can run on its own thread)

inline BaseStage(BaseStage &prev_stage, bool detachable = true)

Constructor.

The prev_stage is used to setup the consuming callback that will be called when the previous stage produces data. When the previous stage produces data, it will call the consuming callback (set_consuming_callback) of this stage. This behavior is automatically handled by this constructor. If you need to customize the consuming callback of one (or all) of the previous stages, you should use set_consuming_callback instead.

Parameters
  • prev_stage – the stage that is executed before the created one

  • detachable – If this stage can be detached (i.e. can run on its own thread)

inline void notify(const NotificationType &type, const boost::any &data)

Notifies next stages of a change.

This schedules the execution of all the receiving callbacks

Parameters
  • type – The notification type

  • data – The associated notification data

inline void produce(const boost::any &data)

Produces data.

This schedules the execution of all the producing callbacks

Parameters

data – The produced data

inline void complete()

Sets the stage status and notify next stages when it is done.

This function should be called whenever the stage will never produce any more data A stage is done when it has the status Status::Completed or

Status::Cancelled and it has finished scheduling tasks to be processed by following stages.

class Metavision::FrameCompositionStage : public Metavision::BaseStage

Class for composing a frame out of multiple frames.

It connects stages together to display side by side their image streams at a fixed refresh rate. Each sub-frame coming from the input stages is rendered to its specified coordinates in the composed output frame.

The FPS given by the user determines at which frequency the full image must be updated (in the data’s clock, not in the system’s one). However, input stages are not necessarily synchronous and might have different output frequencies. This class acts like a synchronizer and displays at each multiple of dt = 1/FPS only the most recent sub-image for each input stage.

Nullptrs images can be used as temporal markers, so that input stages can let the class know there are no available data to display for this input at time ts. In that case, the corresponding part in the whole image won’t be updated.

Public Functions

void add_previous_frame_stage(BaseStage &prev_frame_stage, int x, int y, int width, int height, bool enable_crop = false, const FrameComposer::GrayToColorOptions &gray_to_color_options = FrameComposer::GrayToColorOptions())

Sets up the frame composer to put the frame produced by prev_frame_stage at the given location.

Parameters
  • prev_frame_stage – Stage producing the frames

  • x – X-position of the top-left corner of the image in the composition

  • y – Y-position of the top-left corner of the image in the composition

  • width – Width of the (possibly scaled) frame inside the composed frame

  • height – Height of the (possibly scaled) frame inside the composed frame

  • enable_crop – Whether to enable cropping the image to the specified width and height (maintains the center)

  • gray_to_color_options – Options used to rescale and/or apply a colormap on the grayscale image

FrameComposer &frame_composer()

Gets the underlying frame composer algorithm.

Returns

FrameComposer & the frame composer algorithm

class Metavision::FrameGenerationStage : public Metavision::BaseStage

Stage that generates an OpenCV frame out of EventCD events.

Public Functions

inline FrameGenerationStage(int width, int height, uint32_t accumulation_time_ms = 10, double fps = 0., const Metavision::ColorPalette &palette = BaseFrameGenerationAlgorithm::default_palette())

Constructor.

Note

If the fps is zero, accumulation_time_ms will be used instead as reference time to generate frames

Parameters
  • width – Width of the frame.

  • height – Height of the frame.

  • accumulation_time_ms – Accumulation time (in ms)

  • fps – The fps at which to generate the frames. The time reference used is the one from the input events

  • palette – The Prophesee’s color palette to use

inline FrameGenerationStage(BaseStage &prev_stage, int width, int height, int fps)

Constructor.

Parameters
  • prev_stage – Previous stage.

  • width – Width of the frame.

  • height – Height of the frame.

  • fps – Target of frames to generate per second.

class Metavision::Pipeline

Class that represents a pipeline of processing units (stages) and controls their execution.

Public Types

enum class Status

Enum class representing the status of the pipeline.

Values:

enumerator Inactive

if the stage has not yet been started

enumerator Started

if the pipeline has been started

enumerator Cancelled

if the pipeline has been cancelled with cancel

enumerator Completed

if the pipeline has finished running

using StepCallback = std::function<void()>

A Callback called before of after the pipeline steps.

Warning

a StepCallback is not allowed to add another step callback otherwise the pipeline will deadlock

Public Functions

inline Pipeline(bool auto_detach = false)

Constructor.

Parameters

auto_detach – If true, each stage added to the pipeline will automatically be detached (BaseStage::detach)

inline ~Pipeline()

Destructor.

The destructor ensures that the pipeline is stopped by calling cancel

template<typename Stage>
Stage &add_stage(std::unique_ptr<Stage> &&stage)

Adds a stage to the pipeline.

Note

The ownership of the stage is transferred to the pipeline. If you need to further interact with this stage, use the returned reference to the stage.

Parameters

stage – Stage to add

Returns

Stage& The added stage

template<typename Stage>
Stage &add_stage(std::unique_ptr<Stage> &&stage, BaseStage &prev_stage)

Adds a stage to the pipeline.

Convenience overload

This function does the same as the more verbose equivalent : pipeline.add_stage(stage); stage->set_previous_stage(prev_stage);

Parameters
  • stage – Stage to add

  • prev_stage – Previous stage

Returns

Stage& The added stage

template<typename OutputEventType = EventCD, typename InputEventType = EventCD, typename Algorithm>
AlgorithmStage<Algorithm, OutputEventType, InputEventType> &add_algorithm_stage(std::unique_ptr<Algorithm> &&algo)

Adds a stage that wraps an algorithm as the consuming callback to the pipeline.

Convenience overload

This function creates an instance of AlgorithmStage and adds it to the pipeline.

Warning

Be mindful of the order of the template arguments: the output event type is given first, because most of the time the InputEventType is EventCD, while the OutputEventType varies.

Template Parameters
  • OutputEventType – Type of events produced by this stage, defaults to EventCD

  • InputEventType – Type of events consumed by this stage, defaults to EventCD

  • Algorithm – Type of algorithm wrapped in this stage, its type is inferred from the arguments

Parameters

algo – Wrapped algorithm

Returns

AlgorithmStage& the created stage

template<typename OutputEventType = EventCD, typename InputEventType = EventCD, typename Algorithm>
AlgorithmStage<Algorithm, OutputEventType, InputEventType> &add_algorithm_stage(std::unique_ptr<Algorithm> &&algo, bool enabled = true)

Adds a stage that wraps an algorithm as the consuming callback to the pipeline.

Convenience overload only available if InputEventType == OutputEventType.

This function creates an instance of AlgorithmStage and adds it to the pipeline.

Warning

Be mindful of the order of the template arguments: the output event type is given first, because most of the time the InputEventType is EventCD, while the OutputEventType varies.

Template Parameters
  • OutputEventType – Type of events produced by this stage, defaults to EventCD

  • InputEventType – Type of events consumed by this stage, defaults to EventCD

  • Algorithm – Type of algorithm wrapped in this stage, its type is inferred from the arguments

Parameters
  • algo – Wrapped algorithm

  • enabled – If the stage is enabled by default

Returns

AlgorithmStage& the created stage

template<typename OutputEventType = EventCD, typename InputEventType = EventCD, typename Algorithm>
AlgorithmStage<Algorithm, OutputEventType, InputEventType> &add_algorithm_stage(std::unique_ptr<Algorithm> &&algo, BaseStage &prev_stage)

Adds a stage that wraps an algorithm as the consuming callback to the pipeline.

Convenience overload that also allows setting the previous stage.

This function creates an instance of AlgorithmStage and adds it to the pipeline.

Warning

Be mindful of the order of the template arguments: the output event type is given first, because most of the time the InputEventType is EventCD, while the OutputEventType varies.

Template Parameters
  • OutputEventType – Type of events produced by this stage, defaults to EventCD

  • InputEventType – Type of events consumed by this stage, defaults to EventCD

  • Algorithm – Type of algorithm wrapped in this stage, its type is inferred from the arguments

Parameters
  • algo – Wrapped algorithm

  • prev_stage – Previous stage of this stage

Returns

AlgorithmStage& the created stage

template<typename OutputEventType = EventCD, typename InputEventType = EventCD, typename Algorithm>
AlgorithmStage<Algorithm, OutputEventType, InputEventType> &add_algorithm_stage(std::unique_ptr<Algorithm> &&algo, BaseStage &prev_stage, bool enabled = true)

Adds a stage that wraps an algorithm as the consuming callback to the pipeline.

Convenience overload that also allows setting the previous stage and is only available if InputEventType == OutputEventType.

This function creates an instance of AlgorithmStage and adds it to the pipeline.

Warning

Be mindful of the order of the template arguments: the output event type is given first, because most of the time the InputEventType is EventCD, while the OutputEventType varies.

Template Parameters
  • OutputEventType – Type of events produced by this stage, defaults to EventCD

  • InputEventType – Type of events consumed by this stage, defaults to EventCD

  • Algorithm – Type of algorithm wrapped in this stage, its type is inferred from the arguments

Parameters
  • algo – Wrapped algorithm

  • prev_stage – Previous stage of this stage

  • enabled – If the stage is enabled by default, ignored if InputEventType != OutputEventType

Returns

AlgorithmStage& the created stage

inline void remove_stage(BaseStage &stage)

Removes a stage from the pipeline.

This has no effect if the stage was not already added to the pipeline.

Note

This function will also remove the stage from the list of previous and next stages of any other stage in the pipeline. In particular, this means that proper care must be taken by the caller to make sure the consuming callbacks of the stages affected by this removal are connected to another stage in the pipeline with e.g BaseStage::set_previous_stage or BaseStage::set_consuming_callback before the pipeline is started, as in the following example :

Pipeline p;
auto& s1 = p.add_stage(std::make_unique<Stage>());
auto& s2 = p.add_stage(std::make_unique<Stage>(), s1);
auto& s3 = p.add_stage(std::make_unique<Stage>(), s2);
p.remove_stage(s2);
s3.set_previous_stage(s1); // without this line, s3 will wait forever since its previous stage has been
                           // removed and will not produce any data

Parameters

stage – Stage to remove

inline size_t count() const

Returns the number of stages inside the pipeline.

Returns

size_t the number of stages inside the pipeline

inline bool empty() const

Checks if the pipeline does not contain any stage.

Returns

true if the pipeline is empty, false otherwise

inline Status status() const

Gets the status of the pipeline.

Returns

Status the status of the pipeline

inline bool step()

Executes a step of the pipeline.

This actually runs one of the scheduled callback on the main thread. The processing threads runs on their own, but can be blocked by the main thread if one stage needs to run on the main thread.

Returns

true if the step was successful, false if the pipeline has no remaining steps to run

inline void run()

Runs the pipeline.

This will block until the execution of all the stages callbacks have been executed. This can be halted by calling cancel.

This is functionally equivalent to the following loop on a Pipeline p : while (p.step()) {}

inline void cancel()

Cancels the pipeline execution.

This will prevent any stage from producing any more data and will cancel all scheduled callbacks, therefore immediately exiting the pipeline.

inline void add_pre_step_callback(const StepCallback &cb)

Adds a callback that will be called before the pipeline steps.

Warning

This method cannot be called from a step callback

Parameters

cb – The callback to call

inline void add_post_step_callback(const StepCallback &cb)

Adds a callback that will be called after the pipeline steps.

Warning

This method cannot be called from a step callback

Parameters

cb – The callback to call

class Metavision::Stage : public Metavision::BaseStage

Simple stage that can be customized.

This class can be used to create a stage instance to be customized via set_consuming_callback, set_starting_callback, set_stopping_callback etc. This can be an alternative to the creation of a new class inheriting BaseStage.

Public Functions

inline Stage(bool detachable = true)

Constructor.

Parameters

detachable – If this stage can be detached (i.e. can run on its own thread)

inline Stage(BaseStage &prev_stage, bool detachable = true)

Constructor.

The prev_stage is used to setup the consuming callback that will be called when the previous stage produces data. When the previous stage produces data, it will call the consuming callback (set_consuming_callback) of this stage. This behavior is automatically handled by this constructor. If you need to customize the consuming callback of one (or all) of the previous stages, you should use set_consuming_callback instead.

Parameters
  • prev_stage – the stage that is executed before the created one

  • detachable – If this stage can be detached (i.e. can run on its own thread)

template<typename EventType>
class Metavision::StreamLoggingStage : public Metavision::BaseStage

Stage that runs StreamLoggerAlgorithm.

Public Functions

inline StreamLoggingStage(const std::string &filename, int width, int height)

Constructor.

Parameters
  • filename – Name of the output file

  • width – Width of the frame

  • height – Height of the frame

inline StreamLoggingStage(BaseStage &prev_stage, const std::string &filename, int width, int height)

Constructor.

Parameters
  • prev_stage – Previous Stage

  • filename – Name of the output file

  • width – Width of the frame

  • height – Height of the frame

inline StreamLoggerAlgorithm &algo()

Gets algo.

Returns

Algorithm class associated to this stage

class Metavision::VideoWritingStage : public Metavision::BaseStage

Stage that writes the input frames to a video file.

Public Functions

inline VideoWritingStage(const std::string &filename, int width, int height, int fps, const std::string &codec = "MJPG", bool colored = true)

Constructor.

Parameters
  • filename – Name of the output file.

  • width – Width of the frame.

  • height – Height of the frame.

  • fps – Frames per second of the output video.

  • codec – Codec used by OpenCV to encode the video.

  • colored – If true the incoming frames are expected to be color frames, otherwise grayscale.

inline VideoWritingStage(BaseStage &prev_stage, const std::string &filename, int width, int height, int fps, const std::string &codec = "MJPG", bool colored = true)

Constructor.

Parameters
  • prev_stage – Previous stage.

  • filename – Name of the output file.

  • width – Width of the frame.

  • height – Height of the frame.

  • fps – Frames per second of the output video.

  • codec – Codec used by OpenCV to encode the video.

  • colored – If true the incoming frames are expected to be color frames, otherwise grayscale.

inline ~VideoWritingStage()

Destructor.