JeVoisBase
1.22
JeVois Smart Embedded Machine Vision Toolkit Base Modules
|
|
Save captured camera frames into a video file. More...
Public Member Functions | |
SaveVideo (std::string const &instance) | |
Constructor. | |
void | postInit () override |
Get started. | |
void | postUninit () override |
Get stopped. | |
virtual | ~SaveVideo () |
Virtual destructor for safe inheritance. | |
void | process (jevois::InputFrame &&inframe, jevois::OutputFrame &&outframe) override |
Processing function, version that also shows a debug video output. | |
void | process (jevois::InputFrame &&inframe) override |
Processing function, version with no video output. | |
virtual void | process (jevois::InputFrame &&inframe, jevois::GUIhelper &helper) override |
Processing function with zero-copy and GUI on JeVois-Pro. | |
void | parseSerial (std::string const &str, std::shared_ptr< jevois::UserInterface >) override |
Receive a string from a serial port which contains a user command. | |
void | supportedCommands (std::ostream &os) override |
Human-readable description of this Module's supported custom commands. | |
Public Member Functions inherited from jevois::Module | |
Module (std::string const &instance) | |
virtual | ~Module () |
virtual void | sendSerial (std::string const &str) |
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 | |
void | run () |
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 () |
Protected Attributes | |
std::future< void > | itsRunFut |
jevois::BoundedBuffer< cv::Mat, jevois::BlockingBehavior::Block, jevois::BlockingBehavior::Block > | itsBuf |
std::atomic< bool > | itsSaving |
int | itsFileNum |
std::atomic< bool > | itsRunning |
std::string | itsFilename |
Related Symbols | |
(Note that these are not member symbols.) | |
JEVOIS_DECLARE_PARAMETER (filename, std::string, "Name of the video file to write. If path is not absolute, " PATHPREFIX " will be prepended to it. Name should contain a printf-like directive for " "one int argument, which will start at 0 and be incremented on each streamoff command.", "video%06d.avi", ParamCateg) | |
Parameter. | |
JEVOIS_DECLARE_PARAMETER (fourcc, std::string, "FourCC of the codec to use. The OpenCV VideoWriter doc is unclear " "as to which codecs are supported. Presumably, the ffmpeg library is used inside OpenCV. " "Hence any video encoder supported by ffmpeg should work. Tested codecs include: MJPG, " "MP4V, AVC1. Make sure you also pick the right filename extension (e.g., .avi for MJPG, " ".mp4 for MP4V, etc)", "X264", boost::regex("^\\w{4}$"), ParamCateg) | |
Parameter. | |
JEVOIS_DECLARE_PARAMETER (fps, double, "Video frames/sec as stored in the file and to be used both for recording and " "playback. Beware that the video writer will drop frames if you are capturing faster than " "the frame rate specified here. For example, if capturing at 120fps, be sure to set this " "parameter to 120, otherwise by default the saved video will be at 30fps even though capture " "was running at 120fps.", 30.0, ParamCateg) | |
Parameter. | |
Save captured camera frames into a video file.
This module records video and saves it to the MicroSD card inside the JeVois smart camera. It is useful, for example, to record footage that will be used to train some machine vision algorithm.
Issue the command start
over the command-line interface to start saving video frames, and stop
to stop saving. Successive start/stop commands will increment the file number (d argument in the filename
parameter. Before a file is written, the module checks whether it already exists, and, if so, skips over it by incrementing the file number. See Command-line interface user guide for details on how to use the command-line interface.
This module works with any video resolution and pixel format supported by the camera sensor. Thus, additional video mappings are possible beyond the ones listed here.
See Advanced topic: Image pixel formats for information about pixel formats; with this module you can use the formats supported by the camera sensor.
This module accepts any resolution supported by the JeVois camera sensor.
This module can operate both with USB/GUI video output, or no USB video output.
When using with no USB/GUI output (NONE output format), you should first issue a streamon
command to start video streaming by the camera sensor chip, then issue a start
when you are ready to start recording. The streamon
is not necessary when using a video mapping with USB video output, as the host computer over USB triggers video streaming when it starts grabbing frames from the JeVois camera.
This module internally uses the OpenCV VideoWriter class to compress and write the video file. See the OpenCV documentation for which video formats are supported.
You should be aware of two things when attempting video recording at high frame rates:
fps
parameter should be set to the rate at which you want to save video. If you capture at 60 frames/s according to your video mapping but fps
is set to 30, saving will be at 30 fps. This limitation of rate is done internally by the OpenCV VideoWriter. So just make sure that you set the fps
parameter to the rate at which you want to save.Note that this module may suffer from DMA coherency artifacts if the camturbo
parameter of the jevois::Engine is turned on, which it is by default. The camturbo
parameter relaxes some of the cache coherency constraints on the video buffers captured by the camera sensor, which allows the JeVois processor to access video pixel data from memory faster. But with modules that do not do much processing, sometimes this yields video artifacts, we presume because some of the video data from previous frames still is in the CPU cache and hence is not again fetched from main memory by the CPU. If you see short stripes of what appears to be wrong pixel colors in the video, try to disable camturbo:
edit JEVOIS:/config/params.cfg on your MicroSD card and in there turn camturbo
to false.
Connect to the JeVois command-line interface (see Command-line interface user guide), and issue
setmapping2 YUYV 640 480 30.0 JeVois SaveVideo streamon start
and you will be saving compressed video with 640x480 at 30fps to your microSD card inside JeVois. When you are done, just issue:
stop
and the video file will be finalized and closed. If you want to access it directly by exporting the microSD inside JeVois as a virtual USB flash drive, issue (with JeVois v1.3 and later):
streamoff
to stop camera sensor streaming, and
usbsd
to export the microSD as a virtual USB flash drive. The video file(s) will be in the JEVOIS:/data/savevideo/ folder. You can then use the recorded video to test and debug a new algorithm using your host computer, by running jevois-daemon
on the host computer with a video file input as opposed to a live camera input, as follows:
jevois-daemon --cameradev=myvideo.avi --videomapping=num
where you replace num above by the video mapping you want to use. See The jevois-daemon executable for more info about the cameradev
parameter.
Definition at line 179 of file SaveVideo.C.
|
inline |
Constructor.
Definition at line 186 of file SaveVideo.C.
|
inlinevirtual |
Virtual destructor for safe inheritance.
Definition at line 223 of file SaveVideo.C.
|
inlineoverridevirtual |
Receive a string from a serial port which contains a user command.
Reimplemented from jevois::Module.
Definition at line 344 of file SaveVideo.C.
References jevois::BoundedBuffer< typename T, BlockingBehavior WhenFull, BlockingBehavior WhenEmpty >::filled_size(), itsBuf, itsSaving, LERROR, LINFO, jevois::BoundedBuffer< typename T, BlockingBehavior WhenFull, BlockingBehavior WhenEmpty >::push(), and jevois::Module::sendSerial().
|
inlineoverridevirtual |
Get started.
Reimplemented from jevois::Component.
Definition at line 193 of file SaveVideo.C.
References jevois::async(), itsRunFut, itsRunning, and run().
|
inlineoverridevirtual |
Get stopped.
Reimplemented from jevois::Component.
Definition at line 204 of file SaveVideo.C.
References jevois::BoundedBuffer< typename T, BlockingBehavior WhenFull, BlockingBehavior WhenEmpty >::filled_size(), itsBuf, itsFilename, itsRunFut, itsRunning, LERROR, LINFO, jevois::BoundedBuffer< typename T, BlockingBehavior WhenFull, BlockingBehavior WhenEmpty >::push(), and jevois::warnAndIgnoreException().
|
inlineoverridevirtual |
Processing function, version with no video output.
Reimplemented from jevois::Module.
Definition at line 263 of file SaveVideo.C.
References jevois::rawimage::convertToCvBGR(), jevois::BoundedBuffer< typename T, BlockingBehavior WhenFull, BlockingBehavior WhenEmpty >::filled_size(), itsBuf, itsSaving, LERROR, and jevois::BoundedBuffer< typename T, BlockingBehavior WhenFull, BlockingBehavior WhenEmpty >::push().
|
inlineoverridevirtual |
Processing function with zero-copy and GUI on JeVois-Pro.
Reimplemented from jevois::Module.
Definition at line 283 of file SaveVideo.C.
References jevois::rawimage::convertToCvBGR(), jevois::GUIhelper::drawInputFrame(), jevois::GUIhelper::endFrame(), jevois::BoundedBuffer< typename T, BlockingBehavior WhenFull, BlockingBehavior WhenEmpty >::filled_size(), jevois::GUIhelper::iinfo(), jevois::GUIhelper::itext(), itsBuf, itsFilename, itsSaving, jevois::BoundedBuffer< typename T, BlockingBehavior WhenFull, BlockingBehavior WhenEmpty >::push(), jevois::GUIhelper::reportError(), jevois::Timer::start(), jevois::GUIhelper::startFrame(), jevois::Timer::stop(), and jevois::GUIhelper::toggleButton().
|
inlineoverridevirtual |
Processing function, version that also shows a debug video output.
Reimplemented from jevois::Module.
Definition at line 229 of file SaveVideo.C.
References jevois::rawimage::convertToCvBGR(), jevois::BoundedBuffer< typename T, BlockingBehavior WhenFull, BlockingBehavior WhenEmpty >::filled_size(), h, jevois::RawImage::height, itsBuf, itsFilename, itsSaving, LERROR, jevois::rawimage::paste(), jevois::BoundedBuffer< typename T, BlockingBehavior WhenFull, BlockingBehavior WhenEmpty >::push(), jevois::RawImage::require(), jevois::yuyv::White, jevois::RawImage::width, and jevois::rawimage::writeText().
|
inlineprotected |
Definition at line 384 of file SaveVideo.C.
References itsBuf, itsFilename, itsFileNum, itsRunning, LERROR, LFATAL, LINFO, PATHPREFIX, jevois::BoundedBuffer< typename T, BlockingBehavior WhenFull, BlockingBehavior WhenEmpty >::pop(), jevois::Module::sendSerial(), and jevois::sformat().
Referenced by postInit().
|
inlineoverridevirtual |
Human-readable description of this Module's supported custom commands.
Reimplemented from jevois::Module.
Definition at line 377 of file SaveVideo.C.
|
related |
Parameter.
|
related |
Parameter.
|
related |
Parameter.
|
protected |
Definition at line 448 of file SaveVideo.C.
Referenced by parseSerial(), postUninit(), process(), process(), process(), and run().
|
protected |
Definition at line 452 of file SaveVideo.C.
Referenced by postUninit(), process(), process(), and run().
|
protected |
Definition at line 450 of file SaveVideo.C.
Referenced by run().
|
protected |
Definition at line 447 of file SaveVideo.C.
Referenced by postInit(), and postUninit().
|
protected |
Definition at line 451 of file SaveVideo.C.
Referenced by postInit(), postUninit(), and run().
|
protected |
Definition at line 449 of file SaveVideo.C.
Referenced by parseSerial(), process(), process(), and process().