44#include <opencv2/core/core.hpp> 
   58                             "Platform always is fullscreen as the MALI OpenGL driver do not support windowing.",
 
   63                             "by hardware and the value of this parameter will be overwritten on init. The " 
   64                             "parameter can still be used to query display size.",
 
   77                             "which we hide the GUI, or 0.0 to never hide it. Note: The GUI starts hidden until the " 
   78                             "first input event from a keyboard, mouse, etc.",
 
   83                                           2.0f, { 1.0f, 1.1f, 1.2f, 1.3f, 1.4f, 1.5f, 1.6f, 1.7f, 1.8f, 1.9f, 2.0f,
 
   84                                                   2.1f, 2.2f, 2.3f, 2.4f, 2.5f, 2.6f, 2.7f, 2.8f, 2.9f, 3.0f },
 
   92                                           GuiStyle::Light, GuiStyle_Values, ParamCateg);
 
   96                                           "Note than changing GUI scale will update this parameter as well.",
 
  101                             ImColor(255, 255, 255, 255), ParamCateg);
 
  117                                           "mainly for demo mode",
 
  130                    public Parameter<gui::fullscreen, gui::winsize, gui::hidesecs, gui::scale,
 
  131                                     gui::style, gui::rounding, gui::overlaycolor, gui::linethick,
 
  132                                     gui::fillalpha, gui::allowquit, gui::twirl>
 
  136      GUIhelper(std::string 
const & instance, 
bool conslock = 
false);
 
  145      bool startFrame(
unsigned short & w, 
unsigned short & 
h);
 
  168      void drawImage(
char const * name, 
RawImage const & img, 
int & x, 
int & y, 
unsigned short & w, 
unsigned short & 
h,
 
  169                     bool noalias = 
false, 
bool isoverlay = 
false);
 
  182      void drawImage(
char const * name, cv::Mat 
const & img, 
bool rgb, 
int & x, 
int & y, 
unsigned short & w,
 
  183                     unsigned short & 
h, 
bool noalias = 
false, 
bool isoverlay = 
false);
 
  190                          unsigned short & w, 
unsigned short & 
h, 
bool noalias = 
false, 
bool casync = 
false);
 
  198                           unsigned short & w, 
unsigned short & 
h, 
bool noalias = 
false, 
bool casync = 
false);
 
  210      ImVec2 
i2d(ImVec2 p, 
char const * name = 
nullptr);
 
  217      ImVec2 
i2d(
float x, 
float y, 
char const * name = 
nullptr);
 
  224      ImVec2 
i2ds(ImVec2 p, 
char const * name = 
nullptr);
 
  231      ImVec2 
i2ds(
float x, 
float y, 
char const * name = 
nullptr);
 
  236      void drawLine(
float x1, 
float y1, 
float x2, 
float y2, ImU32 col = IM_COL32(128,255,128,255));
 
  241      void drawRect(
float x1, 
float y1, 
float x2, 
float y2, ImU32 col = IM_COL32(128,255,128,255), 
bool filled = 
true);
 
  246      void drawPoly(std::vector<cv::Point> 
const & pts, ImU32 col = IM_COL32(128,255,128,255), 
bool filled = 
true);
 
  251      void drawPoly(std::vector<cv::Point2f> 
const & pts, ImU32 col = IM_COL32(128,255,128,255), 
bool filled = 
true);
 
  257      void drawPoly(cv::Mat 
const & pts, ImU32 col = IM_COL32(128,255,128,255), 
bool filled = 
true);
 
  262      void drawCircle(
float x, 
float y, 
float r, ImU32 col = IM_COL32(128,255,128,255), 
bool filled = 
true);
 
  266      void drawEllipse(
float x, 
float y, 
float rx, 
float ry, 
float rot = 0.0F,
 
  267                       ImU32 col = IM_COL32(128,255,128,255), 
bool filled = 
true);
 
  272      void drawText(
float x, 
float y, 
char const * txt, ImU32 col = IM_COL32(128,255,128,255));
 
  277      void drawText(
float x, 
float y, std::string 
const & txt, ImU32 col = IM_COL32(128,255,128,255));
 
  283      ImVec2 
