SDK Core Pipeline

For a basic usage guide, refer to 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

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>
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

enable, disable, set_enabled.

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>
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

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

Algorithm &algo()

Returns the wrapped algorithm.

Return

Algorithm & the wrapped algorithm

const Algorithm &algo() const

Returns the wrapped algorithm.

Return

Algorithm & the wrapped algorithm

template<typename TOutputEventType = OutputEventType, typename TInputEventType = InputEventType>
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>
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>
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>
bool is_enabled() const

Returns the status of the wrapped algorithm.

Return

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::FrameDisplayStage, Metavision::FrameGenerationStage, Metavision::Stage, Metavision::StreamLoggingStage< EventType >, Metavision::VideoWritingStage

Public Types

enum 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 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 = BoundedSharedObjectPool<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

~BaseStage()

Destructor.

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

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

Gets the previous stages of this stage.

Return

The previous stages

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.

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

Gets the next stages of this stage.

Return

The next stages

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.

Status status() const

Returns the status of the stage.

Return

Status the status of the stage

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

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

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

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

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

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

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

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

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.

See

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

Parameters
  • cb: The callback that will be called by the producing callback of a previous stage

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.

See

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

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

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

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.

Return

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

Return

false otherwise

bool is_detached() const

Gets the detached status of this stage.

Return

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

Return

false if stage schedules the execution of its callback on the main thread

Pipeline &pipeline()

Returns the associated pipeline.

Throws a std::runtime_error if no pipeline has been set yet.

Return

Pipeline& the pipeline that owns this stage

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).

const Pipeline &pipeline() const

Returns the associated pipeline.

Throws a std::runtime_error if no pipeline has been set yet.

Return

Pipeline& the pipeline that owns this stage

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).

Protected Functions

BaseStage(bool detachable = true)

Constructor.

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

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)

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

void produce(const boost::any &data)

Produces data.

This schedules the execution of all the producing callbacks

Parameters
  • data: The produced data

void complete()

Sets the stage status and notify next stages of doneness.

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.

This is done without any copy, using the shared pointers to the images.

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.

Return

FrameComposer & the frame composer algorithm

class Metavision::FrameDisplayStage : public Metavision::BaseStage

Stage that displays the input frame in an OpenCV window.

Public Functions

FrameDisplayStage(const std::string &title, int wait_delay_ms = 1, bool auto_exit_on_quit_key = true, int down_scaling_factor = 1)

Constructor.

Parameters
  • title: Title of the window.

  • wait_delay_ms: Minimum amount of time that should pass between a frame and the next, in milliseconds.

  • auto_exit_on_quit_key: Whether to cancel the pipeline when the q key is pressed in the window.

  • down_scaling_factor: Factor to apply for reducing the displayed image

FrameDisplayStage(BaseStage &prev_stage, const std::string &title, int wait_delay_ms = 1, bool auto_exit_on_quit_key = true, int down_scaling_factor = 1)

Constructor.

Parameters
  • prev_stage: Previous stage.

  • title: Title of the window.

  • wait_delay_ms: Minimum amount of time that should pass between a frame and the next, in milliseconds.

  • auto_exit_on_quit_key: Whether to cancel the pipeline when the q key is pressed in the window.

  • down_scaling_factor: Factor to apply for reducing the displayed image

void set_auto_exit_on_quit_key(bool auto_exit_on_quit_key)

Sets whether to cancel the pipeline when the q key is pressed in the window.

Parameters
  • auto_exit_on_quit_key: Whether to cancel the pipeline when the q key is pressed in the window.

bool auto_exit_on_quit_key() const

Returns true if the pipeline will be cancelled when the q key is pressed in the window.

Return

true if the pipeline will be cancelled when the q key is pressed in the window.

char get_last_key()

Gets the last key pressed on the window.

Return

Last key pressed on the window.

void set_on_key_pressed_cb(const OnKeyPressedCb &on_key_pressed_cb)

Sets the callback that is called when a key is pressed.

Parameters
  • on_key_pressed_cb: Function to call

class Metavision::FrameGenerationStage : public Metavision::BaseStage

Stage that generates an OpenCV frame out of EventCD events.

Public Functions

FrameGenerationStage(int width, int height, timestamp accumulation_time_ms = 10, bool colored = true, double fps = 0.)

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)

  • colored: Generates either colored or grayscale image

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

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 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

Public Functions

Pipeline(bool auto_detach = false)

Constructor.

Parameters
  • auto_detach: if true, each stage added to the pipeline will automatically be detached (BaseStage::detach)

~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.

Return

Stage& The added stage

Parameters
  • stage: Stage to add

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);

Return

Stage& The added stage

Parameters
  • stage: Stage to add

  • prev_stage: Previous 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.

Return

AlgorithmStage& the created stage

Template Parameters
  • OutputEventType: the type of events produced by this stage, defaults to EventCD

  • InputEventType: the type of events consumed by this stage, defaults to EventCD

  • Algorithm: the type of algorithm wrapped in this stage, it’s type is inferred from the arguments

Parameters
  • algo: The wrapped algorithm

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.

Return

AlgorithmStage& the created stage

Template Parameters
  • OutputEventType: the type of events produced by this stage, defaults to EventCD

  • InputEventType: the type of events consumed by this stage, defaults to EventCD

  • Algorithm: the type of algorithm wrapped in this stage, it’s type is inferred from the arguments

Parameters
  • algo: The wrapped algorithm

  • enabled: If the stage is enabled by default

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.

Return

AlgorithmStage& the created stage

Template Parameters
  • OutputEventType: the type of events produced by this stage, defaults to EventCD

  • InputEventType: the type of events consumed by this stage, defaults to EventCD

  • Algorithm: the type of algorithm wrapped in this stage, it’s type is inferred from the arguments

Parameters
  • algo: The wrapped algorithm

  • prev_stage: the previous stage of this 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.

Return

AlgorithmStage& the created stage

Template Parameters
  • OutputEventType: the type of events produced by this stage, defaults to EventCD

  • InputEventType: the type of events consumed by this stage, defaults to EventCD

  • Algorithm: the type of algorithm wrapped in this stage, it’s type is inferred from the arguments

Parameters
  • algo: The wrapped algorithm

  • prev_stage: the previous stage of this stage

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

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. The removed stage

size_t count() const

Returns the number of stages inside the pipeline.

Return

size_t the number of stages inside the pipeline

bool empty() const

Checks if the pipeline does not contain any stage.

Return

true if the pipeline is empty, false otherwise

Status status() const

Gets the status of the pipeline.

Return

Status the status of the pipeline

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.

Return

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

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()) {}

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.

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

Stage(bool detachable = true)

Constructor.

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

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

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

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

class Metavision::VideoWritingStage : public Metavision::BaseStage

Stage that writes the input frames to a video file.

Public Functions

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.

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.