JeVois  1.20
JeVois Smart Embedded Machine Vision Toolkit
Share this page:
ImGuiImage.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 #ifdef JEVOIS_PRO
21 
22 #include <jevois/GPU/OpenGL.H>
23 #include <opencv2/core.hpp>
24 #include <imgui.h>
25 
26 namespace jevois
27 {
28  //! Wrapper for an image that can be rendered into ImGui
29  /*! The wrapper combines an OpenCV image and an OpenGL texture. */
30  class ImGuiImage
31  {
32  public:
33  //! Constructor, image is uninitialized and loaded() returns false
34  ImGuiImage();
35 
36  //! Load from file
37  void load(std::string const & fname);
38 
39  //! Load from an OpenCV image
40  /*! Allocates a texture on the GPU for the image. */
41  void load(cv::Mat const & img, bool isbgr = true);
42 
43  //! Returns true if an image has been loaded through load()
44  bool loaded() const;
45 
46  //! Free the texture and revert to un-initialized state
47  void clear();
48 
49  //! Destructor
50  /*! Deletes the associated GPU texture and OpenCV pixel data. */
51  ~ImGuiImage();
52 
53  //! Draw into into current ImGui window or a drawlist
54  void draw(ImVec2 const & pos, ImVec2 const & size, ImDrawList * dl = nullptr);
55 
56  private:
57  GLuint itsId = 0;
58  };
59 } // namespace jevois
60 
61 #endif // JEVOIS_PRO
jevois::ImGuiImage::load
void load(std::string const &fname)
Load from file.
Definition: ImGuiImage.C:76
jevois::ImGuiImage
Wrapper for an image that can be rendered into ImGui.
Definition: ImGuiImage.H:30
OpenGL.H
jevois::ImGuiImage::draw
void draw(ImVec2 const &pos, ImVec2 const &size, ImDrawList *dl=nullptr)
Draw into into current ImGui window or a drawlist.
Definition: ImGuiImage.C:98
jevois
Definition: Concepts.dox:1
jevois::ImGuiImage::ImGuiImage
ImGuiImage()
Constructor, image is uninitialized and loaded() returns false.
Definition: ImGuiImage.C:27
jevois::ImGuiImage::~ImGuiImage
~ImGuiImage()
Destructor.
Definition: ImGuiImage.C:94
jevois::ImGuiImage::clear
void clear()
Free the texture and revert to un-initialized state.
Definition: ImGuiImage.C:88
jevois::ImGuiImage::loaded
bool loaded() const
Returns true if an image has been loaded through load()
Definition: ImGuiImage.C:84