JeVois  1.22
JeVois Smart Embedded Machine Vision Toolkit
Share this page:
Loading...
Searching...
No Matches
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.
 
virtual ~MovieOutput ()
 Virtual destructor for safe inheritance.
 
virtual void setFormat (VideoMapping const &m) override
 Set the video format and frame rate.
 
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()
 
virtual void send (RawImage const &img) override
 Send an image out.
 
virtual void streamOn () override
 Start streaming.
 
virtual void abortStream () override
 Abort streaming.
 
virtual void streamOff () override
 Stop streaming.
 
- Public Member Functions inherited from jevois::VideoOutput
virtual ~VideoOutput ()
 Virtual destructor for safe inheritance.
 

Protected Member Functions

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

Protected Attributes

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

Constructor & Destructor Documentation

◆ MovieOutput()

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

Constructor.

Definition at line 32 of file MovieOutput.C.

References jevois::async(), itsRunFut, and run().

◆ ~MovieOutput()

jevois::MovieOutput::~MovieOutput ( )
virtual

Virtual destructor for safe inheritance.

Definition at line 39 of file MovieOutput.C.

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

Member Function Documentation

◆ abortStream()

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 102 of file MovieOutput.C.

◆ get()

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 63 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.

◆ run()

void jevois::MovieOutput::run ( )
protected

Use a thread to encode and save frames.

Definition at line 127 of file MovieOutput.C.

References LERROR, LFATAL, and LINFO.

Referenced by MovieOutput().

◆ send()

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 81 of file MovieOutput.C.

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

◆ setFormat()

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

Set the video format and frame rate.

Implements jevois::VideoOutput.

Definition at line 56 of file MovieOutput.C.

◆ streamOff()

void jevois::MovieOutput::streamOff ( )
overridevirtual

Stop streaming.

Implements jevois::VideoOutput.

Definition at line 108 of file MovieOutput.C.

References LERROR, and LINFO.

◆ streamOn()

void jevois::MovieOutput::streamOn ( )
overridevirtual

Start streaming.

Implements jevois::VideoOutput.

Definition at line 96 of file MovieOutput.C.

Member Data Documentation

◆ itsBuf

Buffer of frames to encode and write to file.

Definition at line 71 of file MovieOutput.H.

◆ itsBuffer

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

Our single video buffer.

Definition at line 65 of file MovieOutput.H.

◆ itsFilebase

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

Current file base to save video to.

Definition at line 76 of file MovieOutput.H.

◆ itsFilename

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

Current file name to save video to.

Definition at line 75 of file MovieOutput.H.

◆ itsFileNum

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.

◆ itsMapping

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.

◆ itsRunFut

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

Future for our run() thread.

Definition at line 69 of file MovieOutput.H.

Referenced by MovieOutput().

◆ itsRunning

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

True when our run() thread should keep running.

Definition at line 74 of file MovieOutput.H.

◆ itsSaving

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: