JeVois  1.21
JeVois Smart Embedded Machine Vision Toolkit
Share this page:
Loading...
Searching...
No Matches
VideoDisplayGL.H
Go to the documentation of this file.
1// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2//
3// JeVois Smart Embedded Machine Vision Toolkit - Copyright (C) 2020 by Laurent Itti, the University of Southern
4// California (USC), and iLab at USC. See http://iLab.usc.edu and http://jevois.org for information about this project.
5//
6// This file is part of the JeVois Smart Embedded Machine Vision Toolkit. This program is free software; you can
7// redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software
8// Foundation, version 2. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
9// without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
10// License for more details. You should have received a copy of the GNU General Public License along with this program;
11// if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
12//
13// Contact information: Laurent Itti - 3641 Watt Way, HNB-07A - Los Angeles, CA 90089-2520 - USA.
14// Tel: +1 213 740 3527 - itti@pollux.usc.edu - http://iLab.usc.edu - http://jevois.org
15// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
16/*! \file */
17
18#pragma once
19
20// This is only available on JeVoisPro
21#ifdef JEVOIS_PRO
22
26#include <jevois/GPU/GPUimage.H>
29#include <vector>
30#include <atomic>
31
32namespace jevois
33{
34 //! Video output to local screen
35 /*! This class provides accelerated OpenGL-ES display on JeVois-Pro platform. It only works on JeVois-Pro and creates
36 fatal errors on other host or platform configs. Images are simply displayed on the local screen using
37 OpenGL-ES.
38
39 Here is the basic theory of operation:
40
41 - When running on host, we open an X11 window; on platform, we instead use fbdev.
42 - When the first video frame arrives, we then initialize OpenGL and create 2 triangles that will be rendered in
43 the whole window. The reason for this is to avoid threading issues (so OpenGL is initialized in the same thread
44 as rendering calls will be made). We also initialize a texture of the same size as the incoming image. We
45 finally create a surface of same size as the window or fbdev. We then load a compile shaders to render our
46 texture into our surface.
47 - On every frame, we just update the texture's pixel location and render the scene.
48
49 \ingroup core */
51 {
52 public:
53 //! Constructor
54 VideoDisplayGL(size_t nbufs = 2);
55
56 //! Virtual destructor for safe inheritance
57 virtual ~VideoDisplayGL();
58
59 //! Set the video format and frame rate, allocate the buffers
60 virtual void setFormat(VideoMapping const & m) override;
61
62 //! Get a pre-allocated image so that we can fill the pixel data and later send out using send()
63 virtual void get(RawImage & img) override;
64
65 //! Send an image out to display
66 virtual void send(RawImage const & img) override;
67
68 //! Start streaming
69 virtual void streamOn() override;
70
71 //! Abort streaming
72 /*! This only cancels future get() and done() calls, one should still call streamOff() to turn off streaming. */
73 virtual void abortStream() override;
74
75 //! Stop streaming
76 virtual void streamOff() override;
77
78 protected:
79 std::vector<std::shared_ptr<VideoBuf> > itsBuffers;
82
83#ifdef JEVOIS_PLATFORM_PRO
85#else
86 VideoDisplayBackendX11 itsBackend;
87#endif
88 std::atomic<bool> itsStreaming;
89 };
90}
91
92#endif // JEVOIS_PRO
Thread-safe synchronized producer/consumer queue.
Class to hold a GPUtexture, GPUprogram, and other data associated with rendering an image in OpenGL.
Definition GPUimage.H:39
A raw image as coming from a V4L2 Camera and/or being sent out to a USB Gadget.
Definition RawImage.H:111
Backend for VideoDisplay on JeVois-Pro host using MALI.
Video output to local screen.
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.
BoundedBuffer< RawImage, BlockingBehavior::Block, BlockingBehavior::Block > itsImageQueue
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()
VideoDisplayBackendMALI itsBackend
virtual void streamOn() override
Start streaming.
virtual void streamOff() override
Stop streaming.
std::vector< std::shared_ptr< VideoBuf > > itsBuffers
virtual void abortStream() override
Abort streaming.
std::atomic< bool > itsStreaming
Base class for video output. Gadget, MovieOutput, VideoDisplay, and VideoOutputNone derive from it.
Definition VideoOutput.H:28
Main namespace for all JeVois classes and functions.
Definition Concepts.dox:2
Simple struct to hold video mapping definitions for the processing Engine.