DvsenseDriver  1.0.3
The SDK for dvsense products.
dvsense::DvsFileReader Class Referenceabstract

DVS File Reader class. More...

#include <DvsFileReader.h>

Public Member Functions

 DvsFileReader ()
 Default constructor. More...
 
virtual ~DvsFileReader ()
 Virtual destructor. More...
 
virtual bool loadFile ()=0
 Loads a RAW file for event processing. More...
 
virtual bool getStartTimeStamp (TimeStamp &start_timestamp)=0
 Get the Seek start of TimeStamp in the file. More...
 
virtual bool getEndTimeStamp (TimeStamp &end_timestamp)=0
 Get the Seek end of TimeStamp in the file. More...
 
virtual bool getMaxEvents (uint64_t &num)=0
 Get the maximum number of events available. More...
 
virtual bool reachedEndOfEvents ()=0
 Check if the end of the event data has been reached. More...
 
virtual bool seekTime (TimeStamp t)=0
 Seeks to a specific timestamp in the file. More...
 
virtual bool seekNEvents (uint64_t n_event)=0
 Seeks to the n event in the file. More...
 
virtual TimeStamp getCurrentPosTimeStamp ()=0
 Gets the timestamp of the current file decode location. More...
 
virtual uint64_t getCurrentPosEventNum ()=0
 Gets the number of events from the start of the file to the current file decoding location. More...
 
virtual std::shared_ptr< Event2DVector > getNEvents (uint64_t n)=0
 Retrieves a specified number of events from the current file position. More...
 
virtual std::shared_ptr< Event2DVector > getNEventsGivenStartTimeStamp (TimeStamp start, uint64_t n)=0
 Retrieves a specified number of events starting from a given timestamp. More...
 
virtual std::shared_ptr< Event2DVector > getNEventsGivenStartEvent (uint64_t event_num, uint64_t n)=0
 Retrieves a specific number of events from a specified location. More...
 
virtual std::shared_ptr< std::vector< Event2D > > getNTimeEvents (TimeStamp interval)=0
 Retrieves events within a specific time interval from the current position. More...
 
virtual std::shared_ptr< Event2DVector > getNTimeEventsGivenStartTimeStamp (TimeStamp start, TimeStamp interval)=0
 Retrieves events within a specific time interval from the current position. More...
 
virtual std::shared_ptr< std::vector< Event2D > > getNTimeEventsGivenStartEvent (uint64_t event_num, TimeStamp interval)=0
 Retrieves events within a specified time interval starting with event num. More...
 
virtual bool extractEventData (TimeStamp start, TimeStamp end, std::string out_file_path)=0
 Extracts event data within a specified time range and saves the results to a specified output file. More...
 
virtual bool exportEventDataToVideo (TimeStamp start, TimeStamp end, std::string out_file_path)=0
 
virtual uint16_t getWidth () const =0
 Get the width of the sensor used to capture the events. More...
 
virtual uint16_t getHeight () const =0
 Get the height of the sensor used to capture the events. More...
 

Static Public Member Functions

static std::unique_ptr< DvsFileReadercreateFileReader (std::string filepath)
 Create a File Reader object. More...
 

Detailed Description

DVS File Reader class.

Constructor & Destructor Documentation

◆ DvsFileReader()

dvsense::DvsFileReader::DvsFileReader ( )
inline

Default constructor.

◆ ~DvsFileReader()

virtual dvsense::DvsFileReader::~DvsFileReader ( )
inlinevirtual

Virtual destructor.

Member Function Documentation

◆ createFileReader()

static std::unique_ptr<DvsFileReader> dvsense::DvsFileReader::createFileReader ( std::string  filepath)
static

Create a File Reader object.

Parameters
filepathPath to the file
Returns
std::unique_ptr<DvsFileReader> Unique pointer to the created file reader

◆ loadFile()

virtual bool dvsense::DvsFileReader::loadFile ( )
pure virtual

Loads a RAW file for event processing.

Parameters
filepathThe full path of the RAW file to be loaded.
Returns
True if the file was successfully loaded, false otherwise.
Note
This function might take significant time to complete depending on the file size.

◆ getStartTimeStamp()

virtual bool dvsense::DvsFileReader::getStartTimeStamp ( TimeStamp start_timestamp)
pure virtual

Get the Seek start of TimeStamp in the file.

Parameters
start_timestampReference to the start timestamp.
Returns
True if the file has timestamp information, true is returned.
False if there is no timestamp information in the file, false is returned.

◆ getEndTimeStamp()

virtual bool dvsense::DvsFileReader::getEndTimeStamp ( TimeStamp end_timestamp)
pure virtual

Get the Seek end of TimeStamp in the file.

Parameters
end_timestampReference to the end timestamp.
Returns
True if the file has timestamp information, true is returned.
False if there is no timestamp information in the file, false is returned.

◆ getMaxEvents()

virtual bool dvsense::DvsFileReader::getMaxEvents ( uint64_t &  num)
pure virtual

Get the maximum number of events available.

Parameters
numReference to store the maximum number of events.
Returns
True if the maximum event count is successfully retrieved.
False if the event count cannot be determined.

◆ reachedEndOfEvents()

virtual bool dvsense::DvsFileReader::reachedEndOfEvents ( )
pure virtual

Check if the end of the event data has been reached.

Returns
True if all events have been read and no more data is available.
False if there are still unread events.

