24#include <glm/gtc/matrix_transform.hpp>
28 jevois::
VideoOutput(), itsImageQueue(std::max(size_t(2), nbufs)), itsStreaming(false)
35 itsStreaming.store(
false);
37 itsImageQueue.clear();
38 size_t const nbufs = itsImageQueue.size();
41 unsigned int imsize = m.
osize();
43 for (
size_t i = 0; i < nbufs; ++i)
45 itsBuffers.push_back(std::make_shared<jevois::VideoBuf>(-1, imsize, 0, -1));
52 img.
buf = itsBuffers[i];
56 itsImageQueue.push(img);
59 LDEBUG(
"Allocated " << nbufs <<
" buffers");
66 for (
auto & b : itsBuffers)
68 if (b.use_count() > 1)
LERROR(
"Ref count non zero when attempting to free VideoBuf");
78 if (itsStreaming.load() ==
false)
LFATAL(
"Not streaming");
81 img = itsImageQueue.pop();
82 LDEBUG(
"Empty image " << img.
bufindex <<
" handed over to application code for filling");
88 if (itsStreaming.load() ==
false)
LFATAL(
"Not streaming");
91 unsigned short winw, winh;
92 itsBackend.getWindowSize(winw, winh);
97 itsBackend.init(1920, 1080,
true);
98 itsBackend.getWindowSize(winw, winh);
102 itsBackend.newFrame();
105 bool shouldclose =
false; itsBackend.pollEvents(shouldclose);
109#ifdef JEVOIS_PLATFORM
111 static glm::mat4 pvm = glm::translate(glm::scale(glm::mat4(1.0f), glm::vec3(2.0f / winw, 2.0f / winh, 1.0f)),
112 glm::vec3(0.375f, 0.375f, 0.0f));
115 static glm::mat4 pvm = glm::scale(glm::mat4(1.0f), glm::vec3(2.0f / winw, 2.0f / winh, 1.0f));
120 int x = 0, y = 0;
unsigned short w = 0,
h = 0;
121 itsImage.draw(x, y, w,
h,
true, pvm);
128 itsImageQueue.push(img);
129 LDEBUG(
"Empty image " << img.
bufindex <<
" ready for filling in by application code");
134{ itsStreaming.store(
true); }
138{ itsStreaming.store(
false); }
142{ itsStreaming.store(
false); }
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.
virtual void setFormat(VideoMapping const &m) override
Set the video format and frame rate, allocate the buffers.
virtual void send(RawImage const &img) override
Send an image out to display.
virtual ~VideoDisplayGL()
Virtual destructor for safe inheritance.
virtual void get(RawImage &img) override
Get a pre-allocated image so that we can fill the pixel data and later send out using send()
virtual void streamOn() override
Start streaming.
virtual void streamOff() override
Stop streaming.
VideoDisplayGL(size_t nbufs=2)
Constructor.
virtual void abortStream() override
Abort streaming.
Base class for video output. Gadget, MovieOutput, VideoDisplay, and VideoOutputNone derive from it.
#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