23#include <opencv2/videoio.hpp>
24#include <opencv2/imgproc/imgproc.hpp>
31 if (
itsCap.open(filename) ==
false)
LFATAL(
"Failed to open movie or image sequence [" << filename <<
']');
53 return (itsMapping.c2fmt != 0);
59 static size_t frameidx = 0;
66 img.
width = itsMapping.cw;
67 img.
height = itsMapping.ch;
68 img.
fmt = itsMapping.cfmt;
69 img.
fps = itsMapping.cfps;
77 if (itsCap.read(itsRawFrame) ==
false)
79 LINFO(
"End of input - Rewinding...");
82 itsCap.set(cv::CAP_PROP_POS_AVI_RATIO, 0);
83 itsCap.set(cv::CAP_PROP_POS_FRAMES, 0);
86 if (itsCap.read(itsRawFrame) ==
false)
LFATAL(
"Could not read next video frame");
91 if (itsRawFrame.cols !=
int(itsMapping.cw) || itsRawFrame.rows !=
int(itsMapping.ch))
93 if ((frameidx++ % 100) == 0)
94 LINFO(
"Note: Resizing get() frame from " << itsRawFrame.cols <<
'x'<< itsRawFrame.rows <<
" to " <<
95 itsMapping.cw <<
'x'<< itsMapping.ch);
96 cv::resize(itsRawFrame, frame, cv::Size(itsMapping.cw, itsMapping.ch));
98 else frame = itsRawFrame;
104 img.
width = itsMapping.cw;
105 img.
height = itsMapping.ch;
106 img.
fmt = itsMapping.cfmt;
107 img.
fps = itsMapping.cfps;
118 static size_t frameidx2 = 0;
125 img.
width = itsMapping.c2w;
126 img.
height = itsMapping.c2h;
127 img.
fmt = itsMapping.c2fmt;
128 img.
fps = itsMapping.cfps;
144 if (itsRawFrame.cols !=
int(itsMapping.c2w) || itsRawFrame.rows !=
int(itsMapping.c2h))
146 if ((frameidx2++ % 100) == 0)
147 LINFO(
"Note: Resizing get2() frame from " << itsRawFrame.cols <<
'x'<< itsRawFrame.rows <<
" to " <<
148 itsMapping.c2w <<
'x'<< itsMapping.c2h);
149 cv::resize(itsRawFrame, frame, cv::Size(itsMapping.c2w, itsMapping.c2h));
151 else frame = itsRawFrame;
157 img.
width = itsMapping.c2w;
158 img.
height = itsMapping.c2h;
159 img.
fmt = itsMapping.c2fmt;
160 img.
fps = itsMapping.cfps;
173 itsRawFrame = cv::Mat();
185{
throw std::runtime_error(
"Operation queryControl() not supported by MovieInput"); }
189{
throw std::runtime_error(
"Operation queryMenu() not supported by MovieInput"); }
193{
throw std::runtime_error(
"Operation getControl() not supported by MovieInput"); }
197{
throw std::runtime_error(
"Operation setControl() not supported by MovieInput"); }
A raw image as coming from a V4L2 Camera and/or being sent out to a USB Gadget.
float fps
Programmed frames/s as given by current video mapping, may not be actual.
unsigned int fmt
Pixel format as a V4L2_PIX_FMT_XXX.
size_t bufindex
The index of the data buffer in the kernel driver.
unsigned int width
Image width in pixels.
unsigned int height
Image height in pixels.
std::shared_ptr< VideoBuf > buf
The pixel data buffer.
A V4L2 video buffer, to be held in a shared_ptr.
#define LFATAL(msg)
Convenience macro for users to print out console or syslog messages, FATAL level.
#define LINFO(msg)
Convenience macro for users to print out console or syslog messages, INFO level.
void convertCvBGRtoRawImage(cv::Mat const &src, RawImage &dst, int quality)
Convert a BGR cv::Mat to RawImage with already-allocated pixels and pixel type.
Main namespace for all JeVois classes and functions.
Simple struct to hold video mapping definitions for the processing Engine.