iline(
int line = -1, 
char const * name = 
nullptr);
 
  289      void itext(
char const * txt, ImU32 
const & col = IM_COL32_BLACK_TRANS, 
int line = -1);
 
  295      void itext(std::string 
const & txt, ImU32 
const & col = IM_COL32_BLACK_TRANS, 
int line = -1);
 
  303                 unsigned short winw = 0, 
unsigned short winh = 0);
 
  359      void helpMarker(
char const * msg, 
char const * msg2 = 
nullptr, 
char const * msg3 = 
nullptr);
 
  369      int modal(std::string 
const & title, 
char const * text, 
int * default_val = 
nullptr,
 
  370                char const * b1txt = 
"Ok", 
char const * b2txt = 
"Cancel");
 
  375      bool combo(std::string 
const & name, std::vector<std::string> 
const & items, 
int & selected_index);
 
  386      bool selectImageBox(
int & state, ImVec2 & tl, ImVec2 & br, ImU32 col = IM_COL32(128,255,128,255));
 
  402      ImVec2 
d2i(ImVec2 p, 
char const * name = 
nullptr);
 
  409      ImVec2 
d2i(
float x, 
float y, 
char const * name = 
nullptr);
 
  416      ImVec2 
d2is(ImVec2 p, 
char const * name = 
nullptr);
 
  423      ImVec2 
d2is(
float x, 
float y, 
char const * name = 
nullptr);
 
  435      void demoBanner(std::string 
const & title = 
"", std::string 
const & msg = 
"");
 
  454          std::chrono::time_point<std::chrono::steady_clock> 
firsttime;
 
  455          std::chrono::time_point<std::chrono::steady_clock> 
lasttime;
 
 
  462      void drawPolyInternal(ImVec2 
const * pts, 
size_t npts, ImU32 col, 
bool filled);
 
  466#ifdef JEVOIS_PLATFORM_PRO 
  501      void newModEntry(
char const * wname, std::string & str, 
char const * desc, 
char const * hint, 
char const * hlp);
 
  510      void onParamChange(gui::scale 
const & param, 
float const & newval) 
override;
 
  511      void onParamChange(gui::rounding 
const & param, 
int const & newval) 
override;
 
  512      void onParamChange(gui::style 
const & param, gui::GuiStyle 
const & newval) 
override;
 
  513      void onParamChange(gui::twirl 
const & param, 
float const & newval) 
override;
 
 
  550#include <jevois/GPU/details/GUIhelperImpl.H> 
A component of a model hierarchy.
 
std::string descriptor() const
Get our full descriptor (including all parents) as [Instancename]:[...]:[...].
 
Class to hold a GPUtexture, GPUprogram, and other data associated with rendering an image in OpenGL.
 
Helper class to assist modules in creating graphical and GUI elements.
 
void setparval(std::string const &descriptor, T const &val)
 
glm::mat4 proj
Our projection matrix.
 
void drawCircle(float x, float y, float r, ImU32 col=IM_COL32(128, 255, 128, 255), bool filled=true)
Draw circle over an image.
 
void onParamChange(gui::style const ¶m, gui::GuiStyle const &newval) override
 
std::list< ErrorData > itsErrors
 
std::map< std::string, GPUimage > itsImages2
 
std::string itsBannerTitle
 
void endFrame()
Finish current frame and render it.
 
bool seroutEnabled() const
Tell whether user enabled serout messages to GUI console.
 
bool combo(std::string const &name, std::vector< std::string > const &items, int &selected_index)
Helper to draw a combobox from a vector of strings.
 
void resetstate(bool modulechanged=true)
Reset to default state, typically called on Module or video format change.
 
VideoMapping itsNewMapping
 
std::shared_ptr< GUIeditor > itsCfgEditor
 
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.
 
JEVOIS_DECLARE_PARAMETER_WITH_CALLBACK(scale, float, "Scale factor applied to the GUI", 2.0f, { 1.0f, 1.1f, 1.2f, 1.3f, 1.4f, 1.5f, 1.6f, 1.7f, 1.8f, 1.9f, 2.0f, 2.1f, 2.2f, 2.3f, 2.4f, 2.5f, 2.6f, 2.7f, 2.8f, 2.9f, 3.0f }, ParamCateg)
Parameter.
 
