supereight
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
se::Reader Class Referenceabstract

Base abstract class for dataset readers. More...

#include <reader_base.hpp>

Inheritance diagram for se::Reader:
se::InteriorNetReader se::NewerCollegeReader se::OpenNIReader se::RAWReader se::TUMReader

Public Member Functions

 Reader (const ReaderConfig &c)
 Construct a Reader from a ReaderConfig. More...
 
virtual ~Reader ()
 
ReaderStatus nextData (Image< float > &depth_image)
 Read the next depth image. More...
 
ReaderStatus nextData (Image< float > &depth_image, Image< uint32_t > &rgba_image)
 Read the next depth and RGBA images. More...
 
ReaderStatus nextData (Image< float > &depth_image, Image< uint32_t > &rgba_image, Eigen::Matrix4f &T_WB)
 Read the next depth and RGBA images and ground truth pose. More...
 
ReaderStatus getPose (Eigen::Matrix4f &T_WB, const size_t frame)
 Read the ground truth pose at the provided frame number. More...
 
virtual void restart ()=0
 Restart reading from the beginning. More...
 
virtual std::string name () const =0
 The name of the reader. More...
 
bool good () const
 The state of the reader. More...
 
size_t frame () const
 The current frame number. More...
 
size_t numFrames () const
 The total number of frames in the current dataset. More...
 
Eigen::Vector2i depthImageRes () const
 The dimensions of the depth images. More...
 
Eigen::Vector2i RGBAImageRes () const
 The dimensions of the RGBA images. More...
 
bool isLiveReader () const
 Whether the reader uses a live camera as input. More...
 

Static Public Member Functions

static ReaderStatus mergeStatus (ReaderStatus status_1, ReaderStatus status_2)
 Merge se::ReaderStatus values keeping the worst one. More...
 

Protected Member Functions

ReaderStatus readPose (Eigen::Matrix4f &T_WB, const size_t frame, const char delimiter=' ')
 Read the ground truth pose at the provided frame number. More...
 
ReaderStatus nextPose (Eigen::Matrix4f &T_WB)
 Read the next ground truth pose. More...
 

Protected Attributes

std::string sequence_path_
 
std::string ground_truth_file_
 
std::ifstream ground_truth_fs_
 
Eigen::Vector2i depth_image_res_
 
Eigen::Vector2i rgba_image_res_
 
float fps_
 
double spf_
 
bool drop_frames_
 
int verbose_
 
bool is_live_reader_
 
ReaderStatus status_
 
size_t frame_
 The frame_ is initialized to SIZE_MAX, so that when first incremented it becomes 0. More...
 
size_t num_frames_
 

Detailed Description

Base abstract class for dataset readers.

The overloaded nextData() functions all increment the frame counter, so only one of them should be called within a single pipeline iteration.

Note
Derived classes should adhere to the following rules:

Constructor & Destructor Documentation

◆ Reader()

se::Reader::Reader ( const ReaderConfig c)

Construct a Reader from a ReaderConfig.

Note
This constructor should be called in all derived class constructors.
Parameters
[in]cThe configuration struct to use.

◆ ~Reader()

virtual se::Reader::~Reader ( )
inlinevirtual

Member Function Documentation

◆ nextData() [1/3]

ReaderStatus se::Reader::nextData ( Image< float > &  depth_image)

Read the next depth image.

Note
The frame number is incremented when calling this function.
Parameters
[out]depth_imageThe next depth image.
Returns
An appropriate status code.

◆ nextData() [2/3]

ReaderStatus se::Reader::nextData ( Image< float > &  depth_image,
Image< uint32_t > &  rgba_image 
)

Read the next depth and RGBA images.

Note
The frame number is incremented when calling this function.
Parameters
[out]depth_imageThe next depth image.
[out]rgba_imageThe next RGBA image.
Returns
An appropriate status code.

◆ nextData() [3/3]

ReaderStatus se::Reader::nextData ( Image< float > &  depth_image,
Image< uint32_t > &  rgba_image,
Eigen::Matrix4f &  T_WB 
)

Read the next depth and RGBA images and ground truth pose.

Note
The frame number is incremented when calling this function.
Parameters
[out]depth_imageThe next depth image.
[out]rgba_imageThe next RGBA image.
[out]T_WBThe next ground truth pose.
Returns
An appropriate status code.

◆ getPose()

ReaderStatus se::Reader::getPose ( Eigen::Matrix4f &  T_WB,
const size_t  frame 
)

Read the ground truth pose at the provided frame number.

Each line in the ground truth file should correspond to a single depth/RGBA image pair and have a format
... tx ty tz qx qy qz qw,
that is the pose is encoded in the last 7 columns of the line.

