JeVois  1.3
JeVois Smart Embedded Machine Vision Toolkit
Share this page:
jevois::MovieOutput Class Reference

#include <jevois/Core/MovieOutput.H>

Video output to a movie file, using OpenCV video encoding.

This video output mode saved output frames to a file (or series of files). It is useful when developing new algorithms to check the correctness of generated outputs offline, or to save some documentation/demo movies of a module.

Definition at line 33 of file MovieOutput.H.

Inheritance diagram for jevois::MovieOutput:
Collaboration diagram for jevois::MovieOutput:

Public Member Functions

 MovieOutput (std::string const &fn)
 Constructor. More...
 
virtual ~MovieOutput ()
 Virtual destructor for safe inheritance. More...
 
virtual void setFormat (VideoMapping const &m) override
 Set the video format and frame rate. More...
 
virtual void get (RawImage &img) override
 Get a pre-allocated image so that we can fill the pixel data and later send out using send() More...
 
virtual void send (RawImage const &img) override
 Send an image out. More...
 
virtual void streamOn () override
 Start streaming. More...
 
virtual void abortStream () override
 Abort streaming. More...
 
virtual void streamOff () override
 Stop streaming. More...
 
- Public Member Functions inherited from jevois::VideoOutput
virtual ~VideoOutput ()
 Virtual destructor for safe inheritance. More...
 

Protected Member Functions

void run ()
 Use a thread to encode and save frames. More...
 

Protected Attributes

std::shared_ptr< VideoBufitsBuffer
 Our single video buffer. More...
 
VideoMapping itsMapping
 Our current video mapping, we resize the input to the mapping's camera dims. More...
 
std::future< void > itsRunFut
 Future for our run() thread. More...
 
jevois::BoundedBuffer< cv::Mat, jevois::BlockingBehavior::Block, jevois::BlockingBehavior::BlockitsBuf
 Buffer of frames to encode and write to file. More...
 
std::atomic< bool > itsSaving
 True when we are saving to file. More...
 
int itsFileNum
 File number, gets incremented on each streamOff() to avoid overwriting previous files. More...
 
std::atomic< bool > itsRunning
 True when our run() thread should keep running. More...
 
std::string itsFilename
 Current file name to save video to. More...
 
std::string itsFilebase
 Current file base to save video to. More...
 

Constructor & Destructor Documentation

jevois::MovieOutput::MovieOutput ( std::string const &  fn)

Constructor.

Definition at line 31 of file MovieOutput.C.

References itsRunFut, and run().

jevois::MovieOutput::~MovieOutput ( )
virtual

Virtual destructor for safe inheritance.

Definition at line 38 of file MovieOutput.C.

References LERROR, LINFO, jevois::system(), and jevois::warnAndIgnoreException().

Member Function Documentation

void jevois::MovieOutput::abortStream ( )
overridevirtual

Abort streaming.

This only cancels future get() and send() calls, one should still call streamOff() to turn off streaming.

Implements jevois::VideoOutput.

Definition at line 101 of file MovieOutput.C.

void jevois::MovieOutput::get ( RawImage img)
overridevirtual

Get a pre-allocated image so that we can fill the pixel data and later send out using send()

May throw if not buffer is available, i.e., all have been queued to send but have not yet been sent. Application code must balance exactly one send() for each get().

Implements jevois::VideoOutput.

Definition at line 62 of file MovieOutput.C.

References jevois::RawImage::buf, jevois::RawImage::bufindex, jevois::RawImage::fmt, jevois::RawImage::fps, jevois::RawImage::height, LFATAL, and jevois::RawImage::width.

void jevois::MovieOutput::run ( )
protected

Use a thread to encode and save frames.

Definition at line 126 of file MovieOutput.C.

References LERROR, LFATAL, LINFO, and jevois::system().

Referenced by MovieOutput().

void jevois::MovieOutput::send ( RawImage const &  img)
overridevirtual

Send an image out.

May throw if the format is incorrect or std::overflow_error if we have not yet consumed the previous image.

Implements jevois::VideoOutput.

Definition at line 80 of file MovieOutput.C.

References jevois::rawimage::convertToCvBGR(), LERROR, and LFATAL.

void jevois::MovieOutput::setFormat ( VideoMapping const &  m)
overridevirtual

Set the video format and frame rate.

Implements jevois::VideoOutput.

Definition at line 55 of file MovieOutput.C.

void jevois::MovieOutput::streamOff ( )
overridevirtual

Stop streaming.

Implements jevois::VideoOutput.

Definition at line 107 of file MovieOutput.C.

References LERROR, LINFO, and jevois::system().

void jevois::MovieOutput::streamOn ( )
overridevirtual

Start streaming.

Implements jevois::VideoOutput.

Definition at line 95 of file MovieOutput.C.

Member Data Documentation

Buffer of frames to encode and write to file.

Definition at line 71 of file MovieOutput.H.

std::shared_ptr<VideoBuf> jevois::MovieOutput::itsBuffer
protected

Our single video buffer.

Definition at line 65 of file MovieOutput.H.

std::string jevois::MovieOutput::itsFilebase
protected

Current file base to save video to.

Definition at line 76 of file MovieOutput.H.

std::string jevois::MovieOutput::itsFilename
protected

Current file name to save video to.

Definition at line 75 of file MovieOutput.H.

int jevois::MovieOutput::itsFileNum
protected

File number, gets incremented on each streamOff() to avoid overwriting previous files.

Definition at line 73 of file MovieOutput.H.

VideoMapping jevois::MovieOutput::itsMapping
protected

Our current video mapping, we resize the input to the mapping's camera dims.

Definition at line 66 of file MovieOutput.H.

std::future<void> jevois::MovieOutput::itsRunFut
protected

Future for our run() thread.

Definition at line 69 of file MovieOutput.H.

Referenced by MovieOutput().

std::atomic<bool> jevois::MovieOutput::itsRunning
protected

True when our run() thread should keep running.

Definition at line 74 of file MovieOutput.H.

std::atomic<bool> jevois::MovieOutput::itsSaving
protected

True when we are saving to file.

Definition at line 72 of file MovieOutput.H.


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