JeVois  1.0
JeVois Smart Embedded Machine Vision Toolkit
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 save inheritance. More...
 
virtual void streamOn () override
 Start streaming. More...
 
virtual void abortStream () override
 Abort streaming. More...
 
virtual void streamOff () override
 Stop streaming. More...
 
virtual void get (RawImage &img) override
 Get the next frame from the video file, possibly looping back to start if end is reached. More...
 
virtual void done (RawImage &img) override
 Indicate that user processing is done with an image previously obtained via get() More...
 
virtual void queryControl (struct v4l2_queryctrl &qc) const override
 Get information about a control, throw if unsupported by hardware. More...
 
virtual 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...
 
virtual void getControl (struct v4l2_control &ctrl) const override
 Get a control's current value, throw if unsupported by hardware. More...
 
virtual void setControl (struct v4l2_control const &ctrl) override
 Set a control, throw if the hardware rejects the value. More...
 
virtual void setFormat (VideoMapping const &m) override
 Set the video format and frame rate. More...
 
virtual void writeRegister (unsigned char reg, unsigned char val) override
 Write a value of one of the camera's registers. More...
 
virtual unsigned char readRegister (unsigned char reg) override
 Read a value from one of the camera's registers. 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...
 

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
std::string const itsDevName
 Our device or movie file name. More...
 
unsigned int const itsNbufs
 Our number of buffers. More...
 

Constructor & Destructor Documentation

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.

jevois::MovieInput::~MovieInput ( )
virtual

Virtual destructor for save inheritance.

Definition at line 35 of file MovieInput.C.

Member Function Documentation

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.

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 91 of file MovieInput.C.

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::height, LFATAL, LINFO, and jevois::RawImage::width.

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 106 of file MovieInput.C.

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 98 of file MovieInput.C.

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

unsigned char jevois::MovieInput::readRegister ( unsigned char  reg)
overridevirtual

Read a value from one of the camera's registers.

In MovieInput, this just throws an std::runtime_error

Implements jevois::VideoInput.

Definition at line 125 of file MovieInput.C.

References LFATAL.

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 110 of file MovieInput.C.

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 114 of file MovieInput.C.

void jevois::MovieInput::streamOff ( )
overridevirtual

Stop streaming.

Implements jevois::VideoInput.

Definition at line 47 of file MovieInput.C.

void jevois::MovieInput::streamOn ( )
overridevirtual

Start streaming.

Implements jevois::VideoInput.

Definition at line 39 of file MovieInput.C.

void jevois::MovieInput::writeRegister ( unsigned char  reg,
unsigned char  val 
)
overridevirtual

Write a value of one of the camera's registers.

In MovieInput, this just throws an std::runtime_error

Implements jevois::VideoInput.

Definition at line 121 of file MovieInput.C.

References LFATAL.

Member Data Documentation

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

Our single video buffer.

Definition at line 93 of file MovieInput.H.

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

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

Definition at line 92 of file MovieInput.H.

Referenced by MovieInput().

VideoMapping jevois::MovieInput::itsMapping
protected

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

Definition at line 94 of file MovieInput.H.


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