JeVoisBase  1.20
JeVois Smart Embedded Machine Vision Toolkit Base Modules
Share this page:
BufferedVideoReader Class Reference

Simple class to read video frames from a movie file, decode them, and buffer them for smooth playback. More...

#include <jevoisbase/Components/Utilities/BufferedVideoReader.H>

Inheritance diagram for BufferedVideoReader:
Collaboration diagram for BufferedVideoReader:

Public Member Functions

 BufferedVideoReader (std::string const &instance, size_t bufsize=100)
 Constructor. More...
 
 ~BufferedVideoReader ()
 Virtual destructor for safe inheritance. More...
 
cv::Mat get ()
 Get the next frame as a BGR cv::Mat, or an empty cv::Mat when the movie is finished. More...
 
- Public Member Functions inherited from jevois::Component
 Component (std::string const &instance)
 
virtual ~Component ()
 
std::shared_ptr< Comp > addSubComponent (std::string const &instance, Args &&...args)
 
void removeSubComponent (std::shared_ptr< Comp > &component)
 
void removeSubComponent (std::string const &instance, bool warnIfNotFound=true)
 
std::shared_ptr< Comp > getSubComponent (std::string const &instance) const
 
bool isTopLevel () const
 
Engineengine () const
 
bool initialized () const
 
const std::string & className () const
 
const std::string & instanceName () const
 
std::vector< std::string > setParamVal (std::string const &paramdescriptor, T const &val)
 
void setParamValUnique (std::string const &paramdescriptor, T const &val)
 
std::vector< std::pair< std::string, T > > getParamVal (std::string const &paramdescriptor) const
 
getParamValUnique (std::string const &paramdescriptor) const
 
std::vector< std::string > setParamString (std::string const &paramdescriptor, std::string const &val)
 
void setParamStringUnique (std::string const &paramdescriptor, std::string const &val)
 
std::vector< std::pair< std::string, std::string > > getParamString (std::string const &paramdescriptor) const
 
std::string getParamStringUnique (std::string const &paramdescriptor) const
 
void freezeParam (std::string const &paramdescriptor)
 
void unFreezeParam (std::string const &paramdescriptor)
 
void freezeAllParams ()
 
void unFreezeAllParams ()
 
std::string descriptor () const
 
void setParamsFromFile (std::string const &filename)
 
std::istream & setParamsFromStream (std::istream &is, std::string const &absfile)
 
virtual void paramInfo (std::shared_ptr< UserInterface > s, std::map< std::string, std::string > &categs, bool skipFrozen, std::string const &cname="", std::string const &pfx="")
 
void foreachParam (std::function< void(std::string const &compname, ParameterBase *p)> func, std::string const &cname="")
 
std::shared_ptr< DynamicParameter< T > > addDynamicParameter (std::string const &name, std::string const &description, T const &defaultValue, ParameterCategory const &category)
 
std::shared_ptr< DynamicParameter< T > > addDynamicParameter (std::string const &name, std::string const &description, T const &defaultValue, ValidValuesSpec< T > const &validValuesSpec, ParameterCategory const &category)
 
void setDynamicParameterCallback (std::string const &name, std::function< void(T const &)> cb, bool callnow=true)
 
void removeDynamicParameter (std::string const &name)
 
void setPath (std::string const &path)
 
std::filesystem::path absolutePath (std::filesystem::path const &path="")
 
std::shared_ptr< Comp > addSubComponent (std::string const &instance, Args &&...args)
 
void removeSubComponent (std::shared_ptr< Comp > &component)
 
void removeSubComponent (std::string const &instance, bool warnIfNotFound=true)
 
std::shared_ptr< Comp > getSubComponent (std::string const &instance) const
 
bool isTopLevel () const
 
Engineengine () const
 
bool initialized () const
 
const std::string & className () const
 
const std::string & instanceName () const
 
std::vector< std::string > setParamVal (std::string const &paramdescriptor, T const &val)
 
void setParamValUnique (std::string const &paramdescriptor, T const &val)
 
std::vector< std::pair< std::string, T > > getParamVal (std::string const &paramdescriptor) const
 
getParamValUnique (std::string const &paramdescriptor) const
 
std::vector< std::string > setParamString (std::string const &paramdescriptor, std::string const &val)
 
void setParamStringUnique (std::string const &paramdescriptor, std::string const &val)
 
std::vector< std::pair< std::string, std::string > > getParamString (std::string const &paramdescriptor) const
 
std::string getParamStringUnique (std::string const &paramdescriptor) const
 
void freezeParam (std::string const &paramdescriptor)
 
void unFreezeParam (std::string const &paramdescriptor)
 
void freezeAllParams ()
 
void unFreezeAllParams ()
 
std::string descriptor () const
 
void setParamsFromFile (std::string const &filename)
 
std::istream & setParamsFromStream (std::istream &is, std::string const &absfile)
 
virtual void paramInfo (std::shared_ptr< UserInterface > s, std::map< std::string, std::string > &categs, bool skipFrozen, std::string const &cname="", std::string const &pfx="")
 
void foreachParam (std::function< void(std::string const &compname, ParameterBase *p)> func, std::string const &cname="")
 
std::shared_ptr< DynamicParameter< T > > addDynamicParameter (std::string const &name, std::string const &description, T const &defaultValue, ParameterCategory const &category)
 
std::shared_ptr< DynamicParameter< T > > addDynamicParameter (std::string const &name, std::string const &description, T const &defaultValue, ValidValuesSpec< T > const &validValuesSpec, ParameterCategory const &category)
 
void setDynamicParameterCallback (std::string const &name, std::function< void(T const &)> cb, bool callnow=true)
 
void removeDynamicParameter (std::string const &name)
 
void setPath (std::string const &path)
 
std::filesystem::path absolutePath (std::filesystem::path const &path="")
 
- Public Member Functions inherited from jevois::ParameterRegistry
virtual ~ParameterRegistry ()
 

Protected Member Functions

virtual void postInit () override
 Start the thread that loads, decodes and pushes the frames into our buffer. More...
 
virtual void postUninit () override
 Uninit, wait on our run thread and swallow any exception. More...
 
void run ()
 Reader thread. More...
 
- Protected Member Functions inherited from jevois::Component
virtual void preInit ()
 
virtual void preUninit ()
 
virtual void preInit ()
 
virtual void preUninit ()
 
- Protected Member Functions inherited from jevois::ParameterRegistry
void addParameter (ParameterBase *const param)
 
void removeParameter (ParameterBase *const param)
 
void callbackInitCall ()
 

Related Functions

(Note that these are not member functions.)

 JEVOIS_DECLARE_PARAMETER (filename, std::string, "Filename of video to read (if not absolute, will be assumed to be " "relative to Component path)", "movie.mpg", ParamCateg)
 Parameter. More...
 

Detailed Description

Simple class to read video frames from a movie file, decode them, and buffer them for smooth playback.

Reading and decoding is done in a thread, and decoded images are pushed into a producer/consumer queue. When the queue is full, decoding pauses until some images are popped off the queue by some other thread, for example to display them or to send them over USB link.

Definition at line 43 of file BufferedVideoReader.H.

Constructor & Destructor Documentation

◆ BufferedVideoReader()

BufferedVideoReader::BufferedVideoReader ( std::string const &  instance,
size_t  bufsize = 100 
)

Constructor.

Definition at line 22 of file BufferedVideoReader.C.

◆ ~BufferedVideoReader()

BufferedVideoReader::~BufferedVideoReader ( )

Virtual destructor for safe inheritance.

Definition at line 27 of file BufferedVideoReader.C.

Member Function Documentation

◆ get()

cv::Mat BufferedVideoReader::get ( )

Get the next frame as a BGR cv::Mat, or an empty cv::Mat when the movie is finished.

Definition at line 57 of file BufferedVideoReader.C.

References jevois::BoundedBuffer< class, WhenFull, WhenEmpty >::pop().

◆ postInit()

void BufferedVideoReader::postInit ( )
overrideprotectedvirtual

Start the thread that loads, decodes and pushes the frames into our buffer.

Reimplemented from jevois::Component.

Definition at line 31 of file BufferedVideoReader.C.

References jevois::Component::absolutePath(), jevois::async(), jevois::BoundedBuffer< class, WhenFull, WhenEmpty >::filled_size(), LINFO, and run().

◆ postUninit()

void BufferedVideoReader::postUninit ( )
overrideprotectedvirtual

Uninit, wait on our run thread and swallow any exception.

Reimplemented from jevois::Component.

Definition at line 47 of file BufferedVideoReader.C.

References jevois::BoundedBuffer< class, WhenFull, WhenEmpty >::filled_size(), JEVOIS_WAIT_GET_FUTURE, and jevois::BoundedBuffer< class, WhenFull, WhenEmpty >::pop().

◆ run()

void BufferedVideoReader::run ( )
protected

Friends And Related Function Documentation

◆ JEVOIS_DECLARE_PARAMETER()

JEVOIS_DECLARE_PARAMETER ( filename  ,
std::string  ,
"Filename of video to read (if not absolute, will be assumed to be " "relative to Component path)"  ,
"movie.mpg"  ,
ParamCateg   
)
related

Parameter.


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