JeVois  1.0
JeVois Smart Embedded Machine Vision Toolkit
VideoDisplay.H
Go to the documentation of this file.
1 // ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2 //
3 // JeVois Smart Embedded Machine Vision Toolkit - Copyright (C) 2016 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 
21 #include <jevois/Core/VideoBuf.H>
23 #include <jevois/Image/RawImage.H>
24 #include <vector>
25 #include <memory>
26 #include <atomic>
27 
28 namespace jevois
29 {
30  //! Video output to local screen
31  /*! This class is useful for debugging machine vision code on a desktop computer as opposed to the JeVois
32  hardware. Images are simply displayed on the local screen. Engine instantiates a VideoDisplay in place of Gadget
33  if the provided Gadget device name is empty. \ingroup core */
34  class VideoDisplay : public VideoOutput
35  {
36  public:
37  //! Constructor
38  VideoDisplay(char const * displayname, size_t nbufs = 2);
39 
40  //! Virtual destructor for safe inheritance
41  virtual ~VideoDisplay();
42 
43  //! Set the video format and frame rate, allocate the buffers
44  void setFormat(VideoMapping const & m) override;
45 
46  //! Get a pre-allocated image so that we can fill the pixel data and later send out using send()
47  void get(RawImage & img) override;
48 
49  //! Send an image out to display
50  void send(RawImage const & img) override;
51 
52  //! Start streaming
53  void streamOn() override;
54 
55  //! Abort streaming
56  /*! This only cancels future get() and done() calls, one should still call streamOff() to turn off streaming. */
57  void abortStream() override;
58 
59  //! Stop streaming
60  void streamOff() override;
61 
62  private:
63  std::vector<std::shared_ptr<VideoBuf> > itsBuffers;
65  std::string const itsName;
66  };
67 }
68 
Thread-safe synchronized producer/consumer queue.
Definition: BoundedBuffer.H:37
virtual ~VideoDisplay()
Virtual destructor for safe inheritance.
Definition: VideoDisplay.C:72
void setFormat(VideoMapping const &m) override
Set the video format and frame rate, allocate the buffers.
Definition: VideoDisplay.C:40
void abortStream() override
Abort streaming.
Definition: VideoDisplay.C:155
void streamOff() override
Stop streaming.
Definition: VideoDisplay.C:159
A raw image as coming from a V4L2 Camera and/or being sent out to a USB Gadget.
Definition: RawImage.H:110
Simple struct to hold video mapping definitions for the processing Engine.
Definition: VideoMapping.H:41
void streamOn() override
Start streaming.
Definition: VideoDisplay.C:151
VideoDisplay(char const *displayname, size_t nbufs=2)
Constructor.
Definition: VideoDisplay.C:31
Video output to local screen.
Definition: VideoDisplay.H:34
void send(RawImage const &img) override
Send an image out to display.
Definition: VideoDisplay.C:99
Base class for video output. Gadget, MovieOutput, VideoDisplay, and VideoOutputNone derive from it...
Definition: VideoOutput.H:27