OpenEV
Extending OpenCV to event-based vision
Loading...
Searching...
No Matches
ev::AbstractDataset Class Referenceabstract

This is an auxiliary class. This class cannot be instanced. More...

#include <abstract-dataset.hpp>

Inheritance diagram for ev::AbstractDataset:
ev::EventCameraDataset

Public Types

using Progress = std::function<void(double, double)>
 Function called while a sequence is being downloaded.

Public Member Functions

 AbstractDataset (const AbstractDataset &)=delete
 AbstractDataset (AbstractDataset &&) noexcept=default
AbstractDataset & operator= (const AbstractDataset &)=delete
AbstractDataset & operator= (AbstractDataset &&) noexcept=default
virtual std::string name () const =0
 Name of the dataset.
virtual std::string shortname () const =0
 Short name of the dataset, also used as directory name.
virtual std::vector< std::string > sequences () const =0
 Sequences published by the dataset.
virtual std::string url (const std::string &sequence) const =0
 Address of the zip file of a sequence.
virtual cv::Size sensorSize (const std::string &sequence) const =0
 Sensor size of the camera that recorded a sequence.
virtual std::string cameraName (const std::string &sequence) const =0
 Name of the camera that recorded a sequence.
void setDirectory (const std::string &directory)
 Set the directory where the sequences of this dataset are kept.
std::string directory () const
 Directory where the sequences of this dataset are kept.
std::string path (const std::string &sequence) const
 Directory of a sequence.
bool isAvailable (const std::string &sequence) const
 Check if a sequence has been downloaded.
bool download (const std::string &sequence, const Progress &progress=nullptr)
 Download a sequence and extract it in path(). Nothing is done if the sequence is already available.
bool open (const std::string &sequence, const Progress &progress=nullptr)
 Open a sequence, downloading it first if it is not available.
void close ()
 Close the sequence.
bool isOpen () const
 Check if a sequence is open.
const std::string & sequence () const
 Name of the sequence that is open.
ConcurrentQueue & events (const std::size_t n=0)
 Read a given number of events, add them to the queue, and return it, see AbstractReader_::events().
void prefetch (const std::size_t n)
 Keep the queue at a given number of events from a background thread, see AbstractReader_::prefetch().
std::size_t prefetchCapacity () const
 Number of events prefetch() keeps in the queue, see AbstractReader_::prefetchCapacity().
void setRoi (const cv::Rect &roi)
 Deliver only the events inside a region of interest, as the cameras of the devices module do. The events keep their coordinates.
cv::Rect getRoi () const
 Get the region of interest.
void reset ()
 Go back to the beginning of the sequence, see AbstractReader_::reset().
const FrameFileVector & frames () const
 Frames of the sequence, empty if it has none.
const ImuVector & imu () const
 Inertial measurements of the sequence, empty if it has none.
const std::string & error () const
 Reason why the last download() failed.

Static Public Member Functions

static std::string cacheDirectory ()
 Directory where downloaded datasets are kept by default.

Detailed Description

This is an auxiliary class. This class cannot be instanced.

A dataset knows which sequences it publishes, where each one is downloaded from, and where they are kept in this machine.

Note
Events are read on demand: events(n) reads n events from the sequence, adds them to a queue and returns it. With prefetch(n), a background thread keeps n events in the queue instead.
Frames are listed by frames() as image files with their timestamps, sorted by time.
Inertial measurements are all loaded when the sequence is opened, and listed by imu() sorted by time.

Member Function Documentation

◆ cacheDirectory()

std::string ev::AbstractDataset::cacheDirectory ( )
staticnodiscard

Directory where downloaded datasets are kept by default.

Returns
$XDG_CACHE_HOME/openev/datasets, or ~/.cache/openev/datasets if XDG_CACHE_HOME is not set

◆ cameraName()

virtual std::string ev::AbstractDataset::cameraName ( const std::string & sequence) const
nodiscardpure virtual

Name of the camera that recorded a sequence.

Parameters
sequenceSequence name
Returns
Camera name

Implemented in ev::EventCameraDataset.

◆ directory()

std::string ev::AbstractDataset::directory ( ) const
nodiscard

Directory where the sequences of this dataset are kept.

Returns
Directory

◆ download()

bool ev::AbstractDataset::download ( const std::string & sequence,
const Progress & progress = nullptr )

Download a sequence and extract it in path(). Nothing is done if the sequence is already available.

Parameters
sequenceSequence name
progressFunction called while downloading
Returns
True if the sequence is available; if false, see error()

◆ error()

const std::string & ev::AbstractDataset::error ( ) const
inlinenodiscard

Reason why the last download() failed.

Returns
Message, empty if it did not fail
Examples
example-event-camera-dataset.cpp.

◆ events()

