JeVois  1.16
JeVois Smart Embedded Machine Vision Toolkit
Share this page:
jevois::MovieInput Class Reference

#include <jevois/Core/MovieInput.H>

Movie input, can be used as a replacement for Camera to debug algorithms using a fixed video sequence.

The movie will be looped forever to provide continual input. This is a direct wrapper around the VideoCapture class of OpenCV, and it hence supports many different video file formats, and image sequences when the filename contains a printf-like d placeholder for a frame number. See OpenCV documentation for VideoCapture for more details.

Note that the movie frames will be resized to match the dimensions specified by setFormat() and will be converted to the pixel type specified in setFormat().

Definition at line 35 of file MovieInput.H.

Inheritance diagram for jevois::MovieInput:
Collaboration diagram for jevois::MovieInput:

Public Member Functions

 MovieInput (std::string const &filename, unsigned int const nbufs=3)
 Constructor, opens the movie file. More...
 
virtual ~MovieInput ()
 Virtual destructor for safe inheritance. More...
 
void streamOn () override
 Start streaming. More...
 
void abortStream () override
 Abort streaming. More...
 
void streamOff () override
 Stop streaming. More...
 
void get (RawImage &img) override
 Get the next frame from the video file, possibly looping back to start if end is reached. More...
 
void done (RawImage &img) override
 Indicate that user processing is done with an image previously obtained via get() More...
 
void queryControl (struct v4l2_queryctrl &qc) const override
 Get information about a control, throw if unsupported by hardware. More...
 
void queryMenu (struct v4l2_querymenu &qm) const override
 Get the available menu entry names for a menu-type control, throw if unsupported by hardware. More...
 
void getControl (struct v4l2_control &ctrl) const override
 Get a control's current value, throw if unsupported by hardware. More...
 
void setControl (struct v4l2_control const &ctrl) override
 Set a control, throw if the hardware rejects the value. More...
 
void setFormat (VideoMapping const &m) override
 Set the video format and frame rate. More...
 
- Public Member Functions inherited from jevois::VideoInput
 VideoInput (std::string const &devname, unsigned int const nbufs=0)
 Constructor. More...
 
virtual ~VideoInput ()
 Virtual destructor for save inheritance. More...
 
virtual bool hasScaledImage () const
 Check whether a second input image scaled by the JeVoisPro Platform ISP is available. More...
 
virtual void get2 (RawImage &img)
 Get the next captured ISP-scaled secondary buffer. More...
 
virtual void done2 (RawImage &img)
 Indicate that user processing is done with a second ISP-scaled image previously obtained via get2() More...
 

Protected Attributes

cv::VideoCapture itsCap
 Our OpenCV video capture, works on movie and image files too. More...
 
std::shared_ptr< VideoBufitsBuf
 Our single video buffer. More...
 
VideoMapping itsMapping
 Our current video mapping, we resize the input to the mapping's camera dims. More...
 
- Protected Attributes inherited from jevois::VideoInput
const std::string itsDevName
 Our device or movie file name. More...
 
unsigned const int itsNbufs
 Our number of buffers. More...
 

Constructor & Destructor Documentation

◆ MovieInput()

jevois::MovieInput::MovieInput ( std::string const &  filename,
unsigned int const  nbufs = 3 
)

Constructor, opens the movie file.

Definition at line 27 of file MovieInput.C.

References itsCap, and LFATAL.

◆ ~MovieInput()

jevois::MovieInput::~MovieInput ( )
virtual

Virtual destructor for safe inheritance.

Definition at line 35 of file MovieInput.C.

Member Function Documentation

◆ abortStream()

void jevois::MovieInput::abortStream ( )
overridevirtual

Abort streaming.

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

Implements jevois::VideoInput.

Definition at line 43 of file MovieInput.C.

◆ done()

void jevois::MovieInput::done ( RawImage img)
overridevirtual

Indicate that user processing is done with an image previously obtained via get()

You should call this as soon after get() as possible, once you are finished with the RawImage data so that it can be recycled. This also invalidates the image and in particular its pixel buffer.

Implements jevois::VideoInput.

Definition at line 92 of file MovieInput.C.

◆ get()

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

Get the next frame from the video file, possibly looping back to start if end is reached.

Implements jevois::VideoInput.

Definition at line 51 of file MovieInput.C.

References jevois::RawImage::buf, jevois::RawImage::bufindex, jevois::rawimage::convertCvBGRtoRawImage(), jevois::RawImage::fmt, jevois::RawImage::fps, jevois::RawImage::height, LFATAL, LINFO, and jevois::RawImage::width.

◆ getControl()

void jevois::MovieInput::getControl ( struct v4l2_control &  ctrl) const
overridevirtual

Get a control's current value, throw if unsupported by hardware.

In MovieInput, this just throws an std::runtime_error

Implements jevois::VideoInput.

Definition at line 107 of file MovieInput.C.

◆ queryControl()

void jevois::MovieInput::queryControl ( struct v4l2_queryctrl &  qc) const
overridevirtual

Get information about a control, throw if unsupported by hardware.

In MovieInput, this just throws an std::runtime_error

Implements jevois::VideoInput.

Definition at line 99 of file MovieInput.C.

◆ queryMenu()

void jevois::MovieInput::queryMenu ( struct v4l2_querymenu &  qm) const
overridevirtual

Get the available menu entry names for a menu-type control, throw if unsupported by hardware.

In MovieInput, this just throws an std::runtime_error

Implements jevois::VideoInput.

Definition at line 103 of file MovieInput.C.

◆ setControl()

void jevois::MovieInput::setControl ( struct v4l2_control const &  ctrl)
overridevirtual

Set a control, throw if the hardware rejects the value.

In MovieInput, this just throws an std::runtime_error

Implements jevois::VideoInput.

Definition at line 111 of file MovieInput.C.

◆ setFormat()

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

Set the video format and frame rate.

Video frames read from the input movie file will be rescaled (if necessary) to that format's resolution, and will be converted (if necessary) to that format's pixel type.

Implements jevois::VideoInput.

Definition at line 115 of file MovieInput.C.

◆ streamOff()

void jevois::MovieInput::streamOff ( )
overridevirtual

Stop streaming.

Implements jevois::VideoInput.

Definition at line 47 of file MovieInput.C.

◆ streamOn()

void jevois::MovieInput::streamOn ( )
overridevirtual

Start streaming.

Implements jevois::VideoInput.

Definition at line 39 of file MovieInput.C.

Member Data Documentation

◆ itsBuf

std::shared_ptr<VideoBuf> jevois::MovieInput::itsBuf
protected

Our single video buffer.

Definition at line 85 of file MovieInput.H.

◆ itsCap

cv::VideoCapture jevois::MovieInput::itsCap
protected

Our OpenCV video capture, works on movie and image files too.

Definition at line 84 of file MovieInput.H.

Referenced by MovieInput().

◆ itsMapping

VideoMapping jevois::MovieInput::itsMapping
protected

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

Definition at line 86 of file MovieInput.H.


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