JeVois  1.18
JeVois Smart Embedded Machine Vision Toolkit
Share this page:
GUIhelper.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 // To minimize the amount of ifdef junk in user code, define type alias OptGUIhelper here as either GUIhelper or void
21 namespace jevois
22 {
23 #ifdef JEVOIS_PRO
24  class GUIhelper;
26 #else
27  using OptGUIhelper = void;
28 #endif
29 }
30 
31 // This is only available on JeVoisPro
32 #ifdef JEVOIS_PRO
33 
35 #include <jevois/Core/Engine.H>
36 #include <jevois/Core/InputFrame.H>
39 #include <jevois/GPU/ImGuiImage.H>
40 #include <jevois/Types/Enum.H>
41 #include <chrono>
42 #include <imgui.h>
43 #include <glm/glm.hpp>
44 #include <opencv2/core/core.hpp>
45 
46 namespace jevois
47 {
48  class GPUimage;
49  class GUIeditor;
50 
51  namespace gui
52  {
53  static jevois::ParameterCategory const ParamCateg("Graphical Interface Options");
54 
55  //! Parameter \relates jevois::GUIhelper
56  JEVOIS_DECLARE_PARAMETER(fullscreen, bool, "Use a fullscreen display when true, only has effect on host. "
57  "Platform always is fullscreen as the MALI OpenGL driver do not support windowing.",
58  false, ParamCateg);
59 
60  //! Parameter \relates jevois::GUIhelper
61  JEVOIS_DECLARE_PARAMETER(winsize, cv::Size, "Initial window size to use on host. On platform, size is determined "
62  "by hardware and the value of this parameter will be overwritten on init. The "
63  "parameter can still be used to query display size.",
64 #ifdef JEVOIS_PLATFORM
65  // Use 0x0 default on platform which will trigger a query for framebuffer size in
66  // VideoDisplayBackEndMali:
67  cv::Size(0, 0),
68 #else
69  // On host, provide a default size since by default we run in a window:
70  cv::Size(1920, 1080),
71 #endif
72  ParamCateg);
73 
74  //! Parameter \relates jevois::GUIhelper
75  JEVOIS_DECLARE_PARAMETER(hidesecs, float, "Number of seconds of inactivity from keyboard/mouse/joystick/etc after "
76  "which we hide the GUI, or 0.0 to never hide it. Note: The GUI starts hidden until the "
77  "first input event from a keyboard, mouse, etc.",
78  30.0F, ParamCateg);
79 
80  //! Parameter \relates jevois::GUIhelper
81  JEVOIS_DECLARE_PARAMETER_WITH_CALLBACK(scale, float, "Scale factor applied to the GUI",
82  2.0f, { 1.0f, 1.1f, 1.2f, 1.3f, 1.4f, 1.5f, 1.6f, 1.7f, 1.8f, 1.9f, 2.0f,
83  2.1f, 2.2f, 2.3f, 2.4f, 2.5f, 2.6f, 2.7f, 2.8f, 2.9f, 3.0f },
84  ParamCateg);
85 
86  //! Enum for Parameter \relates jevois::GUIhelper
87  JEVOIS_DEFINE_ENUM_CLASS(GuiStyle, (Light) (Dark) (Classic) );
88 
89  //! Parameter \relates jevois::GUIhelper
90  JEVOIS_DECLARE_PARAMETER_WITH_CALLBACK(style, GuiStyle, "Color style for the JeVois GUI",
91  GuiStyle::Light, GuiStyle_Values, ParamCateg);
92 
93  //! Parameter \relates jevois::GUIhelper
94  JEVOIS_DECLARE_PARAMETER_WITH_CALLBACK(rounding, int, "Window and widget corner rounding for the JeVois GUI. "
95  "Note than changing GUI scale will update this parameter as well.",
96  4, jevois::Range<int>(0, 24), ParamCateg);
97  //! Parameter \relates jevois::GUIhelper
98  JEVOIS_DECLARE_PARAMETER(overlaycolor, ImColor, "Default color to use for overlay text",
99  ImColor(255, 255, 255, 255), ParamCateg);
100 
101  //! Parameter \relates jevois::GUIhelper
102  JEVOIS_DECLARE_PARAMETER(linethick, float, "Line thickness for overlay drawings",
103  5.0F, jevois::Range<float>(0.1F, 20.0F), ParamCateg);
104 
105  //! Parameter \relates jevois::GUIhelper
106  JEVOIS_DECLARE_PARAMETER(fillalpha, float, "Alpha multiplier for overlay fills",
107  0.25F, jevois::Range<float>(0.0F, 1.0F), ParamCateg);
108 
109  //! Parameter \relates jevois::GUIhelper
110  JEVOIS_DECLARE_PARAMETER(allowquit, bool, "Quit application on ESC key (platform) or window close (host)",
111  false, ParamCateg);
112  } // namespace gui
113 
114  /*! \defgroup gui JeVois-Pro Graphical Interface
115 
116  Classes and utilities to provide a graphical interface using Dear ImGui. Supported on JeVois-Pro only.
117 
118  \ingroup core */
119 
120  //! Helper class to assist modules in creating graphical and GUI elements
121  /*! This class only works on JeVois-Pro. \ingroup gui */
122  class GUIhelper : public Component,
123  public Parameter<gui::fullscreen, gui::winsize, gui::hidesecs, gui::scale,
124  gui::style, gui::rounding, gui::overlaycolor, gui::linethick,
125  gui::fillalpha, gui::allowquit>
126  {
127  public:
128  //! Constructor
129  GUIhelper(std::string const & instance, bool conslock = false);
130 
131  //! Destructor
132  virtual ~GUIhelper();
133 
134  //! Start a new rendering frame
135  /*! This should be called on every new video frame to be rendered. Will initialize OpenGL and open the window or
136  screen if needed. Sets the current window size into w and h, returns true if idle (no keyboard/mouse/etc
137  events received in more than hidesecs seconds). */
138  bool startFrame(unsigned short & w, unsigned short & h);
139 
140  //! Helper to indicate that startFrame() was called, and thus endFrame() should be called
141  /*! Mostly useful during exception handling inside Engine. */
142  bool frameStarted() const;
143 
144  //! Draw a RawImage, copying pixel data to an OpenGL texture
145  /*! Name should be a unique name, and should typically remain constant across successive video frames. This name
146  is used as an index to OpenGL textures, shaders, and programs created to render the images. Note that OpenGL
147  will slow down and eventually run out of resources if you create too many textures, thus Module writers should
148  try to minimize the number of different names that are used. Note that we will add a suffix to the name,
149  corresponding to the bufindex of the RawImage. If you pass w=0 or h=0 then the image will be rescaled to fill
150  the display as much as possible without changing the aspect ratio, and the actually used x,y,w,h will be
151  returned. Otherwise, x,y,w,h are not modified. If noalias is specified, the scaling factor will be rounded
152  down to the nearest integer to prevent aliasing in the display. This may reduce the displayed image size. For
153  example, with a 1920x1080 window, a 640x480 image would be letterboxed to 1440x1080 when noalias is false. But
154  that is a scaling factor of 2.25 which may create rendering aliasing. When noalias is true, the letterboxed
155  image size will be 1280x960 (scale factor of 2.0). If isoverlay is true, then the image is assumed to be a
156  semi-transparent overlay to be drawn on top of a previously drawn image, and we preserve the drawing
157  parameters of that previous image. */
158  void drawImage(char const * name, RawImage const & img, int & x, int & y, unsigned short & w, unsigned short & h,
159  bool noalias = false, bool isoverlay = false);
160 
161  //! Draw an OpenCV image, copying pixel data to an OpenGL texture
162  /*! Name should be a unique name, and should typically remain constant across successive video frames. This name
163  is used as an index to OpenGL textures, shaders, and programs created to render the images. Note that OpenGL
164  will slow down and eventually run out of resources if you create too many textures, thus Module writers should
165  try to minimize the number of different names that are used. If image has three or four 8-bit channels,
166  interpret as RGB[A] if rgb is true, otherwise BGR[A]. If two 8-bit channels, interpret as YUYV. If one,
167  interpret as GRAY. If you pass w=0 or h=0 then the image will be rescaled to fill the display as much as
168  possible without changing the aspect ratio, and the actually used x,y,w,h will be returned. Further, if
169  noalias is true, that rescaling will ensure an integer scaling factor. Otherwise, x,y,w,h are not modified. If
170  isoverlay is true, then the image is assumed to be a semi-transparent overlay to be drawn on top of a
171  previously drawn image, and we preserve the drawing parameters of that previous image. */
172  void drawImage(char const * name, cv::Mat const & img, bool rgb, int & x, int & y, unsigned short & w,
173  unsigned short & h, bool noalias = false, bool isoverlay = false);
174 
175  //! Draw the input video frame from the camera using zero-copy
176  /*! If you pass w=0 or h=0 then the image will be rescaled to fill the display as much as possible without
177  changing the aspect ratio, and the actually used x,y,w,h will be returned. Further, if noalias is true, that
178  rescaling will ensure an integer scaling factor. Otherwise, x,y,w,h are not modified. */
179  void drawInputFrame(char const * name, InputFrame const & frame, int & x, int & y,
180  unsigned short & w, unsigned short & h, bool noalias = false, bool casync = false);
181 
182  //! Draw the second (scaled) input video frame from the camera using zero-copy
183  /*! If you pass w=0 or h=0 then the image will be rescaled to fill the display as much as possible without
184  changing the aspect ratio, and the actually used x,y,w,h will be returned. Further, if noalias is true, that
185  rescaling will ensure an integer scaling factor. Otherwise, x,y,w,h are not modified. Throws unless we are
186  JeVois-Pro Platform and the camera is set to CropScale mode. */
187  void drawInputFrame2(char const * name, InputFrame const & frame, int & x, int & y,
188  unsigned short & w, unsigned short & h, bool noalias = false, bool casync = false);
189 
190  //! Convert coordinates of a point from within a rendered image to on-screen
191  /*! If name is nullptr, the last image used by drawImage() or drawInputFrame() is used. In such case, if
192  drawInputFrame() was called on a frame that also had a second, scaled image, assume that we have displayed the
193  full-resolution input frame but sent the scaled image to processing, and that hence we also need to scale from
194  second to first frame. */
195  ImVec2 i2d(ImVec2 p, char const * name = nullptr);
196 
197  //! Convert coordinates of a point from within a rendered image to on-screen
198  /*! If name is nullptr, the last image used by drawImage() or drawInputFrame() is used. In such case, if
199  drawInputFrame() was called on a frame that also had a second, scaled image, assume that we have displayed the
200  full-resolution input frame but sent the scaled image to processing, and that hence we also need to scale from
201  second to first frame. */
202  ImVec2 i2d(float x, float y, char const * name = nullptr);
203 
204  //! Convert a 2D size from within a rendered image to on-screen
205  /*! If name is nullptr, the last image used by drawImage() or drawInputFrame() is used. In such case, if
206  drawInputFrame() was called on a frame that also had a second, scaled image, assume that we have displayed the
207  full-resolution input frame but sent the scaled image to processing, and that hence we also need to scale from
208  second to first frame. */
209  ImVec2 i2ds(ImVec2 p, char const * name = nullptr);
210 
211  //! Convert a 2D size from within a rendered image to on-screen
212  /*! If name is nullptr, the last image used by drawImage() or drawInputFrame() is used. In such case, if
213  drawInputFrame() was called on a frame that also had a second, scaled image, assume that we have displayed the
214  full-resolution input frame but sent the scaled image to processing, and that hence we also need to scale from
215  second to first frame. */
216  ImVec2 i2ds(float x, float y, char const * name = nullptr);
217 
218  //! Draw line over an image
219  /*! Coordinates used should be image coordinates, as this function internally calls i2d(). */
220  void drawLine(float x1, float y1, float x2, float y2, ImU32 col = IM_COL32(128,255,128,255));
221 
222  //! Draw rectangular box over an image
223  /*! Coordinates used should be image coordinates, as this function internally calls i2d(). */
224  void drawRect(float x1, float y1, float x2, float y2, ImU32 col = IM_COL32(128,255,128,255), bool filled = true);
225 
226  //! Draw polygon over an image
227  /*! Coordinates used should be image coordinates, as this function internally calls i2d(). */
228  void drawPoly(std::vector<cv::Point> const & pts, ImU32 col = IM_COL32(128,255,128,255), bool filled = true);
229 
230  //! Draw polygon over an image
231  /*! Coordinates used should be image coordinates, as this function internally calls i2d(). */
232  void drawPoly(std::vector<cv::Point2f> const & pts, ImU32 col = IM_COL32(128,255,128,255), bool filled = true);
233 
234  //! Draw circle over an image
235  /*! Coordinates used should be image coordinates, as this function internally calls i2d(). */
236  void drawCircle(float x, float y, float r, ImU32 col = IM_COL32(128,255,128,255), bool filled = true);
237 
238  //! Draw text over an image
239  /*! Coordinates used should be image coordinates, as this function internally calls i2d(). */
240  void drawText(float x, float y, char const * txt, ImU32 col = IM_COL32(128,255,128,255));
241 
242  //! Draw text over an image
243  /*! Coordinates used should be image coordinates, as this function internally calls i2d(). */
244  void drawText(float x, float y, std::string const & txt, ImU32 col = IM_COL32(128,255,128,255));
245 
246  //! Get coordinates of the start of a given line of text to be drawn as overlay on top of an image
247  /*! Use this to draw overlay text on top of a previously drawn image, it will scale by font size for you. If line
248  is -1, we will increment over the last time this function was called (use with caution). Line number is reset
249  to 0 when drawImage() or drawInputFrame(), etc are called. */
250  ImVec2 iline(int line = -1, char const * name = nullptr);
251 
252  //! Draw some overlay text on top of an image
253  /* If line is -1, we will increment over the last time this function was called (use with caution). Line number is
254  reset to 0 when drawImage() or drawInputFrame(), etc are called. If col is not given, use overlaycolor. */
255  void itext(char const * txt, ImU32 const & col = IM_COL32_BLACK_TRANS, int line = -1);
256 
257  //! Draw some overlay text on top of an image
258  /* If line is -1, we will increment over the last time this function was called (use with caution). Line number is
259  reset to 0 when drawImage() or drawInputFrame(), etc are called. If col is not given, use overlaycolor. */
260  void itext(std::string const & txt, ImU32 const & col = IM_COL32_BLACK_TRANS, int line = -1);
261 
262  //! Display processing and video info at bottom of screen
263  /*! This helper is to be used by modules to provide a consistent info display at the bottom of the screen.
264  fpscpu should be the string returned by Timer::stop(). If winw and winh are not given, will query from display
265  backend, which will cost a few CPU cycles; so pass it on if you already have it, e.g, from running
266  startFrame() previously. */
267  void iinfo(jevois::InputFrame const & inframe, std::string const & fpscpu,
268  unsigned short winw = 0, unsigned short winh = 0);
269 
270  //! Release an image
271  /*! Call this if you plan on re-using the same image name later for an image of different size or
272  format. Otherwise, once an image has been used once, its OpenGL texture (including its dims) will remain the
273  same and only the pixel values will be updated when the image is drawn again. Silently ignores if the image is
274  not found, i.e., has not been drawn before. */
275  void releaseImage(char const * name);
276 
277  //! Release an image, second video stream
278  /*! Call this if you plan on re-using the same image name later for an image of different size or
279  format. Otherwise, once an image has been used once, its OpenGL texture (including its dims) will remain the
280  same and only the pixel values will be updated when the image is drawn again. Silently ignores if the image is
281  not found, i.e., has not been drawn before. */
282  void releaseImage2(char const * name);
283 
284  //! Finish current frame and render it
285  /*! This should be called once for every call to startFrame(). */
286  void endFrame();
287 
288  //! Reset to default state, typically called on Module or video format change
289  /*! Free images, reset matrices, etc. */
290  void reset(bool modulechanged = true);
291 
292  //! Report an error in an overlay window
293  void reportError(std::string const & err);
294 
295  //! Report current exception in a modal dialog, then ignore it
296  void reportAndIgnoreException(std::string const & prefix = "");
297 
298  //! Report current exception in a modal dialog, then re-throw it
299  void reportAndRethrowException(std::string const & prefix = "");
300 
301  //! Clear all errors currently displayed in the JeVois-Pro GUI
302  /*! In the JevoisPro GUI, errors reported via reportError() remain displayed for a few seconds, but sometimes we
303  want to clear them right away, e.g., after DNN pipeline threw, if the user selects another one, we want the
304  previous error to disappear immediately since it is not applicable anymore. */
305  void clearErrors();
306 
307  //! Z distance from camera to image plane to achieve pixel-perfect rendering
308  float const pixel_perfect_z;
309 
310  //! Our projection matrix
311  glm::mat4 proj;
312 
313  //! Our view matrix
314  /*! On the first call to startFrame(), the whole OpenGL engine is initialized and the view matrix is set so that
315  the pixel perfect image plane is vertical and centered on the origin, while the camera is translated in
316  negative Z to achieve pixel perfect rendering. */
317  glm::mat4 view;
318 
319  //! Display a (?) label and show tooltip when it is hovered
320  /*! If 2 or more messages are provided, they will be separated by a separator. */
321  void helpMarker(char const * msg, char const * msg2 = nullptr, char const * msg3 = nullptr);
322 
323  //! Helper to draw a toggle button
324  bool toggleButton(char const * name, bool * val);
325 
326  //! Helper to draw a modal with 2 choices
327  /*! Returns 1 if the first button was clicked, 2 if the second was, or some other value if no button was clicked
328  (caller should just wait and try again at the next frame if not 1 or 2, passing again that returned value). By
329  default, the first button is in focus. If default_val is not nullptr, add a "don't ask again" checkbox. If
330  *default_val is 1 or 2, just return that without even showing the modal. */
331  int modal(std::string const & title, char const * text, int * default_val = nullptr,
332  char const * b1txt = "Ok", char const * b2txt = "Cancel");
333 
334  //! Show a message that we are running headless
335  void headlessDisplay();
336 
337  //! Tell whether user enabled serlog messages to GUI console
338  bool serlogEnabled() const;
339 
340  //! Tell whether user enabled serout messages to GUI console
341  bool seroutEnabled() const;
342 
343  //! Convert coordinates of a point from on-screen to within a rendered image
344  /*! If name is nullptr, the last image used by drawImage() or drawInputFrame() is used. In such case, if
345  drawInputFrame() was called on a frame that also had a second, scaled image, assume that we have displayed the
346  full-resolution input frame but sent the scaled image to processing, and that hence we also need to scale from
347  second to first frame. */
348  ImVec2 d2i(ImVec2 p, char const * name = nullptr);
349 
350  //! Convert coordinates of a point from on-screen to within a rendered image
351  /*! If name is nullptr, the last image used by drawImage() or drawInputFrame() is used. In such case, if
352  drawInputFrame() was called on a frame that also had a second, scaled image, assume that we have displayed the
353  full-resolution input frame but sent the scaled image to processing, and that hence we also need to scale from
354  second to first frame. */
355  ImVec2 d2i(float x, float y, char const * name = nullptr);
356 
357  //! Convert a 2D size from on-screen to within a rendered image
358  /*! If name is nullptr, the last image used by drawImage() or drawInputFrame() is used. In such case, if
359  drawInputFrame() was called on a frame that also had a second, scaled image, assume that we have displayed the
360  full-resolution input frame but sent the scaled image to processing, and that hence we also need to scale from
361  second to first frame. */
362  ImVec2 d2is(ImVec2 p, char const * name = nullptr);
363 
364  //! Convert a 2D size from on-screen to within a rendered image
365  /*! If name is nullptr, the last image used by drawImage() or drawInputFrame() is used. In such case, if
366  drawInputFrame() was called on a frame that also had a second, scaled image, assume that we have displayed the
367  full-resolution input frame but sent the scaled image to processing, and that hence we also need to scale from
368  second to first frame. */
369  ImVec2 d2is(float x, float y, char const * name = nullptr);
370 
371  protected:
372  std::map<std::string /* name */, GPUimage> itsImages, itsImages2;
375  bool itsUsingScaledImage = false;
377 
378  std::chrono::time_point<std::chrono::steady_clock> itsLastEventTime;
379  bool itsIdle; //!< Idle state, updated by startFrame(), used by endFrame() to decide whether to draw GUI
380  bool itsEndFrameCalled = true; // try to avoid violent assert() crash from ImGui if user forgets to endFrame()
381 
382  mutable std::mutex itsErrorMtx;
383  struct ErrorData
384  {
385  std::string err;
386  std::chrono::time_point<std::chrono::steady_clock> firsttime;
387  std::chrono::time_point<std::chrono::steady_clock> lasttime;
388  };
389  std::list<ErrorData> itsErrors;
390 
391  std::set<std::string> itsOpenModals;
392 
393  void drawPolyInternal(ImVec2 const * pts, size_t npts, ImU32 col, bool filled);
394  ImU32 applyFillAlpha(ImU32 col) const;
395 
397 #ifdef JEVOIS_PLATFORM_PRO
399 #else
400  ImGuiBackendSDL itsBackend;
401 #endif
402  std::string itsWindowTitle;
405  std::string itsModName;
406  std::string itsModDesc;
407  std::string itsModAuth;
408  std::string itsModLang;
409  std::vector<std::string> itsModDoc;
410  gui::GuiStyle itsCurrentStyle = gui::GuiStyle::Dark;
411  bool itsShowStyleEditor = false;
412  bool itsShowAppMetrics = false;
413  bool itsShowImGuiDemo = false;
414  bool itsSerLogEnabled = true;
415  bool itsSerOutEnabled = false;
416 
417  void drawJeVoisGUI();
418  void drawInfo();
419  void drawParameters();
420  void drawConsole();
421  void drawCamCtrls();
422  void drawTweaks();
423  void drawSystem();
424  void drawMenuBar();
425  void drawModuleSelect();
426  void drawErrorPopup();
427  void drawNewModuleForm();
428 
429  void newModEntry(char const * wname, std::string & str, char const * desc, char const * hint, char const * hlp);
430 
431  // Set a parameter by string, catch any exception and report it in popup modal
432  void setparstr(std::string const & descriptor, std::string const & val);
433 
434  // Set a parameter by value, catch any exception and report it in popup modal
435  template <class T>
436  void setparval(std::string const & descriptor, T const & val);
437 
438  void onParamChange(gui::scale const & param, float const & newval) override;
439  void onParamChange(gui::rounding const & param, int const & newval) override;
440  void onParamChange(gui::style const & param, gui::GuiStyle const & newval) override;
441 
442  // Config files:
443  std::shared_ptr<GUIeditor> itsCfgEditor;
444 
445  // Code editing:
446  std::shared_ptr<GUIeditor> itsCodeEditor;
447 
448  // dnnget helpers
449  std::future<std::string> itsDnnGetFut;
450 
451  // Flag to refresh video mappings when we save the file or add a new one by creating a new module:
454  };
455 
456 } // namespace jevois
457 
458 // Include inlined implementation details that are of no interest to the end user
459 #include <jevois/GPU/details/GUIhelperImpl.H>
460 
461 #endif // JEVOIS_PRO
jevois::GUIhelper::ErrorData
Definition: GUIhelper.H:383
jevois::Component::descriptor
std::string descriptor() const
Get our full descriptor (including all parents) as [Instancename]:[...]:[...].
Definition: Component.C:276
jevois::GUIhelper::itsCodeEditor
std::shared_ptr< GUIeditor > itsCodeEditor
Definition: GUIhelper.H:446
jevois::GUIhelper::drawImage
void drawImage(char const *name, RawImage const &img, int &x, int &y, unsigned short &w, unsigned short &h, bool noalias=false, bool isoverlay=false)
Draw a RawImage, copying pixel data to an OpenGL texture.
Definition: GUIhelper.C:273
jevois::GUIhelper::drawInputFrame2
void drawInputFrame2(char const *name, InputFrame const &frame, int &x, int &y, unsigned short &w, unsigned short &h, bool noalias=false, bool casync=false)
Draw the second (scaled) input video frame from the camera using zero-copy.
Definition: GUIhelper.C:350
jevois::GUIhelper::drawNewModuleForm
void drawNewModuleForm()
Definition: GUIhelper.C:1637
jevois::GUIhelper::reportAndIgnoreException
void reportAndIgnoreException(std::string const &prefix="")
Report current exception in a modal dialog, then ignore it.
Definition: GUIhelper.C:2080
jevois::GUIhelper::itsSerLogEnabled
bool itsSerLogEnabled
Definition: GUIhelper.H:414
jevois::Range
A generic range class.
Definition: Range.H:80
jevois::GUIhelper::drawMenuBar
void drawMenuBar()
Definition: GUIhelper.C:758
jevois::GUIhelper::drawCircle
void drawCircle(float x, float y, float r, ImU32 col=IM_COL32(128, 255, 128, 255), bool filled=true)
Draw circle over an image.
Definition: GUIhelper.C:497
jevois::GUIhelper::itsModLang
std::string itsModLang
Definition: GUIhelper.H:408
jevois::GUIhelper::itsImages2
std::map< std::string, GPUimage > itsImages2
Definition: GUIhelper.H:372
jevois::GUIhelper::startFrame
bool startFrame(unsigned short &w, unsigned short &h)
Start a new rendering frame.
Definition: GUIhelper.C:163
jevois::GUIhelper::modal
int modal(std::string const &title, char const *text, int *default_val=nullptr, char const *b1txt="Ok", char const *b2txt="Cancel")
Helper to draw a modal with 2 choices.
Definition: GUIhelper.C:1398
jevois::GUIhelper::itext
void itext(char const *txt, ImU32 const &col=IM_COL32_BLACK_TRANS, int line=-1)
Draw some overlay text on top of an image.
Definition: GUIhelper.C:540
jevois::GUIhelper::onParamChange
void onParamChange(gui::scale const &param, float const &newval) override
jevois::GUIhelper::drawInfo
void drawInfo()
Definition: GUIhelper.C:894
JEVOIS_DECLARE_PARAMETER
JEVOIS_DECLARE_PARAMETER(thresh1, double, "First threshold for hysteresis", 50.0, ParamCateg)
jevois::GUIhelper::itsSerOutEnabled
bool itsSerOutEnabled
Definition: GUIhelper.H:415
jevois::GUIhelper::setparstr
void setparstr(std::string const &descriptor, std::string const &val)
Definition: GUIhelper.C:1054
jevois::GPUimage
Class to hold a GPUtexture, GPUprogram, and other data associated with rendering an image in OpenGL.
Definition: GPUimage.H:38
jevois::GUIhelper::headlessDisplay
void headlessDisplay()
Show a message that we are running headless.
Definition: GUIhelper.C:2190
jevois::GUIhelper::drawPolyInternal
void drawPolyInternal(ImVec2 const *pts, size_t npts, ImU32 col, bool filled)
Definition: GUIhelper.C:460
jevois::GUIhelper::endFrame
void endFrame()
Finish current frame and render it.
Definition: GUIhelper.C:662
jevois::Component
A component of a model hierarchy.
Definition: Component.H:181
jevois::GUIhelper::itsOpenModals
std::set< std::string > itsOpenModals
Definition: GUIhelper.H:391
jevois::GUIhelper::reportAndRethrowException
void reportAndRethrowException(std::string const &prefix="")
Report current exception in a modal dialog, then re-throw it.
Definition: GUIhelper.C:2105
jevois::GUIhelper::releaseImage
void releaseImage(char const *name)
Release an image.
Definition: GUIhelper.C:574
jevois::GUIhelper::itsIdle
bool itsIdle
Idle state, updated by startFrame(), used by endFrame() to decide whether to draw GUI.
Definition: GUIhelper.H:379
jevois::GUIhelper::itsErrors
std::list< ErrorData > itsErrors
Definition: GUIhelper.H:389
jevois::GUIhelper::drawTweaks
void drawTweaks()
Definition: GUIhelper.C:1980
jevois::GUIhelper::newModEntry
void newModEntry(char const *wname, std::string &str, char const *desc, char const *hint, char const *hlp)
Definition: GUIhelper.C:1447
jevois::ImGuiImage
Wrapper for an image that can be rendered into ImGui.
Definition: ImGuiImage.H:30
jevois::GUIhelper::itsUsingScaledImage
bool itsUsingScaledImage
Definition: GUIhelper.H:375
jevois::GUIhelper::clearErrors
void clearErrors()
Clear all errors currently displayed in the JeVois-Pro GUI.
Definition: GUIhelper.C:2073
jevois::RawImage
A raw image as coming from a V4L2 Camera and/or being sent out to a USB Gadget.
Definition: RawImage.H:110
jevois::GUIhelper::d2i
ImVec2 d2i(ImVec2 p, char const *name=nullptr)
Convert coordinates of a point from on-screen to within a rendered image.
Definition: GUIhelper.C:588
jevois::GUIhelper::helpMarker
void helpMarker(char const *msg, char const *msg2=nullptr, char const *msg3=nullptr)
Display a (?) label and show tooltip when it is hovered.
Definition: GUIhelper.C:2154
jevois::GUIhelper::i2d
ImVec2 i2d(ImVec2 p, char const *name=nullptr)
Convert coordinates of a point from within a rendered image to on-screen.
Definition: GUIhelper.C:374
jevois::GUIhelper::itsRefreshVideoMappings
bool itsRefreshVideoMappings
Definition: GUIhelper.H:452
jevois::GUIhelper::drawErrorPopup
void drawErrorPopup()
Definition: GUIhelper.C:2112
jevois::GUIhelper::drawModuleSelect
void drawModuleSelect()
Definition: GUIhelper.C:814
jevois::ParameterCategory
A category to which multiple ParameterDef definitions can belong.
Definition: ParameterDef.H:33
jevois::GUIhelper::drawParameters
void drawParameters()
Definition: GUIhelper.C:1062
jevois::GUIhelper::itsModName
std::string itsModName
Definition: GUIhelper.H:405
jevois::GUIhelper::drawRect
void drawRect(float x1, float y1, float x2, float y2, ImU32 col=IM_COL32(128, 255, 128, 255), bool filled=true)
Draw rectangular box over an image.
Definition: GUIhelper.C:448
jevois::GUIhelper::drawCamCtrls
void drawCamCtrls()
Definition: GUIhelper.C:1392
jevois::GUIhelper::itsDnnGetFut
std::future< std::string > itsDnnGetFut
Definition: GUIhelper.H:449
jevois::GUIhelper::itsCurrentStyle
gui::GuiStyle itsCurrentStyle
Definition: GUIhelper.H:410
jevois::GUIhelper::itsScaledImageFacX
float itsScaledImageFacX
Definition: GUIhelper.H:376
jevois::GUIhelper
Helper class to assist modules in creating graphical and GUI elements.
Definition: GUIhelper.H:122
jevois::GUIhelper::itsLastDrawnImage
GPUimage * itsLastDrawnImage
Definition: GUIhelper.H:373
jevois::GUIhelper::drawLine
void drawLine(float x1, float y1, float x2, float y2, ImU32 col=IM_COL32(128, 255, 128, 255))
Draw line over an image.
Definition: GUIhelper.C:442
jevois::GUIhelper::seroutEnabled
bool seroutEnabled() const
Tell whether user enabled serout messages to GUI console.
Definition: GUIhelper.C:1388
jevois::GUIhelper::itsShowStyleEditor
bool itsShowStyleEditor
Definition: GUIhelper.H:411
jevois::GUIhelper::itsLastEventTime
std::chrono::time_point< std::chrono::steady_clock > itsLastEventTime
Definition: GUIhelper.H:378
jevois::GUIhelper::itsImages
std::map< std::string, GPUimage > itsImages
Definition: GUIhelper.H:372
jevois::GUIhelper::proj
glm::mat4 proj
Our projection matrix.
Definition: GUIhelper.H:311
jevois::GUIhelper::reportError
void reportError(std::string const &err)
Report an error in an overlay window.
Definition: GUIhelper.C:2053
jevois
Definition: Concepts.dox:1
jevois::GUIhelper::ErrorData::lasttime
std::chrono::time_point< std::chrono::steady_clock > lasttime
Definition: GUIhelper.H:387
jevois::GUIhelper::itsModDesc
std::string itsModDesc
Definition: GUIhelper.H:406
F
float F
Definition: GUIhelper.C:1968
Component.H
jevois::GUIhelper::itsBackend
ImGuiBackendMALI itsBackend
Definition: GUIhelper.H:398
Engine.H
jevois::GUIhelper::itsConsLock
bool itsConsLock
Definition: GUIhelper.H:396
JEVOIS_DECLARE_PARAMETER_WITH_CALLBACK
JEVOIS_DECLARE_PARAMETER_WITH_CALLBACK(l2grad, bool, "Use more accurate L2 gradient norm if true, L1 if false", false, ParamCateg)
jevois::GUIhelper::drawPoly
void drawPoly(std::vector< cv::Point > const &pts, ImU32 col=IM_COL32(128, 255, 128, 255), bool filled=true)
Draw polygon over an image.
Definition: GUIhelper.C:475
ImGuiBackendSDL.H
jevois::JEVOIS_DEFINE_ENUM_CLASS
JEVOIS_DEFINE_ENUM_CLASS(CameraSensor,(any)(ov9650)(ov2640)(ov7725)(ar0135)(imx290)(os08a10))
Enum for different sensor models.
jevois::GUIhelper::toggleButton
bool toggleButton(char const *name, bool *val)
Helper to draw a toggle button.
Definition: GUIhelper.C:2171
jevois::GUIhelper::reset
void reset(bool modulechanged=true)
Reset to default state, typically called on Module or video format change.
Definition: GUIhelper.C:115
jevois::GUIhelper::frameStarted
bool frameStarted() const
Helper to indicate that startFrame() was called, and thus endFrame() should be called.
Definition: GUIhelper.C:269
jevois::GUIhelper::drawJeVoisGUI
void drawJeVoisGUI()
Definition: GUIhelper.C:677
jevois::GUIhelper::itsHeadless
ImGuiImage itsHeadless
Definition: GUIhelper.H:404
jevois::GUIhelper::itsShowImGuiDemo
bool itsShowImGuiDemo
Definition: GUIhelper.H:413
jevois::GUIhelper::serlogEnabled
bool serlogEnabled() const
Tell whether user enabled serlog messages to GUI console.
Definition: GUIhelper.C:1384
jevois::GUIhelper::releaseImage2
void releaseImage2(char const *name)
Release an image, second video stream.
Definition: GUIhelper.C:581
jevois::GUIhelper::itsModDoc
std::vector< std::string > itsModDoc
Definition: GUIhelper.H:409
jevois::GUIhelper::drawSystem
void drawSystem()
Definition: GUIhelper.C:1462
jevois::GUIhelper::itsEndFrameCalled
bool itsEndFrameCalled
Definition: GUIhelper.H:380
jevois::GUIhelper::drawText
void drawText(float x, float y, char const *txt, ImU32 col=IM_COL32(128, 255, 128, 255))
Draw text over an image.
Definition: GUIhelper.C:510
jevois::GUIhelper::ErrorData::err
std::string err
Definition: GUIhelper.H:385
jevois::GUIhelper::GUIhelper
GUIhelper(std::string const &instance, bool conslock=false)
Constructor.
Definition: GUIhelper.C:47
jevois::GUIhelper::view
glm::mat4 view
Our view matrix.
Definition: GUIhelper.H:317
jevois::GUIhelper::drawInputFrame
void drawInputFrame(char const *name, InputFrame const &frame, int &x, int &y, unsigned short &w, unsigned short &h, bool noalias=false, bool casync=false)
Draw the input video frame from the camera using zero-copy.
Definition: GUIhelper.C:320
jevois::GUIhelper::drawConsole
void drawConsole()
Definition: GUIhelper.C:1295
jevois::GUIhelper::itsErrorMtx
std::mutex itsErrorMtx
Definition: GUIhelper.H:382
InputFrame.H
jevois::GUIhelper::iinfo
void iinfo(jevois::InputFrame const &inframe, std::string const &fpscpu, unsigned short winw=0, unsigned short winh=0)
Display processing and video info at bottom of screen.
Definition: GUIhelper.C:553
jevois::ImGuiBackendMALI
BackendMALI for ImGui on JeVois-Pro.
Definition: ImGuiBackendMALI.H:86
jevois::GUIhelper::itsWindowTitle
std::string itsWindowTitle
Definition: GUIhelper.H:402
jevois::InputFrame
Exception-safe wrapper around a raw camera input frame.
Definition: InputFrame.H:50
jevois::GUIhelper::d2is
ImVec2 d2is(ImVec2 p, char const *name=nullptr)
Convert a 2D size from on-screen to within a rendered image.
Definition: GUIhelper.C:625
jevois::GUIhelper::itsLastDrawnTextLine
int itsLastDrawnTextLine
Definition: GUIhelper.H:374
jevois::GUIhelper::itsCfgEditor
std::shared_ptr< GUIeditor > itsCfgEditor
Definition: GUIhelper.H:443
jevois::GUIhelper::i2ds
ImVec2 i2ds(ImVec2 p, char const *name=nullptr)
Convert a 2D size from within a rendered image to on-screen.
Definition: GUIhelper.C:408
jevois::GUIhelper::itsScaledImageFacY
float itsScaledImageFacY
Definition: GUIhelper.H:376
jevois::GUIhelper::itsModAuth
std::string itsModAuth
Definition: GUIhelper.H:407
jevois::GUIhelper::iline
ImVec2 iline(int line=-1, char const *name=nullptr)
Get coordinates of the start of a given line of text to be drawn as overlay on top of an image.
Definition: GUIhelper.C:530
h
int h
Definition: GUIhelper.C:1968
ImGuiImage.H
jevois::GUIhelper::itsShowAppMetrics
bool itsShowAppMetrics
Definition: GUIhelper.H:412
jevois::GUIhelper::itsVideoMappingListType
int itsVideoMappingListType
Definition: GUIhelper.H:453
jevois::GUIhelper::pixel_perfect_z
const float pixel_perfect_z
Z distance from camera to image plane to achieve pixel-perfect rendering.
Definition: GUIhelper.H:308
jevois::GUIhelper::applyFillAlpha
ImU32 applyFillAlpha(ImU32 col) const
Definition: GUIhelper.C:522
ImGuiBackendMALI.H
jevois::GUIhelper::itsIcon
ImGuiImage itsIcon
Definition: GUIhelper.H:403
jevois::GUIhelper::~GUIhelper
virtual ~GUIhelper()
Destructor.
Definition: GUIhelper.C:108
jevois::GUIhelper::setparval
void setparval(std::string const &descriptor, T const &val)
jevois::GUIhelper::ErrorData::firsttime
std::chrono::time_point< std::chrono::steady_clock > firsttime
Definition: GUIhelper.H:386
Enum.H