JeVois  1.20
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...
 
virtual bool hasScaledImage () const override
 Check whether a second input image scaled by the JeVoisPro Platform ISP is available. More...
 
virtual void get2 (RawImage &img) override
 Get the next captured ISP-scaled secondary buffer. More...
 
void done (RawImage &img) override
 Indicate that user processing is done with an image previously obtained via get() More...
 
void done2 (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...
 

Protected Attributes

cv::VideoCapture itsCap
 Our OpenCV video capture, works on movie and image files too. More...
 
cv::Mat itsRawFrame
 Raw OpenCV frame last captured, before any resizing or conversion. More...
 
std::shared_ptr< VideoBufitsBuf
 Our single video buffer for the main frame. More...
 
std::shared_ptr< VideoBufitsBuf2
 Our single video buffer for the second (processing) frame. 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 169 of file MovieInput.C.

◆ done2()

void jevois::MovieInput::done2 ( 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.

Reimplemented from jevois::VideoInput.

Definition at line 177 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 57 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.

◆ get2()

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

Get the next captured ISP-scaled secondary buffer.

On JeVois-Pro Platform only, the camera ISP can output 2 frames: 1) raw from sensor, 2) scaled by ISP. This function is to access the ISP scaled frame. Throws if not JeVois-Pro Platform or the camera crop type is not jevois::CropType::CropScale. Throws if we are not streaming or blocks until an image is available (has been captured). The image img should have been allocated by the caller and will be filled in by what we receive from the device here. Default implementation throws.

Reimplemented from jevois::VideoInput.

Definition at line 116 of file MovieInput.C.

References jevois::RawImage::buf, jevois::RawImage::bufindex, jevois::rawimage::convertCvBGRtoRawImage(), jevois::RawImage::fmt, jevois::RawImage::fps, jevois::imu::get(), jevois::RawImage::height, 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 192 of file MovieInput.C.

◆ hasScaledImage()

bool jevois::MovieInput::hasScaledImage ( ) const
overridevirtual

Check whether a second input image scaled by the JeVoisPro Platform ISP is available.

Returns false unless we are on JeVois-Pro Platform and the camera format modifier jevois::CropType::CropScale is currently in use.

Reimplemented from jevois::VideoInput.

Definition at line 51 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 184 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 188 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 196 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 200 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 for the main frame.

Definition at line 104 of file MovieInput.H.

◆ itsBuf2

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

Our single video buffer for the second (processing) frame.

Definition at line 105 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 102 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 106 of file MovieInput.H.

◆ itsRawFrame

cv::Mat jevois::MovieInput::itsRawFrame
protected

Raw OpenCV frame last captured, before any resizing or conversion.

Definition at line 103 of file MovieInput.H.


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