void reportAndIgnoreException(std::string const &prefix="")
Report current exception in a modal dialog, then ignore it.
 
bool itsIdleBlocked
While creating/compiling new modules, prevent idle.
 
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.
 
bool startFrame(unsigned short &w, unsigned short &h)
Start a new rendering frame.
 
GPUimage * itsLastDrawnImage
 
JEVOIS_DECLARE_PARAMETER(fillalpha, float, "Alpha multiplier for overlay fills", 0.25F, jevois::Range< float >(0.0F, 1.0F), ParamCateg)
Parameter.
 
ImVec2 i2ds(ImVec2 p, char const *name=nullptr)
Convert a 2D size from within a rendered image to on-screen.
 
bool itsShowHardSerialWin
 
JEVOIS_DECLARE_PARAMETER_WITH_CALLBACK(rounding, int, "Window and widget corner rounding for the JeVois GUI. " "Note than changing GUI scale will update this parameter as well.", 4, jevois::Range< int >(0, 24), ParamCateg)
Parameter.
 
void drawText(float x, float y, char const *txt, ImU32 col=IM_COL32(128, 255, 128, 255))
Draw text over an image.
 
void reportErrorOrInfo(std::string const &err, bool is_info)
 
void drawEllipse(float x, float y, float rx, float ry, float rot=0.0F, ImU32 col=IM_COL32(128, 255, 128, 255), bool filled=true)
Draw ellipse over an image.
 
std::set< std::string > itsOpenModals
 
virtual ~GUIhelper()
Destructor.
 
JEVOIS_DECLARE_PARAMETER_WITH_CALLBACK(twirl, float, "Apply twirl effect to displayed video and images, useful " "mainly for demo mode", 0.0F, jevois::Range< float >(-15.0F, 15.0F), ParamCateg)
Parameter.
 
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.
 
void onParamChange(gui::scale const ¶m, float const &newval) override
 
bool frameStarted() const
Helper to indicate that startFrame() was called, and thus endFrame() should be called.
 
void startCompilation()
Compile a newly created module.
 
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.
 
std::shared_ptr< GUIeditor > itsCodeEditor
 
void clearErrors()
Clear all errors currently displayed in the JeVois-Pro GUI.
 
void newModEntry(char const *wname, std::string &str, char const *desc, char const *hint, char const *hlp)
 
void releaseImage(char const *name)
Release an image.
 
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.
 
glm::mat4 view
Our view matrix.
 
void helpMarker(char const *msg, char const *msg2=nullptr, char const *msg3=nullptr)
Display a (?) label and show tooltip when it is hovered.
 
void demoBanner(std::string const &title="", std::string const &msg="")
Display some text in a big banner, used by demo mode.
 
void highlightText(std::string const &str)
Like ImGui::Textunformatted but in a highlight color (typically, red)
 
void reportError(std::string const &err)
Report an error in an overlay window.
 
void headlessDisplay()
Show a message that we are running headless.
 
ImVec2 i2d(ImVec2 p, char const *name=nullptr)
Convert coordinates of a point from within a rendered image to on-screen.
 
float const pixel_perfect_z
Z distance from camera to image plane to achieve pixel-perfect rendering.
 
void reportAndRethrowException(std::string const &prefix="")
Report current exception in a modal dialog, then re-throw it.
 
bool selectImageBox(int &state, ImVec2 &tl, ImVec2 &br, ImU32 col=IM_COL32(128, 255, 128, 255))
Helper to select a rectangular box by dragging the mouse over the display.
 
int itsLastDrawnTextLine
caution, is nullptr except between drawInputFrame() and endFrame()
 
CompilationState itsCompileState
 
InputFrame const  * itsInputFrame
 
bool idle() const
Check for idle in case startFrame() was called elsewhere.
 
ImVec2 d2is(ImVec2 p, char const *name=nullptr)
Convert a 2D size from on-screen to within a rendered image.
 
void drawLine(float x1, float y1, float x2, float y2, ImU32 col=IM_COL32(128, 255, 128, 255))
Draw line over an image.
 
