JeVoisBase
1.22
JeVois Smart Embedded Machine Vision Toolkit Base Modules
|
|
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>
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 ¶mdescriptor, T const &val) |
void | setParamValUnique (std::string const ¶mdescriptor, T const &val) |
std::vector< std::pair< std::string, T > > | getParamVal (std::string const ¶mdescriptor) const |
T | getParamValUnique (std::string const ¶mdescriptor) const |
std::vector< std::string > | setParamString (std::string const ¶mdescriptor, std::string const &val) |
void | setParamStringUnique (std::string const ¶mdescriptor, std::string const &val) |
std::vector< std::pair< std::string, std::string > > | getParamString (std::string const ¶mdescriptor) const |
std::string | getParamStringUnique (std::string const ¶mdescriptor) const |
void | freezeParam (std::string const ¶mdescriptor, 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 ¶mdescriptor, T const &val) |
void | setParamValUnique (std::string const ¶mdescriptor, T const &val) |
std::vector< std::pair< std::string, T > > | getParamVal (std::string const ¶mdescriptor) const |
T | getParamValUnique (std::string const ¶mdescriptor) const |
std::vector< std::string > | setParamString (std::string const ¶mdescriptor, std::string const &val) |
void | setParamStringUnique (std::string const ¶mdescriptor, std::string const &val) |
std::vector< std::pair< std::string, std::string > > | getParamString (std::string const ¶mdescriptor) const |
std::string | getParamStringUnique (std::string const ¶mdescriptor) const |
void | freezeParam (std::string const ¶mdescriptor, 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. | |
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.
BufferedVideoReader::BufferedVideoReader | ( | std::string const & | instance, |
size_t | bufsize = 100 |
||
) |
Constructor.
Definition at line 22 of file BufferedVideoReader.C.
BufferedVideoReader::~BufferedVideoReader | ( | ) |
Virtual destructor for safe inheritance.
Definition at line 27 of file BufferedVideoReader.C.
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().
|
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().
|
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< typename T, BlockingBehavior WhenFull, BlockingBehavior WhenEmpty >::filled_size(), JEVOIS_WAIT_GET_FUTURE, and jevois::BoundedBuffer< typename T, BlockingBehavior WhenFull, BlockingBehavior WhenEmpty >::pop().
|
protected |
Reader thread.
Definition at line 61 of file BufferedVideoReader.C.
References jevois::Component::absolutePath(), LERROR, and jevois::BoundedBuffer< typename T, BlockingBehavior WhenFull, BlockingBehavior WhenEmpty >::push().
Referenced by postInit().
|
related |
Parameter.