JeVoisBase  1.22
JeVois Smart Embedded Machine Vision Toolkit Base Modules
Share this page:
Loading...
Searching...
No Matches
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.
 
 ~BufferedVideoReader ()
 Virtual destructor for safe inheritance.
 
cv::Mat get ()
 Get the next frame as a BGR cv::Mat, or an empty cv::Mat when the movie is finished.
 
- 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
 
bool initialized () const
 
std::string const & className () const
 
std::string const & 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, bool doit)
 
void freezeAllParams (bool doit)
 
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, bool throw_if_not_found=true)
 
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
 
bool initialized () const
 
std::string const & className () const
 
std::string const & 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, bool doit)
 
void freezeAllParams (bool doit)
 
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, bool throw_if_not_found=true)
 
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.
 
virtual void postUninit () override
 Uninit, wait on our run thread and swallow any exception.
 
void run ()
 Reader thread.
 
- 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 Symbols

(Note that these are not member symbols.)

 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.
 

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< typename T, BlockingBehavior WhenFull, BlockingBehavior 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< typename T, BlockingBehavior WhenFull, BlockingBehavior WhenEmpty >::filled_size(), LINFO, and run().

◆ postUninit()

void BufferedVideoReader::postUninit ( )
overrideprotectedvirtual

◆ run()

void BufferedVideoReader::run ( )
protected

Friends And Related Symbol 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: