BoB robotics
The Brains on Board robotics library
BoBRobotics::Navigation::ImageDatabase Class Reference

An interface for reading from and writing to folders of images. More...

#include <image_database.h>

Classes

struct  Entry
 The metadata for an entry in an ImageDatabase. More...
 
class  FrameWriter
 
class  GridRecorder
 For recording a grid of images at a fixed heading. More...
 
class  ImageFileWriter
 
class  Recorder
 Base class for GridRecorder and RouteRecorder. More...
 
class  RouteRecorder
 For saving images recorded along a route. More...
 
class  VideoFileWriter
 

Public Member Functions

 ImageDatabase (const char *databasePath, bool overwrite=false)
 
 ImageDatabase (const std::string &databasePath, bool overwrite=false)
 
 ImageDatabase (filesystem::path databasePath, bool overwrite=false)
 
 ImageDatabase (const std::tm &creationTime)
 
const filesystem::pathgetPath () const
 Get the path of the directory corresponding to this ImageDatabase.
 
const Entryoperator[] (size_t i) const
 Get one Entry from the database.
 
std::vector< Entry >::const_iterator begin () const
 Start iterator for the database entries.
 
std::vector< Entry >::const_iterator end () const
 End iterator for the database entries.
 
size_t size () const
 Number of entries in this database.
 
bool empty () const
 Check if there are any entries in this database.
 
bool isRoute () const
 Check if the database is non-empty and a route-type database.
 
bool isGrid () const
 Check if the database is non-empty and a grid-type database.
 
std::vector< cv::Mat > loadImages (const cv::Size &size={}, size_t frameSkip=1, bool greyscale=true) const
 Load all of the images in this database into memory and return.
 
void loadImages (std::vector< cv::Mat > &images, const cv::Size &size={}, size_t frameSkip=1, bool greyscale=true) const
 Load all of the images in this database into the specified std::vector<>
 
bool needsUnwrapping () const
 Whether the database consists of panoramic images which need unwrapping.
 
cv::FileNode getMetadata () const
 Access the metadata for this database via OpenCV's persistence API.
 
std::string getName () const
 Get the (directory) name of this database.
 
const std::tm & getCreationTime () const
 Get the time at which this database was created.
 
std::unique_ptr< GridRecordercreateGridRecorder (const Range &xrange, const Range &yrange, const Range &zrange=Range(0_mm), degree_t heading=0_deg, std::string imageFormat="png", std::vector< std::string > extraFieldNames={})
 Start recording a grid of images.
 
std::unique_ptr< RouteRecordercreateRouteRecorder (std::string imageFormat="png", std::vector< std::string > extraFieldNames={})
 Start recording a route.
 
std::unique_ptr< RouteRecordercreateVideoRouteRecorder (const cv::Size &resolution, hertz_t fps, std::vector< std::string > extraFieldNames={})
 Start recording a route, saving images into video file using default AVI/MJPEG format. More...
 
std::unique_ptr< RouteRecordercreateVideoRouteRecorder (const cv::Size &resolution, hertz_t fps, const std::string &extension, const std::string &codec, std::vector< std::string > extraFieldNames={})
 Start recording a route, saving images into video file with a custom codec.
 
hertz_t getFrameRate () const
 
cv::Size getResolution () const
 Get the resolution of saved images.
 
bool hasMetadata () const
 Check if this database has any saved metadata (yet)
 
bool isVideoType () const
 Check if database contains a video file cf. multiple image files.
 
template<class Func >
void forEachImage (const Func &func, size_t frameSkip=1, bool greyscale=true) const
 
void unwrap (const filesystem::path &destination, const cv::Size &unwrapRes, size_t frameSkip=1, bool greyscale=false) const
 Unwrap all the panoramic images in this database into a new folder, creating a new database. More...
 

Static Public Member Functions

static bool fileNameCompare (const std::string &fn1, const std::string &fn2)
 Return true if fn1 should be sorted before fn2.
 

Static Public Attributes

static constexpr const char * MetadataFilename = "database_metadata.yaml"
 
static constexpr const char * EntriesFilename = "database_entries.csv"
 

Detailed Description

An interface for reading from and writing to folders of images.

Member Function Documentation

◆ createVideoRouteRecorder()

std::unique_ptr< ImageDatabase::RouteRecorder > BoBRobotics::Navigation::ImageDatabase::createVideoRouteRecorder ( const cv::Size &  resolution,
hertz_t  fps,
std::vector< std::string >  extraFieldNames = {} 
)

Start recording a route, saving images into video file using default AVI/MJPEG format.

!

◆ unwrap()

void BoBRobotics::Navigation::ImageDatabase::unwrap ( const filesystem::path destination,
const cv::Size &  unwrapRes,
size_t  frameSkip = 1,
bool  greyscale = false 
) const

Unwrap all the panoramic images in this database into a new folder, creating a new database.

!


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