22#include <linux/videodev2.h>
25#ifndef JEVOIS_PLATFORM_A33
26#include <opencv2/core/core.hpp>
27#include <opencv2/highgui/highgui.hpp>
28#include <opencv2/imgproc/imgproc.hpp>
32 jevois::VideoOutput(), itsImageQueue(std::max(size_t(2), nbufs)), itsName(displayname)
35 cv::namedWindow(itsName, cv::WINDOW_AUTOSIZE);
44 itsImageQueue.clear();
45 size_t const nbufs = itsImageQueue.size();
48 unsigned int imsize = m.
osize();
50 for (
size_t i = 0; i < nbufs; ++i)
52 itsBuffers.push_back(std::make_shared<jevois::VideoBuf>(-1, imsize, 0, -1));
59 img.
buf = itsBuffers[i];
63 itsImageQueue.push(img);
66 LDEBUG(
"Allocated " << nbufs <<
" buffers");
69 cv::namedWindow(itsName, cv::WINDOW_AUTOSIZE);
76 for (
auto & b : itsBuffers)
78 if (b.use_count() > 1)
LERROR(
"Ref count non zero when attempting to free VideoBuf");
87 cv::destroyWindow(itsName);
95 img = itsImageQueue.pop();
96 LDEBUG(
"Empty image " << img.
bufindex <<
" handed over to application code for filling");
108 case V4L2_PIX_FMT_YUYV:
111 cv::cvtColor(imgcv, imgbgr, cv::COLOR_YUV2BGR_YUYV);
115 case V4L2_PIX_FMT_GREY:
118 cv::cvtColor(imgcv, imgbgr, cv::COLOR_GRAY2BGR);
122 case V4L2_PIX_FMT_SRGGB8:
125 cv::cvtColor(imgcv, imgbgr, cv::COLOR_BayerBG2BGR);
129 case V4L2_PIX_FMT_RGB565:
132 cv::cvtColor(imgcv, imgbgr, cv::COLOR_BGR5652BGR);
136 default:
LFATAL(
"Unsupported video format");
140 cv::imshow(itsName, imgbgr);
147 itsImageQueue.push(img);
148 LDEBUG(
"Empty image " << img.
bufindex <<
" ready for filling in by application code");
168 itsImageQueue(nbufs), itsName(displayname)
169{
LFATAL(
"VideoDisplay is not supported on JeVois hardware platform"); }
172{
LERROR(
"VideoDisplay is not supported on JeVois hardware platform"); }
175{
LFATAL(
"VideoDisplay is not supported on JeVois hardware platform"); }
178{
LFATAL(
"VideoDisplay is not supported on JeVois hardware platform"); }
181{
LFATAL(
"VideoDisplay is not supported on JeVois hardware platform"); }
184{
LFATAL(
"VideoDisplay is not supported on JeVois hardware platform"); }
187{
LFATAL(
"VideoDisplay is not supported on JeVois hardware platform"); }
190{
LFATAL(
"VideoDisplay is not supported on JeVois hardware platform"); }
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.
void streamOff() override
Stop streaming.
virtual ~VideoDisplay()
Virtual destructor for safe inheritance.
void abortStream() override
Abort streaming.
void send(RawImage const &img) override
Send an image out to display.
void setFormat(VideoMapping const &m) override
Set the video format and frame rate, allocate the buffers.
void streamOn() override
Start streaming.
void get(RawImage &img) override
Get a pre-allocated image so that we can fill the pixel data and later send out using send()
VideoDisplay(char const *displayname, size_t nbufs=2)
Constructor.
#define LFATAL(msg)
Convenience macro for users to print out console or syslog messages, FATAL level.
#define LDEBUG(msg)
Convenience macro for users to print out console or syslog messages, DEBUG level.
#define LERROR(msg)
Convenience macro for users to print out console or syslog messages, ERROR level.
Main namespace for all JeVois classes and functions.
Simple struct to hold video mapping definitions for the processing Engine.
unsigned int ow
output width
unsigned int osize() const
Return the size in bytes of an output image.
float ofps
output frame rate in frames/sec
unsigned int oh
output height
unsigned int ofmt
output pixel format, or 0 for no output over USB