JEVOIS_DECLARE_PARAMETER(fullscreen, bool, "Use a fullscreen display when true, only has effect on host. " "Platform always is fullscreen as the MALI OpenGL driver do not support windowing.", false, ParamCateg)
Parameter.
 
void itext(char const *txt, ImU32 const &col=IM_COL32_BLACK_TRANS, int line=-1)
Draw some overlay text on top of an image.
 
void releaseImage2(char const *name)
Release an image, second video stream.
 
InputFrame const * getInputFrame() const
Get access to the InputFrame last drawn with drawInputFrame()
 
ImU32 applyFillAlpha(ImU32 col) const
 
std::chrono::time_point< std::chrono::steady_clock > itsLastEventTime
 
JEVOIS_DECLARE_PARAMETER(linethick, float, "Line thickness for overlay drawings", 5.0F, jevois::Range< float >(0.1F, 20.0F), ParamCateg)
Parameter.
 
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.
 
std::array< std::string, 4 > itsCompileMessages
 
void drawPoly(std::vector< cv::Point > const &pts, ImU32 col=IM_COL32(128, 255, 128, 255), bool filled=true)
Draw polygon over an image.
 
void onParamChange(gui::rounding const ¶m, int const &newval) override
 
bool itsRefreshVideoMappings
 
std::future< std::string > itsDnnGetFut
 
void drawPolyInternal(ImVec2 const *pts, size_t npts, ImU32 col, bool filled)
 
void setparstr(std::string const &descriptor, std::string const &val)
 
gui::GuiStyle itsCurrentStyle
 
std::string itsWindowTitle
 
int itsVideoMappingListType
 
JEVOIS_DECLARE_PARAMETER_WITH_CALLBACK(style, GuiStyle, "Color style for the JeVois GUI", GuiStyle::Light, GuiStyle_Values, ParamCateg)
Parameter.
 
std::future< std::string > itsCompileFut
 
JEVOIS_DECLARE_PARAMETER(allowquit, bool, "Quit application on ESC key (platform) or window close (host)", false, ParamCateg)
Parameter.
 
ImGuiBackendMALI itsBackend
 
bool compileCommand(std::string const &cmd, std::string &msg)
 
std::vector< std::string > itsModDoc
 
void reportInfo(std::string const &inf)
Report a transient info message in an overlay window.
 
std::map< std::string, GPUimage > itsImages
 
bool itsIdle
Idle state, updated by startFrame(), used by endFrame() to decide whether to draw GUI.
 
JEVOIS_DEFINE_ENUM_CLASS(GuiStyle,(Light)(Dark)(Classic))
Enum for Parameter.
 
ImVec2 d2i(ImVec2 p, char const *name=nullptr)
Convert coordinates of a point from on-screen to within a rendered image.
 
bool toggleButton(char const *name, bool *val)
Helper to draw a toggle button.
 
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.
 
JEVOIS_DECLARE_PARAMETER(hidesecs, float, "Number of seconds of inactivity from keyboard/mouse/joystick/etc after " "which we hide the GUI, or 0.0 to never hide it. Note: The GUI starts hidden until the " "first input event from a keyboard, mouse, etc.", 30.0F, ParamCateg)
Parameter.
 
bool serlogEnabled() const
Tell whether user enabled serlog messages to GUI console.
 
JEVOIS_DECLARE_PARAMETER(winsize, cv::Size, "Initial window size to use on host. On platform, size is determined " "by hardware and the value of this parameter will be overwritten on init. The " "parameter can still be used to query display size.", cv::Size(0, 0), ParamCateg)
Parameter.
 
JEVOIS_DECLARE_PARAMETER(overlaycolor, ImColor, "Default color to use for overlay text", ImColor(255, 255, 255, 255), ParamCateg)
Parameter.
 
BackendMALI for ImGui on JeVois-Pro.
 
Wrapper for an image that can be rendered into ImGui.
 
A raw image as coming from a V4L2 Camera and/or being sent out to a USB Gadget.
 
Main namespace for all JeVois classes and functions.
 
std::chrono::time_point< std::chrono::steady_clock > firsttime
 
std::chrono::time_point< std::chrono::steady_clock > lasttime
 
A category to which multiple ParameterDef definitions can belong.
 
Simple struct to hold video mapping definitions for the processing Engine.