LibMultiSense
LibMultiSense Documentation
Loading...
Searching...
No Matches
multisense::MultiChannelSynchronizer Class Reference

Helper class which provides a interface to synchronize data across multiple channels. More...

#include <MultiSenseMultiChannel.hh>

Public Member Functions

 MultiChannelSynchronizer (std::vector< std::unique_ptr< Channel > > channels, const std::chrono::nanoseconds &tolerance, size_t max_queue_size=0)
 Construct a synchronizer owning the underlying channels.
 
 MultiChannelSynchronizer (std::vector< Channel * > channels, const std::chrono::nanoseconds &tolerance, size_t max_queue_size=0)
 Construct a synchronizer without owning the underlying channels.
 
 ~MultiChannelSynchronizer ()=default
 
Channelchannel (size_t index)
 Access a channel by index.
 
std::optional< std::vector< ImageFrame > > get_synchronized_frame ()
 Get a collection synchronized frames from the input channels with no timeout on waiting.
 
std::optional< std::vector< ImageFrame > > get_synchronized_frame (const std::optional< std::chrono::nanoseconds > &timeout)
 Get a collection synchronized frames from the input channels and return if we have not recieved a collection of frames before the input timeout.
 

Private Member Functions

void add_user_callbacks ()
 Helper to add user callbacks to the input channels.
 

Private Attributes

std::vector< Channel * > m_channels {}
 The collection of channels raw channels to synchronize.
 
std::vector< std::unique_ptr< Channel > > m_owned_channels {}
 A collection of owned channels if the user would like the synchronizer to own the channel memory.
 
std::vector< ImageFramem_active_frames {}
 A collection of active frames which may be dispatched to the user.
 
std::chrono::nanoseconds m_tolerance {}
 The max time tolerance between image frames for them to be considered equal.
 
size_t m_max_queue_size = 0
 Maximum number of synchronized frame groups that will be queued (0 = unlimited)
 
std::mutex m_frame_mutex
 Mutex to notify the user a collection of synchronized frames is ready.
 
std::condition_variable m_frame_cv
 Condition variable to notify the user a collection of synchronized frames is ready.
 
std::deque< std::vector< ImageFrame > > m_ready_frames {}
 Queue of synchronized frames ready for the user to consume.
 

Detailed Description

Helper class which provides a interface to synchronize data across multiple channels.

Definition at line 60 of file MultiSenseMultiChannel.hh.

Constructor & Destructor Documentation

◆ MultiChannelSynchronizer() [1/2]

multisense::MultiChannelSynchronizer::MultiChannelSynchronizer ( std::vector< std::unique_ptr< Channel > >  channels,
const std::chrono::nanoseconds &  tolerance,
size_t  max_queue_size = 0 
)
inlineexplicit

Construct a synchronizer owning the underlying channels.

Parameters
channelsThe channels to synchronize
toleranceThe max time difference for a set of images to be considered synchronized
max_queue_sizeThe max number of synchronized frames to have queued for dispatch

Definition at line 70 of file MultiSenseMultiChannel.hh.

◆ MultiChannelSynchronizer() [2/2]

multisense::MultiChannelSynchronizer::MultiChannelSynchronizer ( std::vector< Channel * >  channels,
const std::chrono::nanoseconds &  tolerance,
size_t  max_queue_size = 0 
)
inlineexplicit

Construct a synchronizer without owning the underlying channels.

Parameters
channelsThe channels to synchronize
toleranceThe max time difference for a set of images to be considered synchronized
max_queue_sizeThe max number of synchronized frames to have queued for dispatch

Definition at line 100 of file MultiSenseMultiChannel.hh.

◆ ~MultiChannelSynchronizer()

multisense::MultiChannelSynchronizer::~MultiChannelSynchronizer ( )
default

Member Function Documentation

◆ add_user_callbacks()

void multisense::MultiChannelSynchronizer::add_user_callbacks ( )
private

Helper to add user callbacks to the input channels.

◆ channel()

Channel & multisense::MultiChannelSynchronizer::channel ( size_t  index)
inline

Access a channel by index.

Definition at line 116 of file MultiSenseMultiChannel.hh.

◆ get_synchronized_frame() [1/2]

std::optional< std::vector< ImageFrame > > multisense::MultiChannelSynchronizer::get_synchronized_frame ( )
inline

Get a collection synchronized frames from the input channels with no timeout on waiting.

Returns
Return a collection of synchronized frames

Definition at line 131 of file MultiSenseMultiChannel.hh.

◆ get_synchronized_frame() [2/2]

std::optional< std::vector< ImageFrame > > multisense::MultiChannelSynchronizer::get_synchronized_frame ( const std::optional< std::chrono::nanoseconds > &  timeout)

Get a collection synchronized frames from the input channels and return if we have not recieved a collection of frames before the input timeout.

Parameters
timeoutThe ammount of time to wait for a synchronized frame
Returns
Return a collection of synchronized frames

Member Data Documentation

◆ m_active_frames

std::vector<ImageFrame> multisense::MultiChannelSynchronizer::m_active_frames {}
private

A collection of active frames which may be dispatched to the user.

Definition at line 165 of file MultiSenseMultiChannel.hh.

◆ m_channels

std::vector<Channel*> multisense::MultiChannelSynchronizer::m_channels {}
private

The collection of channels raw channels to synchronize.

Definition at line 155 of file MultiSenseMultiChannel.hh.

◆ m_frame_cv

std::condition_variable multisense::MultiChannelSynchronizer::m_frame_cv
private

Condition variable to notify the user a collection of synchronized frames is ready.

Definition at line 185 of file MultiSenseMultiChannel.hh.

◆ m_frame_mutex

std::mutex multisense::MultiChannelSynchronizer::m_frame_mutex
private

Mutex to notify the user a collection of synchronized frames is ready.

Definition at line 180 of file MultiSenseMultiChannel.hh.

◆ m_max_queue_size

size_t multisense::MultiChannelSynchronizer::m_max_queue_size = 0
private

Maximum number of synchronized frame groups that will be queued (0 = unlimited)

Definition at line 175 of file MultiSenseMultiChannel.hh.

◆ m_owned_channels

std::vector<std::unique_ptr<Channel> > multisense::MultiChannelSynchronizer::m_owned_channels {}
private

A collection of owned channels if the user would like the synchronizer to own the channel memory.

Definition at line 160 of file MultiSenseMultiChannel.hh.

◆ m_ready_frames

std::deque<std::vector<ImageFrame> > multisense::MultiChannelSynchronizer::m_ready_frames {}
private

Queue of synchronized frames ready for the user to consume.

Definition at line 190 of file MultiSenseMultiChannel.hh.

◆ m_tolerance

std::chrono::nanoseconds multisense::MultiChannelSynchronizer::m_tolerance {}
private

The max time tolerance between image frames for them to be considered equal.

Definition at line 170 of file MultiSenseMultiChannel.hh.


The documentation for this class was generated from the following file: