OKVIS ROS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Private Member Functions | Private Attributes | List of all members
okvis::FrameSynchronizer Class Reference

This class combines multiple frames with the same or similar timestamp into one multiframe. More...

#include <FrameSynchronizer.hpp>

Public Member Functions

 FrameSynchronizer (okvis::VioParameters &parameters)
 Constructor. Calls init(). More...
 
virtual ~FrameSynchronizer ()
 Trivial destructor. More...
 
void init (okvis::VioParameters &parameters)
 Initialise the synchronizer with new parameters. Is called in the constructor. More...
 
std::shared_ptr
< okvis::MultiFrame
addNewFrame (std::shared_ptr< okvis::CameraMeasurement > &frame)
 Adds a new frame to the internal buffer and returns the Multiframe containing the frame. More...
 
bool detectionEndedForMultiFrame (uint64_t multiFrameId)
 Inform the synchronizer that a frame in the multiframe has completed keypoint detection and description. More...
 
bool detectionCompletedForAllCameras (uint64_t multiFrameId)
 This will return true if the internal counter on how many times detectionEndedForMultiFrame() has been called for this multiframe equals the number of cameras in the system. More...
 

Private Member Functions

bool findFrameByTime (const okvis::Time &timestamp, int &position) const
 Find a multiframe in the buffer that has a timestamp within the tolerances of the given one. The tolerance is given as a parameter in okvis::VioParameters::sensors_information::frameTimestampTolerance. More...
 
bool findFrameById (uint64_t mfId, int &position) const
 returns true if a frame with multiframe id mfId is found and sets position to its frame buffer position More...
 

Private Attributes

okvis::VioParameters parameters_
 Copy of the parameters and settings. More...
 
size_t numCameras_
 Number of cameras for easy access. More...
 
double timeTol_
 Timestamp tolerance to classify multiple frames as being part of the same multiframe. More...
 
std::vector< std::pair
< std::shared_ptr
< okvis::MultiFrame >, size_t > > 
frameBuffer_
 Circular buffer containing a multiframe pointer and a counter for how many times detection has completed. More...
 
int bufferPosition_
 Position of the newest multiframe in the buffer. More...
 
okvis::Time lastCompletedFrameTimestamp_
 Timestamp of the last multiframe that returned true in detectionCompletedForAllCameras(). More...
 
uint64_t lastCompletedFrameId_
 ID of the last multiframe that returned true in detectionCompletedForAllCameras(). More...
 

Detailed Description

This class combines multiple frames with the same or similar timestamp into one multiframe.

Warning
This class is not threadsafe. Make sure to lock it with a mutex if used in multiple threads!

Constructor & Destructor Documentation

okvis::FrameSynchronizer::FrameSynchronizer ( okvis::VioParameters parameters)

Constructor. Calls init().

Parameters
parametersParameters and settings.
okvis::FrameSynchronizer::~FrameSynchronizer ( )
virtual

Trivial destructor.

Member Function Documentation

std::shared_ptr< okvis::MultiFrame > okvis::FrameSynchronizer::addNewFrame ( std::shared_ptr< okvis::CameraMeasurement > &  frame)

Adds a new frame to the internal buffer and returns the Multiframe containing the frame.

Parameters
frameNew frame.
Returns
Multiframe with the added frame in it.
bool okvis::FrameSynchronizer::detectionCompletedForAllCameras ( uint64_t  multiFrameId)

This will return true if the internal counter on how many times detectionEndedForMultiFrame() has been called for this multiframe equals the number of cameras in the system.

Warning
There is no check on whether actually all frames inside the multiframe have their keypoints detected. The synchronizer trusts the user to only ever call detectionEndedForMultiFrame() once for each frame in the multiframe.
Parameters
multiFrameIdThe ID of the multiframe.
Returns
True if the detection has ended for all cameras. False if either the multiframe was not found in the buffer or if not all frames in the multiframe have been detected.
bool okvis::FrameSynchronizer::detectionEndedForMultiFrame ( uint64_t  multiFrameId)

Inform the synchronizer that a frame in the multiframe has completed keypoint detection and description.

Warning
This function does not check whether the multiframe contains newly detected keypoints and their descriptors. Therefore only call it when you are sure a frame has been processed for which you have not called this function before.
Parameters
multiFrameIdID of the multiframe that contains the frame with the newly detected keypoints.
Returns
True if the multiframe was found in the synchronizer. If it returns false this means that the multiframe probably is too old and already fell out of the internal buffer.
bool okvis::FrameSynchronizer::findFrameById ( uint64_t  mfId,
int &  position 
) const
private

returns true if a frame with multiframe id mfId is found and sets position to its frame buffer position

Find a multiframe in the buffer for a given multiframe ID.

Parameters
[in]mfIdLook for this ID in the buffer.
[out]positionPosition of the desired multiframe in the buffer. Check the return value to first find out whether the multiframe was found.
Returns
True if a multiframe with the given timestamp was found in the buffer.
bool okvis::FrameSynchronizer::findFrameByTime ( const okvis::Time timestamp,
int &  position 
) const
private

Find a multiframe in the buffer that has a timestamp within the tolerances of the given one. The tolerance is given as a parameter in okvis::VioParameters::sensors_information::frameTimestampTolerance.

Parameters
[in]timestampLook for this timestamp in the buffer.
[out]positionPosition of the found multiframe in the buffer. Check the return value first to find out whether the multiframe was found.
Returns
True if a multiframe with a timestamp within tolerances has been found.
void okvis::FrameSynchronizer::init ( okvis::VioParameters parameters)

Initialise the synchronizer with new parameters. Is called in the constructor.

Parameters
parametersNew parameters and settings.

Member Data Documentation

int okvis::FrameSynchronizer::bufferPosition_
private

Position of the newest multiframe in the buffer.

std::vector<std::pair<std::shared_ptr<okvis::MultiFrame>, size_t> > okvis::FrameSynchronizer::frameBuffer_
private

Circular buffer containing a multiframe pointer and a counter for how many times detection has completed.

uint64_t okvis::FrameSynchronizer::lastCompletedFrameId_
private

ID of the last multiframe that returned true in detectionCompletedForAllCameras().

okvis::Time okvis::FrameSynchronizer::lastCompletedFrameTimestamp_
private

Timestamp of the last multiframe that returned true in detectionCompletedForAllCameras().

size_t okvis::FrameSynchronizer::numCameras_
private

Number of cameras for easy access.

okvis::VioParameters okvis::FrameSynchronizer::parameters_
private

Copy of the parameters and settings.

double okvis::FrameSynchronizer::timeTol_
private

Timestamp tolerance to classify multiple frames as being part of the same multiframe.


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