Parameters
[in]frameThe frame number of the requested ground truth pose.
[out]T_WBThe ground truth pose.
Returns
An appropriate status code.

◆ restart()

virtual void se::Reader::restart ( )
pure virtual

Restart reading from the beginning.

Note
Although this is a virtual function, it does have a default implementation that resets the Reader protected variables. Reader::restart() (this default implementation) should be called at the very beginning of any implementation of restart().

Implemented in se::OpenNIReader, se::InteriorNetReader, se::TUMReader, se::NewerCollegeReader, and se::RAWReader.

◆ name()

virtual std::string se::Reader::name ( ) const
pure virtual

The name of the reader.

Returns
The name of the reader as a string.

Implemented in se::OpenNIReader, se::InteriorNetReader, se::TUMReader, se::NewerCollegeReader, and se::RAWReader.

◆ good()

bool se::Reader::good ( ) const

The state of the reader.

If good() returns false, there is no need to keep reading frames.

Returns
True if the last call to one of the Reader::next*() functions completed successfully.

◆ frame()

size_t se::Reader::frame ( ) const

The current frame number.

Frame numbering starts from 0, so the number of frames read so far is frame() + 1.

Returns
The number of frames read. Returns SIZE_MAX if no frames have been read yet.

◆ numFrames()

size_t se::Reader::numFrames ( ) const

The total number of frames in the current dataset.

Returns
The total number of frames. Returns 0 if the number of frames is unknown (e.g. for camera input).

◆ depthImageRes()

Eigen::Vector2i se::Reader::depthImageRes ( ) const

The dimensions of the depth images.

Returns
A 2D vector containing the width and height of the images.

◆ RGBAImageRes()

Eigen::Vector2i se::Reader::RGBAImageRes ( ) const

The dimensions of the RGBA images.

Returns
A 2D vector containing the width and height of the images.

◆ isLiveReader()

bool se::Reader::isLiveReader ( ) const

Whether the reader uses a live camera as input.

Returns
True if the input is from a live camera, false otherwise.

◆ mergeStatus()

static ReaderStatus se::Reader::mergeStatus ( ReaderStatus  status_1,
ReaderStatus  status_2 
)
static

Merge se::ReaderStatus values keeping the worst one.

Parameters
[in]status_1The first se::ReaderStatus to merge.
[in]status_2The second se::ReaderStatus to merge.
Returns
The worst of the 2 statuses.

◆ readPose()

ReaderStatus se::Reader::readPose ( Eigen::Matrix4f &  T_WB,
const size_t  frame,
const char  delimiter = ' ' 
)
protected

Read the ground truth pose at the provided frame number.

Each line in the ground truth file should correspond to a single depth/RGBA image pair and have a format
... tx ty tz qx qy qz qw,
that is the pose is encoded in the last 7 columns of the line.

Note
Use getPose(...) to request a pose. It keeps track of the ground_truth_frame_ and ifstream state.
Parameters
[out]T_WBThe ground truth pose.
[in]frameThe frame number of the requested ground truth pose.
[in]delimiterThe character delimiting columns in the file. Defaults to space.
Returns
An appropriate status code.

◆ nextPose()

ReaderStatus se::Reader::nextPose ( Eigen::Matrix4f &  T_WB)
protected

Read the next ground truth pose.

Each line in the ground truth file should correspond to a single depth/RGBA image pair and have a format
... tx ty tz qx qy qz qw,
that is the pose is encoded in the last 7 columns of the line.

Note
The frame number is NOT incremented inside this function.
Parameters
[out]T_WBThe next ground truth pose.
Returns
An appropriate status code.

Member Data Documentation

◆ sequence_path_

std::string se::Reader::sequence_path_
protected

◆ ground_truth_file_

std::string se::Reader::ground_truth_file_
protected

◆ ground_truth_fs_

std::ifstream se::Reader::ground_truth_fs_
protected

◆ depth_image_res_

Eigen::Vector2i se::Reader::depth_image_res_
protected

◆ rgba_image_res_

Eigen::Vector2i se::Reader::rgba_image_res_
protected

◆ fps_

float se::Reader::fps_
protected

◆ spf_

double se::Reader::spf_
protected

◆ drop_frames_

bool se::Reader::drop_frames_
protected

◆ verbose_

int se::Reader::verbose_
protected

◆ is_live_reader_

bool se::Reader::is_live_reader_
protected

◆ status_

ReaderStatus se::Reader::status_
protected

◆ frame_

size_t se::Reader::frame_
protected

The frame_ is initialized to SIZE_MAX, so that when first incremented it becomes 0.

Unsigned integer overflow is defined behaviour in C/C++ so this is safe to do.

◆ num_frames_

size_t se::Reader::num_frames_
protected

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