ConcurrentQueue & ev::AbstractDataset::events ( const std::size_t n = 0)
inlinenodiscard

Read a given number of events, add them to the queue, and return it, see AbstractReader_::events().

Parameters
nNumber of events to add to the queue
Returns
Reference to the queue
Examples
example-event-camera-dataset.cpp.

◆ frames()

const FrameFileVector & ev::AbstractDataset::frames ( ) const
inlinenodiscard

Frames of the sequence, empty if it has none.

Returns
Frames sorted by timestamp, in microseconds, with the absolute path of each image file
Examples
example-event-camera-dataset.cpp.

◆ getRoi()

cv::Rect ev::AbstractDataset::getRoi ( ) const
inlinenodiscard

Get the region of interest.

Returns
Region of interest in pixels; the whole sensor of the sequence that is open if none was set
Examples
example-event-camera-dataset.cpp.

◆ imu()

const ImuVector & ev::AbstractDataset::imu ( ) const
inlinenodiscard

Inertial measurements of the sequence, empty if it has none.

Returns
Measurements sorted by timestamp
Examples
example-event-camera-dataset.cpp.

◆ isAvailable()

bool ev::AbstractDataset::isAvailable ( const std::string & sequence) const
nodiscard

Check if a sequence has been downloaded.

Parameters
sequenceSequence name
Returns
True if the sequence is ready to be read
Examples
example-event-camera-dataset.cpp.

◆ isOpen()

bool ev::AbstractDataset::isOpen ( ) const
inlinenodiscard

Check if a sequence is open.

Returns
True if open

◆ name()

virtual std::string ev::AbstractDataset::name ( ) const
nodiscardpure virtual

Name of the dataset.

Returns
Name

Implemented in ev::EventCameraDataset.

◆ open()

bool ev::AbstractDataset::open ( const std::string & sequence,
const Progress & progress = nullptr )

Open a sequence, downloading it first if it is not available.

Parameters
sequenceSequence name
progressFunction called while downloading
Returns
True if the sequence is open; if false, see error()
Examples
example-event-camera-dataset.cpp.

◆ path()

std::string ev::AbstractDataset::path ( const std::string & sequence) const
nodiscard

Directory of a sequence.

Parameters
sequenceSequence name
Returns
Directory, whether the sequence has been downloaded or not
Examples
example-event-camera-dataset.cpp.

◆ prefetch()

void ev::AbstractDataset::prefetch ( const std::size_t n)
inline

Keep the queue at a given number of events from a background thread, see AbstractReader_::prefetch().

Parameters
nNumber of events to keep in the queue; zero stops the thread
Examples
example-event-camera-dataset.cpp.

◆ prefetchCapacity()

std::size_t ev::AbstractDataset::prefetchCapacity ( ) const
inlinenodiscard

Number of events prefetch() keeps in the queue, see AbstractReader_::prefetchCapacity().

Returns
Number of events, zero if there is no thread
Examples
example-event-camera-dataset.cpp.

◆ sensorSize()

virtual cv::Size ev::AbstractDataset::sensorSize ( const std::string & sequence) const
nodiscardpure virtual

Sensor size of the camera that recorded a sequence.

Parameters
sequenceSequence name
Returns
Sensor size in pixels

Implemented in ev::EventCameraDataset.

◆ sequence()

const std::string & ev::AbstractDataset::sequence ( ) const
inlinenodiscard

Name of the sequence that is open.

Returns
Sequence name, empty if none
Examples
example-event-camera-dataset.cpp.

◆ sequences()

virtual std::vector< std::string > ev::AbstractDataset::sequences ( ) const
nodiscardpure virtual

Sequences published by the dataset.

Returns
Sequence names

Implemented in ev::EventCameraDataset.

◆ setDirectory()

void ev::AbstractDataset::setDirectory ( const std::string & directory)

Set the directory where the sequences of this dataset are kept.

Parameters
directoryDirectory; if empty, shortname() inside cacheDirectory()

◆ setRoi()

void ev::AbstractDataset::setRoi ( const cv::Rect & roi)
inline

Deliver only the events inside a region of interest, as the cameras of the devices module do. The events keep their coordinates.

Parameters
roiRegion of interest in pixels; an empty region delivers every event
Note
Frames and inertial measurements are not affected.
Examples
example-event-camera-dataset.cpp.

◆ shortname()

virtual std::string ev::AbstractDataset::shortname ( ) const
nodiscardpure virtual

Short name of the dataset, also used as directory name.

Returns
Short name

Implemented in ev::EventCameraDataset.

◆ url()

virtual std::string ev::AbstractDataset::url ( const std::string & sequence) const
nodiscardpure virtual

Address of the zip file of a sequence.

Parameters
sequenceSequence name
Returns
URL

Implemented in ev::EventCameraDataset.


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