◆ seekTime()

virtual bool dvsense::DvsFileReader::seekTime ( TimeStamp  t)
pure virtual

Seeks to a specific timestamp in the file.

This function moves the current position in the file to the event at the specified timestamp. If the provided timestamp is out of bounds, the current position will be set to the start or end of the file accordingly.

Parameters
tThe target timestamp to seek to.
Returns
True if the seek operation was successful, false if the timestamp was not found.

◆ seekNEvents()

virtual bool dvsense::DvsFileReader::seekNEvents ( uint64_t  n_event)
pure virtual

Seeks to the n event in the file.

Parameters
tThe target event num to seek to.
Returns
True if the seek operation was successful, false if the n event was not found.

◆ getCurrentPosTimeStamp()

virtual TimeStamp dvsense::DvsFileReader::getCurrentPosTimeStamp ( )
pure virtual

Gets the timestamp of the current file decode location.

Returns
TimeStamp
Note
When reading a fixed number of events or at a fixed time interval, the timestamp of the current file location may not correspond to the timestamp of the returned event.

◆ getCurrentPosEventNum()

virtual uint64_t dvsense::DvsFileReader::getCurrentPosEventNum ( )
pure virtual

Gets the number of events from the start of the file to the current file decoding location.

Returns
events num

◆ getNEvents()

virtual std::shared_ptr<Event2DVector> dvsense::DvsFileReader::getNEvents ( uint64_t  n)
pure virtual

Retrieves a specified number of events from the current file position.

Parameters
nThe number of events to retrieve.
Returns
A shared pointer to an Event2DVector containing the retrieved events.
Warning
This function is not thread-safe and the buffer will be overwritten on the next call.

◆ getNEventsGivenStartTimeStamp()

virtual std::shared_ptr<Event2DVector> dvsense::DvsFileReader::getNEventsGivenStartTimeStamp ( TimeStamp  start,
uint64_t  n 
)
pure virtual

Retrieves a specified number of events starting from a given timestamp.

Parameters
startThe timestamp to start reading from.
nThe number of events to retrieve.
Returns
A shared pointer to an Event2DVector containing the retrieved events.
Warning
This function is not thread-safe and the buffer will be overwritten on the next call.

◆ getNEventsGivenStartEvent()

virtual std::shared_ptr<Event2DVector> dvsense::DvsFileReader::getNEventsGivenStartEvent ( uint64_t  event_num,
uint64_t  n 
)
pure virtual

Retrieves a specific number of events from a specified location.

Parameters
event_numThe event number to start reading from.
nThe number of events which to retrieve.
Returns
A shared pointer to an Event2DVector containing the retrieved events.
Warning
This function is not thread-safe and the buffer will be overwritten on the next call.

◆ getNTimeEvents()

virtual std::shared_ptr<std::vector<Event2D> > dvsense::DvsFileReader::getNTimeEvents ( TimeStamp  interval)
pure virtual

Retrieves events within a specific time interval from the current position.

Parameters
intervalThe time interval during which to retrieve events.
Returns
A shared pointer to an Event2DVector containing the retrieved events.
Warning
This function is not thread-safe and the buffer will be overwritten on the next call.

◆ getNTimeEventsGivenStartTimeStamp()

virtual std::shared_ptr<Event2DVector> dvsense::DvsFileReader::getNTimeEventsGivenStartTimeStamp ( TimeStamp  start,
TimeStamp  interval 
)
pure virtual

Retrieves events within a specific time interval from the current position.

Parameters
startThe timestamp to start reading from.
intervalThe time interval during which to retrieve events.
Returns
A shared pointer to an Event2DVector containing the retrieved events.
Warning
This function is not thread-safe and the buffer will be overwritten on the next call.

◆ getNTimeEventsGivenStartEvent()

virtual std::shared_ptr<std::vector<Event2D> > dvsense::DvsFileReader::getNTimeEventsGivenStartEvent ( uint64_t  event_num,
TimeStamp  interval 
)
pure virtual

Retrieves events within a specified time interval starting with event num.

Parameters
event_numThe event num to start reading from.
intervalThe time interval during which to retrieve events.
Returns
A shared pointer to an Event2DVector containing the retrieved events.
Warning
This function is not thread-safe and the buffer will be overwritten on the next call.

◆ extractEventData()

virtual bool dvsense::DvsFileReader::extractEventData ( TimeStamp  start,
TimeStamp  end,
std::string  out_file_path 
)
pure virtual

Extracts event data within a specified time range and saves the results to a specified output file.

Parameters
startThe start timestamp.
endThe end timestamp
Returns
Return true if file output succeeds, false otherwise.
Warning
out_file_path The complete file path must be output, and the file directory must exist.
Note
It should be noted that the saved file data is not an accurate start timestamp, and there is a deviation of about 10us from the actual start timestamp.

◆ exportEventDataToVideo()

virtual bool dvsense::DvsFileReader::exportEventDataToVideo ( TimeStamp  start,
TimeStamp  end,
std::string  out_file_path 
)
pure virtual

◆ getWidth()

virtual uint16_t dvsense::DvsFileReader::getWidth ( ) const
pure virtual

Get the width of the sensor used to capture the events.

Returns
uint16_t

◆ getHeight()

virtual uint16_t dvsense::DvsFileReader::getHeight ( ) const
pure virtual

Get the height of the sensor used to capture the events.

Returns
uint16_t