JeVois  1.16
JeVois Smart Embedded Machine Vision Toolkit
Share this page:
jevois::GUIhelper Class Reference

#include <jevois/GPU/GUIhelper.H>

Helper class to assist modules in creating graphical and GUI elements.

This class only works on JeVois-Pro. All functions except constructor and destructor throw on other platforms.

Definition at line 108 of file GUIhelper.H.

Inheritance diagram for jevois::GUIhelper:
Collaboration diagram for jevois::GUIhelper:

Classes

struct  CfgItem
 
struct  ErrorData
 

Public Member Functions

 GUIhelper (std::string const &instance, bool conslock=false)
 Constructor. More...
 
virtual ~GUIhelper ()
 Destructor. More...
 
bool startFrame (unsigned short &w, unsigned short &h)
 Start a new rendering frame. More...
 
bool frameStarted () const
 Helper to indicate that startFrame() was called, and thus endFrame() should be called. More...
 
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. More...
 
void drawImage (char const *name, cv::Mat const &img, bool rgb, int &x, int &y, unsigned short &w, unsigned short &h, bool noalias=false, bool isoverlay=false)
 Draw an OpenCV image, copying pixel data to an OpenGL texture. More...
 
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. More...
 
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. More...
 
ImVec2 i2d (ImVec2 p, char const *name=nullptr)
 Convert coordinates of a point from within a rendered image to on-screen. More...
 
ImVec2 i2d (float x, float y, char const *name=nullptr)
 Convert coordinates of a point from within a rendered image to on-screen. More...
 
ImVec2 i2ds (ImVec2 p, char const *name=nullptr)
 Convert a 2D size from within a rendered image to on-screen. More...
 
ImVec2 i2ds (float x, float y, char const *name=nullptr)
 Convert a 2D size from within a rendered image to on-screen. More...
 
void drawLine (float x1, float y1, float x2, float y2, ImU32 col=IM_COL32(128, 255, 128, 255))
 Draw line over an image. More...
 
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. More...
 
void drawPoly (std::vector< cv::Point > const &pts, ImU32 col=IM_COL32(128, 255, 128, 255), bool filled=true)
 Draw polygon over an image. More...
 
void drawPoly (std::vector< cv::Point2f > const &pts, ImU32 col=IM_COL32(128, 255, 128, 255), bool filled=true)
 Draw polygon over an image. More...
 
void drawCircle (float x, float y, float r, ImU32 col=IM_COL32(128, 255, 128, 255), bool filled=true)
 Draw circle over an image. More...
 
void drawText (float x, float y, char const *txt, ImU32 col=IM_COL32(128, 255, 128, 255))
 Draw text over an image. More...
 
void drawText (float x, float y, std::string const &txt, ImU32 col=IM_COL32(128, 255, 128, 255))
 Draw text over an image. More...
 
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. More...
 
void itext (char const *txt, ImU32 const &col=IM_COL32_BLACK_TRANS, int line=-1)
 Draw some overlay text on top of an image. More...
 
void itext (std::string const &txt, ImU32 const &col=IM_COL32_BLACK_TRANS, int line=-1)
 Draw some overlay text on top of an image. More...
 
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. More...
 
void releaseImage (char const *name)
 Release an image. More...
 
void releaseImage2 (char const *name)
 Release an image, second video stream. More...
 
void endFrame ()
 Finish current frame and render it. More...
 
void reset (bool modulechanged=true)
 Reset to default state, typically called on Module or video format change. More...
 
void reportError (std::string const &err)
 Report an error in an overlay window. More...
 
void reportAndIgnoreException (std::string const &prefix="")
 Report current exception in a modal dialog, then ignore it. More...
 
void reportAndRethrowException (std::string const &prefix="")
 Report current exception in a modal dialog, then re-throw it. More...
 
void helpMarker (char const *msg, char const *msg2=nullptr, char const *msg3=nullptr)
 Display a (?) label and show tooltip when it is hovered. More...
 
bool toggleButton (char const *name, bool *val)
 Helper to draw a toggle button. More...
 
int modal (std::string const &title, char const *text, bool &dont_ask_me_next_time, char const *b1txt="Ok", char const *b2txt="Cancel")
 Helper to draw a modal with 2 choices. More...
 
void headlessDisplay ()
 Show a message that we are running headless. More...
 
bool serlogEnabled () const
 Tell whether user enabled serlog messages to GUI console. More...
 
bool seroutEnabled () const
 Tell whether user enabled serout messages to GUI console. More...
 
- Public Member Functions inherited from jevois::Component
 Component (std::string const &instance)
 Constructor. More...
 
virtual ~Component ()
 Virtual destructor for safe inheritance. More...
 
template<class Comp , typename... Args>
std::shared_ptr< Comp > addSubComponent (std::string const &instance, Args &&...args)
 Pseudo-constructor: construct and add another component as a subcomponent of this one. More...
 
template<class Comp >
void removeSubComponent (std::shared_ptr< Comp > &component)
 Remove a sub-Component from this Component, by shared_ptr. More...
 
void removeSubComponent (std::string const &instance, bool warnIfNotFound=true)
 Remove a sub-Component from this Component, by instance name. More...
 
template<class Comp = jevois::Component>
std::shared_ptr< Comp > getSubComponent (std::string const &instance) const
 Get a sub-component by instance name. More...
 
bool isTopLevel () const
 Returns true if this component is top-level, i.e., its parent is jevois::Manager. More...
 
Engineengine () const
 Get a handle to our Engine, or throw if we do not have an Engine as root ancestor. More...
 
bool initialized () const
 Has this component been initialized yet? More...
 
const std::string & className () const
 The class name of this component. More...
 
const std::string & instanceName () const
 The instance name of this component. More...
 
template<typename T >
std::vector< std::string > setParamVal (std::string const &paramdescriptor, T const &val)
 Set a parameter value. More...
 
template<typename T >
void setParamValUnique (std::string const &paramdescriptor, T const &val)
 Set a parameter value, simple version assuming only one parameter match. More...
 
template<typename T >
std::vector< std::pair< std::string, T > > getParamVal (std::string const &paramdescriptor) const
 Get parameter(s) value(s) by descriptor. More...
 
template<typename T >
getParamValUnique (std::string const &paramdescriptor) const
 Get a parameter value, simple version assuming only one parameter match. More...
 
std::vector< std::string > setParamString (std::string const &paramdescriptor, std::string const &val)
 Set a parameter value, by string. More...
 
void setParamStringUnique (std::string const &paramdescriptor, std::string const &val)
 Set a parameter value by string, simple version assuming only one parameter match. More...
 
std::vector< std::pair< std::string, std::string > > getParamString (std::string const &paramdescriptor) const
 Get a parameter value, by string. More...
 
std::string getParamStringUnique (std::string const &paramdescriptor) const
 Get a parameter value by string, simple version assuming only one parameter match. More...
 
void freezeParam (std::string const &paramdescriptor)
 Freeze a parameter, by name, see ParameterBase::freeze() More...
 
void unFreezeParam (std::string const &paramdescriptor)
 Unfreeze a parameter, by name, see ParameterBase::unFreeze() More...
 
void freezeAllParams ()
 Freeze all parameters. More...
 
void unFreezeAllParams ()
 Unfreeze all parameters. More...
 
std::string descriptor () const
 Get our full descriptor (including all parents) as [Instancename]:[...]:[...]. More...
 
void setParamsFromFile (std::string const &filename)
 Set some parameters from a file. More...
 
std::istream & setParamsFromStream (std::istream &is, std::string const &absfile)
 Set some parameters from an open stream. More...
 
virtual void paramInfo (std::shared_ptr< UserInterface > s, std::map< std::string, std::string > &categs, bool skipFrozen, std::string const &cname="", std::string const &pfx="")
 Get machine-oriented descriptions of all parameters. More...
 
void foreachParam (std::function< void(std::string const &compname, ParameterBase *p)> func, std::string const &cname="")
 Run a function on every param we hold. More...
 
void setPath (std::string const &path)
 Assign a filesystem path to this component. More...
 
std::string absolutePath (std::string const &path="")
 If given path is relative (not starting with /), prepend the Component path to it. More...
 
- Public Member Functions inherited from jevois::ParameterRegistry
virtual ~ParameterRegistry ()
 Virtual destructor for safe inheritance. More...
 

Public Attributes

const float pixel_perfect_z
 Z distance from camera to image plane to achieve pixel-perfect rendering. More...
 
glm::mat4 proj
 Our projection matrix. More...
 
glm::mat4 view
 Our view matrix. More...
 

Protected Types

enum  CfgSaveAction { CfgSaveAction::None, CfgSaveAction::Reload, CfgSaveAction::Reboot, CfgSaveAction::RefreshMappings }
 

Protected Member Functions

void drawPolyInternal (ImVec2 const *pts, size_t npts, ImU32 col, bool filled)
 
ImU32 applyFillAlpha (ImU32 col) const
 
void drawJeVoisGUI ()
 
void drawInfo ()
 
void drawParameters ()
 
void drawConsole ()
 
void drawEditorMenu (TextEditor &e)
 
void drawEditor (TextEditor &e)
 
void drawCamCtrls ()
 
void drawCfgEditor ()
 
void drawCodeEditor ()
 
void drawTweaks ()
 
void drawSystem ()
 
void drawMenuBar ()
 
void drawModuleSelect ()
 
void drawErrorPopup ()
 
void drawNewModuleForm ()
 
void newModEntry (char const *wname, std::string &str, char const *desc, char const *hint, char const *hlp)
 
void setparstr (std::string const &descriptor, std::string const &val)
 
template<class T >
void setparval (std::string const &descriptor, T const &val)
 
void onParamChange (gui::scale const &param, float const &newval) override
 
void onParamChange (gui::rounding const &param, int const &newval) override
 
void onParamChange (gui::style const &param, gui::GuiStyle const &newval) override
 
void loadEditorFile (TextEditor &e, std::string const &fn, std::string const &failtxt, bool failro)
 
void saveEditorFile (TextEditor &e, std::string const &fn)
 
- Protected Member Functions inherited from jevois::Component
virtual void preInit ()
 Called before all sub-Components are init()ed. More...
 
virtual void postInit ()
 Called after all sub-Components are init()ed. More...
 
virtual void preUninit ()
 Called before all sub-Components are uninit()ed. More...
 
virtual void postUninit ()
 Called after all sub-Components are uninit()ed. More...
 
- Protected Member Functions inherited from jevois::ParameterRegistry
void addParameter (ParameterBase *const param)
 The Parameter class uses this method to register itself on construction with its owning Component. More...
 
void removeParameter (ParameterBase *const param)
 The Parameter class uses this method to un-register itself on destruction with its owning Component. More...
 
void callbackInitCall ()
 For all parameters that have a callback which has never been called, call it with the default param value. More...
 

Protected Attributes

std::map< std::string, GPUimageitsImages
 
std::map< std::string, GPUimageitsImages2
 
GPUimageitsLastDrawnImage = nullptr
 
int itsLastDrawnTextLine = -1
 
bool itsUsingScaledImage = false
 
float itsScaledImageFacX = 1.0F
 
float itsScaledImageFacY = 1.0F
 
std::chrono::time_point< std::chrono::steady_clock > itsLastEventTime
 
bool itsIdle
 Idle state, updated by startFrame(), used by endFrame() to decide whether to draw GUI. More...
 
bool itsEndFrameCalled = true
 
std::mutex itsErrorMtx
 
std::list< ErrorDataitsErrors
 
std::set< std::string > itsOpenModals
 
bool itsConsLock
 
ImGuiBackendSDL itsBackend
 
std::string itsWindowTitle
 
ImGuiImage itsIcon
 
ImGuiImage itsHeadless
 
std::string itsModName
 
std::string itsModDesc
 
std::string itsModAuth
 
std::string itsModLang
 
std::vector< std::string > itsModDoc
 
gui::GuiStyle itsCurrentStyle = gui::GuiStyle::Dark
 
bool itsShowStyleEditor = false
 
bool itsShowAppMetrics = false
 
bool itsShowImGuiDemo = false
 
bool itsSerLogEnabled = true
 
bool itsSerOutEnabled = true
 
TextEditor itsCfgEditor
 
std::string itsCfgFileName
 
std::vector< CfgItemitsCfgItems
 
size_t itsNumFixedCfgItems
 
bool itsRefreshCfgList = true
 
int itsCfgCurrentItem = 0
 
CfgSaveAction itsCfgCurrentAction = CfgSaveAction::None
 
bool itsCfgWantLoad = true
 
bool itsCfgWantAction = false
 
bool itsCfgOkToLoad = false
 
int itsCfgNewItem = 0
 
TextEditor itsCodeEditor
 
std::string itsCodeFileName
 
std::future< std::string > itsDnnGetFut
 
bool itsRefreshVideoMappings = false
 
int itsVideoMappingListType = 0
 

Related Functions

(Note that these are not member functions.)

 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. More...
 
 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(1920, 1080), ParamCateg)
 Parameter. More...
 
 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. More...
 
 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. More...
 
 JEVOIS_DEFINE_ENUM_CLASS (GuiStyle,(Light)(Dark)(Classic))
 Enum for Parameter. More...
 
 JEVOIS_DECLARE_PARAMETER_WITH_CALLBACK (style, GuiStyle, "Color style for the JeVois GUI", GuiStyle::Light, GuiStyle_Values, ParamCateg)
 Parameter. More...
 
 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. More...
 
 JEVOIS_DECLARE_PARAMETER (overlaycolor, ImColor, "Default color to use for overlay text", ImColor(255, 255, 255, 255), ParamCateg)
 Parameter. More...
 
 JEVOIS_DECLARE_PARAMETER (linethick, float, "Line thickness for overlay drawings", 5.0F, jevois::Range< float >(0.1F, 20.0F), ParamCateg)
 Parameter. More...
 
 JEVOIS_DECLARE_PARAMETER (fillalpha, float, "Alpha multiplier for overlay fills", 0.25F, jevois::Range< float >(0.0F, 1.0F), ParamCateg)
 Parameter. More...
 
 JEVOIS_DECLARE_PARAMETER (allowquit, bool, "Quit application on ESC key (platform) or window close (host)", false, ParamCateg)
 Parameter. More...
 

Member Enumeration Documentation

◆ CfgSaveAction

enum jevois::GUIhelper::CfgSaveAction
strongprotected
Enumerator
None 
Reload 
Reboot 
RefreshMappings 

Definition at line 403 of file GUIhelper.H.

Constructor & Destructor Documentation

◆ GUIhelper()

jevois::GUIhelper::GUIhelper ( std::string const &  instance,
bool  conslock = false 
)

Constructor.

Definition at line 43 of file GUIhelper.C.

References itsCfgEditor, itsCfgItems, itsCodeEditor, itsNumFixedCfgItems, itsWindowTitle, Reboot, RefreshMappings, and Reload.

◆ ~GUIhelper()

jevois::GUIhelper::~GUIhelper ( )
virtual

Destructor.

Definition at line 88 of file GUIhelper.C.

References JEVOIS_WAIT_GET_FUTURE.

Member Function Documentation

◆ applyFillAlpha()

ImU32 jevois::GUIhelper::applyFillAlpha ( ImU32  col) const
protected

Definition at line 491 of file GUIhelper.C.

References jevois::imu::get().

◆ drawCamCtrls()

void jevois::GUIhelper::drawCamCtrls ( )
protected

Definition at line 1294 of file GUIhelper.C.

◆ drawCfgEditor()

void jevois::GUIhelper::drawCfgEditor ( )
protected

Definition at line 1419 of file GUIhelper.C.

References jevois::absolutePath().

◆ drawCircle()

void jevois::GUIhelper::drawCircle ( float  x,
float  y,
float  r,
ImU32  col = IM_COL32(128,255,128,255),
bool  filled = true 
)

Draw circle over an image.

Coordinates used should be image coordinates, as this function internally calls i2d().

Definition at line 466 of file GUIhelper.C.

References jevois::imu::get().

◆ drawCodeEditor()

void jevois::GUIhelper::drawCodeEditor ( )
protected

Definition at line 1580 of file GUIhelper.C.

◆ drawConsole()

◆ drawEditor()

void jevois::GUIhelper::drawEditor ( TextEditor &  e)
protected

Definition at line 1406 of file GUIhelper.C.

◆ drawEditorMenu()

void jevois::GUIhelper::drawEditorMenu ( TextEditor &  e)
protected

Definition at line 1372 of file GUIhelper.C.

◆ drawErrorPopup()

void jevois::GUIhelper::drawErrorPopup ( )
protected

Definition at line 2276 of file GUIhelper.C.

◆ drawImage() [1/2]

void jevois::GUIhelper::drawImage ( char const *  name,
cv::Mat const &  img,
bool  rgb,
int &  x,
int &  y,
unsigned short &  w,
unsigned short &  h,
bool  noalias = false,
bool  isoverlay = false 
)

Draw an OpenCV image, copying pixel data to an OpenGL texture.

Name should be a unique name, and should typically remain constant across successive video frames. This name is used as an index to OpenGL textures, shaders, and programs created to render the images. Note that OpenGL will slow down and eventually run out of resources if you create too many textures, thus Module writers should try to minimize the number of different names that are used. If image has three or four 8-bit channels, interpret as RGB[A] if rgb is true, otherwise BGR[A]. If two 8-bit channels, interpret as YUYV. If one, interpret as GRAY. If you pass w=0 or h=0 then the image will be rescaled to fill the display as much as possible without changing the aspect ratio, and the actually used x,y,w,h will be returned. Further, if noalias is true, that rescaling will ensure an integer scaling factor. Otherwise, x,y,w,h are not modified. If isoverlay is true, then the image is assumed to be a semi-transparent overlay to be drawn on top of a previously drawn image, and we preserve the drawing parameters of that previous image.

Definition at line 267 of file GUIhelper.C.

References h.

◆ drawImage() [2/2]

void jevois::GUIhelper::drawImage ( char const *  name,
jevois::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.

Name should be a unique name, and should typically remain constant across successive video frames. This name is used as an index to OpenGL textures, shaders, and programs created to render the images. Note that OpenGL will slow down and eventually run out of resources if you create too many textures, thus Module writers should try to minimize the number of different names that are used. Note that we will add a suffix to the name, corresponding to the bufindex of the RawImage. If you pass w=0 or h=0 then the image will be rescaled to fill the display as much as possible without changing the aspect ratio, and the actually used x,y,w,h will be returned. Otherwise, x,y,w,h are not modified. If noalias is specified, the scaling factor will be rounded down to the nearest integer to prevent aliasing in the display. This may reduce the displayed image size. For example, with a 1920x1080 window, a 640x480 image would be letterboxed to 1440x1080 when noalias is false. But that is a scaling factor of 2.25 which may create rendering aliasing. When noalias is true, the letterboxed image size will be 1280x960 (scale factor of 2.0). If isoverlay is true, then the image is assumed to be a semi-transparent overlay to be drawn on top of a previously drawn image, and we preserve the drawing parameters of that previous image.

Definition at line 242 of file GUIhelper.C.

References jevois::RawImage::bufindex, h, and jevois::to_string().

Referenced by jevois::dnn::PostProcessorSegment::report().

◆ drawInfo()

void jevois::GUIhelper::drawInfo ( )
protected

◆ drawInputFrame()

void jevois::GUIhelper::drawInputFrame ( char const *  name,
jevois::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.

If you pass w=0 or h=0 then the image will be rescaled to fill the display as much as possible without changing the aspect ratio, and the actually used x,y,w,h will be returned. Further, if noalias is true, that rescaling will ensure an integer scaling factor. Otherwise, x,y,w,h are not modified.

Definition at line 289 of file GUIhelper.C.

References jevois::RawImage::bufindex, jevois::InputFrame::get(), jevois::InputFrame::get2(), h, jevois::InputFrame::hasScaledImage(), jevois::RawImage::height, jevois::to_string(), and jevois::RawImage::width.

◆ drawInputFrame2()

void jevois::GUIhelper::drawInputFrame2 ( char const *  name,
jevois::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.

If you pass w=0 or h=0 then the image will be rescaled to fill the display as much as possible without changing the aspect ratio, and the actually used x,y,w,h will be returned. Further, if noalias is true, that rescaling will ensure an integer scaling factor. Otherwise, x,y,w,h are not modified. Throws unless we are JeVois-Pro Platform and the camera is set to CropScale mode.

Definition at line 319 of file GUIhelper.C.

References jevois::RawImage::bufindex, jevois::InputFrame::get2(), h, and jevois::to_string().

◆ drawJeVoisGUI()

void jevois::GUIhelper::drawJeVoisGUI ( )
protected

Definition at line 572 of file GUIhelper.C.

◆ drawLine()

void jevois::GUIhelper::drawLine ( float  x1,
float  y1,
float  x2,
float  y2,
ImU32  col = IM_COL32(128,255,128,255) 
)

Draw line over an image.

Coordinates used should be image coordinates, as this function internally calls i2d().

Definition at line 411 of file GUIhelper.C.

References jevois::imu::get().

◆ drawMenuBar()

void jevois::GUIhelper::drawMenuBar ( )
protected

Definition at line 660 of file GUIhelper.C.

◆ drawModuleSelect()

void jevois::GUIhelper::drawModuleSelect ( )
protected

Definition at line 716 of file GUIhelper.C.

References JEVOISPRO_FMT_GUI, and LFATAL.

◆ drawNewModuleForm()

void jevois::GUIhelper::drawNewModuleForm ( )
protected

◆ drawParameters()

◆ drawPoly() [1/2]

void jevois::GUIhelper::drawPoly ( std::vector< cv::Point > const &  pts,
ImU32  col = IM_COL32(128,255,128,255),
bool  filled = true 
)

Draw polygon over an image.

Coordinates used should be image coordinates, as this function internally calls i2d().

Definition at line 444 of file GUIhelper.C.

◆ drawPoly() [2/2]

void jevois::GUIhelper::drawPoly ( std::vector< cv::Point2f > const &  pts,
ImU32  col = IM_COL32(128,255,128,255),
bool  filled = true 
)

Draw polygon over an image.

Coordinates used should be image coordinates, as this function internally calls i2d().

Definition at line 455 of file GUIhelper.C.

◆ drawPolyInternal()

void jevois::GUIhelper::drawPolyInternal ( ImVec2 const *  pts,
size_t  npts,
ImU32  col,
bool  filled 
)
protected

Definition at line 429 of file GUIhelper.C.

References jevois::imu::get().

◆ drawRect()

void jevois::GUIhelper::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.

Coordinates used should be image coordinates, as this function internally calls i2d().

Definition at line 417 of file GUIhelper.C.

References jevois::imu::get().

Referenced by jevois::dnn::PostProcessorDetect::report().

◆ drawSystem()

◆ drawText() [1/2]

void jevois::GUIhelper::drawText ( float  x,
float  y,
char const *  txt,
ImU32  col = IM_COL32(128,255,128,255) 
)

Draw text over an image.

Coordinates used should be image coordinates, as this function internally calls i2d().

Definition at line 479 of file GUIhelper.C.

Referenced by jevois::dnn::PostProcessorDetect::report().

◆ drawText() [2/2]

void jevois::GUIhelper::drawText ( float  x,
float  y,
std::string const &  txt,
ImU32  col = IM_COL32(128,255,128,255) 
)

Draw text over an image.

Coordinates used should be image coordinates, as this function internally calls i2d().

Definition at line 485 of file GUIhelper.C.

◆ drawTweaks()

void jevois::GUIhelper::drawTweaks ( )
protected

Definition at line 2162 of file GUIhelper.C.

References FX().

◆ endFrame()

void jevois::GUIhelper::endFrame ( )

Finish current frame and render it.

This should be called once for every call to startFrame().

Definition at line 557 of file GUIhelper.C.

◆ frameStarted()

bool jevois::GUIhelper::frameStarted ( ) const

Helper to indicate that startFrame() was called, and thus endFrame() should be called.

Mostly useful during exception handling inside Engine.

Definition at line 238 of file GUIhelper.C.

◆ headlessDisplay()

void jevois::GUIhelper::headlessDisplay ( )

Show a message that we are running headless.

Definition at line 2354 of file GUIhelper.C.

References jevois::warnAndIgnoreException().

◆ helpMarker()

void jevois::GUIhelper::helpMarker ( char const *  msg,
char const *  msg2 = nullptr,
char const *  msg3 = nullptr 
)

Display a (?) label and show tooltip when it is hovered.

If 2 or more messages are provided, they will be separated by a separator.

Definition at line 2318 of file GUIhelper.C.

◆ i2d() [1/2]

ImVec2 jevois::GUIhelper::i2d ( float  x,
float  y,
char const *  name = nullptr 
)

Convert coordinates of a point from within a rendered image to on-screen.

If name is nullptr, the last image used by drawImage() or drawInputFrame() is used. In such case, if drawInputFrame() was called on a frame that also had a second, scaled image, assume that we have displayed the full-resolution input frame but sent the scaled image to processing, and that hence we also need to scale from second to first frame.

Definition at line 373 of file GUIhelper.C.

◆ i2d() [2/2]

ImVec2 jevois::GUIhelper::i2d ( ImVec2  p,
char const *  name = nullptr 
)

Convert coordinates of a point from within a rendered image to on-screen.

If name is nullptr, the last image used by drawImage() or drawInputFrame() is used. In such case, if drawInputFrame() was called on a frame that also had a second, scaled image, assume that we have displayed the full-resolution input frame but sent the scaled image to processing, and that hence we also need to scale from second to first frame.

Definition at line 343 of file GUIhelper.C.

References jevois::GPUimage::i2d().

Referenced by jevois::dnn::PostProcessorSegment::report(), and jevois::dnn::PreProcessor::sendreport().

◆ i2ds() [1/2]

ImVec2 jevois::GUIhelper::i2ds ( float  x,
float  y,
char const *  name = nullptr 
)

Convert a 2D size from within a rendered image to on-screen.

If name is nullptr, the last image used by drawImage() or drawInputFrame() is used. In such case, if drawInputFrame() was called on a frame that also had a second, scaled image, assume that we have displayed the full-resolution input frame but sent the scaled image to processing, and that hence we also need to scale from second to first frame.

Definition at line 407 of file GUIhelper.C.

◆ i2ds() [2/2]

ImVec2 jevois::GUIhelper::i2ds ( ImVec2  p,
char const *  name = nullptr 
)

Convert a 2D size from within a rendered image to on-screen.

If name is nullptr, the last image used by drawImage() or drawInputFrame() is used. In such case, if drawInputFrame() was called on a frame that also had a second, scaled image, assume that we have displayed the full-resolution input frame but sent the scaled image to processing, and that hence we also need to scale from second to first frame.

Definition at line 377 of file GUIhelper.C.

References jevois::GPUimage::i2ds().

◆ iinfo()

void jevois::GUIhelper::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.

This helper is to be used by modules to provide a consistent info display at the bottom of the screen. fpscpu should be the string returned by Timer::stop(). If winw and winh are not given, will query from display backend, which will cost a few CPU cycles; so pass it on if you already have it, e.g, from running startFrame() previously.

Definition at line 522 of file GUIhelper.C.

References jevois::fccstr(), jevois::RawImage::fmt, jevois::InputFrame::get(), jevois::imu::get(), jevois::InputFrame::get2(), jevois::InputFrame::hasScaledImage(), jevois::RawImage::height, jevois::sformat(), and jevois::RawImage::width.

◆ iline()

ImVec2 jevois::GUIhelper::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.

Use this to draw overlay text on top of a previously drawn image, it will scale by font size for you. If line is -1, we will increment over the last time this function was called (use with caution). Line number is reset to 0 when drawImage() or drawInputFrame(), etc are called.

Definition at line 499 of file GUIhelper.C.

◆ itext() [1/2]

void jevois::GUIhelper::itext ( char const *  txt,
ImU32 const &  col = IM_COL32_BLACK_TRANS,
int  line = -1 
)

Draw some overlay text on top of an image.

Definition at line 509 of file GUIhelper.C.

References jevois::imu::get().

Referenced by jevois::dnn::Pipeline::process(), and jevois::dnn::PostProcessorClassify::report().

◆ itext() [2/2]

void jevois::GUIhelper::itext ( std::string const &  txt,
ImU32 const &  col = IM_COL32_BLACK_TRANS,
int  line = -1 
)

Draw some overlay text on top of an image.

Definition at line 516 of file GUIhelper.C.

◆ loadEditorFile()

void jevois::GUIhelper::loadEditorFile ( TextEditor &  e,
std::string const &  fn,
std::string const &  failtxt,
bool  failro 
)
protected

Definition at line 1339 of file GUIhelper.C.

References LINFO.

◆ modal()

int jevois::GUIhelper::modal ( std::string const &  title,
char const *  text,
bool &  dont_ask_me_next_time,
char const *  b1txt = "Ok",
char const *  b2txt = "Cancel" 
)

Helper to draw a modal with 2 choices.

Returns 0 if no button was clicked, 1 if the first button was, 2 if the second was. By default, the first button is in focus.

Definition at line 1300 of file GUIhelper.C.

◆ newModEntry()

void jevois::GUIhelper::newModEntry ( char const *  wname,
std::string &  str,
char const *  desc,
char const *  hint,
char const *  hlp 
)
protected

Definition at line 1637 of file GUIhelper.C.

◆ onParamChange() [1/3]

void jevois::GUIhelper::onParamChange ( gui::rounding const &  param,
int const &  newval 
)
overrideprotected

◆ onParamChange() [2/3]

void jevois::GUIhelper::onParamChange ( gui::scale const &  param,
float const &  newval 
)
overrideprotected

◆ onParamChange() [3/3]

void jevois::GUIhelper::onParamChange ( gui::style const &  param,
gui::GuiStyle const &  newval 
)
overrideprotected

◆ releaseImage()

void jevois::GUIhelper::releaseImage ( char const *  name)

Release an image.

Call this if you plan on re-using the same image name later for an image of different size or format. Otherwise, once an image has been used once, its OpenGL texture (including its dims) will remain the same and only the pixel values will be updated when the image is drawn again. Silently ignores if the image is not found, i.e., has not been drawn before.

Definition at line 543 of file GUIhelper.C.

Referenced by jevois::dnn::PostProcessorSegment::~PostProcessorSegment().

◆ releaseImage2()

void jevois::GUIhelper::releaseImage2 ( char const *  name)

Release an image, second video stream.

Call this if you plan on re-using the same image name later for an image of different size or format. Otherwise, once an image has been used once, its OpenGL texture (including its dims) will remain the same and only the pixel values will be updated when the image is drawn again. Silently ignores if the image is not found, i.e., has not been drawn before.

Definition at line 550 of file GUIhelper.C.

◆ reportAndIgnoreException()

void jevois::GUIhelper::reportAndIgnoreException ( std::string const &  prefix = "")

Report current exception in a modal dialog, then ignore it.

Definition at line 2252 of file GUIhelper.C.

Referenced by jevois::dnn::Pipeline::process().

◆ reportAndRethrowException()

void jevois::GUIhelper::reportAndRethrowException ( std::string const &  prefix = "")

Report current exception in a modal dialog, then re-throw it.

Definition at line 2269 of file GUIhelper.C.

◆ reportError()

void jevois::GUIhelper::reportError ( std::string const &  err)

Report an error in an overlay window.

Definition at line 2235 of file GUIhelper.C.

◆ reset()

void jevois::GUIhelper::reset ( bool  modulechanged = true)

Reset to default state, typically called on Module or video format change.

Free images, reset matrices, etc.

Definition at line 95 of file GUIhelper.C.

References jevois::imu::get(), h, and LFATAL.

◆ saveEditorFile()

void jevois::GUIhelper::saveEditorFile ( TextEditor &  e,
std::string const &  fn 
)
protected

Definition at line 1358 of file GUIhelper.C.

References LINFO.

◆ serlogEnabled()

bool jevois::GUIhelper::serlogEnabled ( ) const

Tell whether user enabled serlog messages to GUI console.

Definition at line 1286 of file GUIhelper.C.

◆ seroutEnabled()

bool jevois::GUIhelper::seroutEnabled ( ) const

Tell whether user enabled serout messages to GUI console.

Definition at line 1290 of file GUIhelper.C.

◆ setparstr()

void jevois::GUIhelper::setparstr ( std::string const &  descriptor,
std::string const &  val 
)
protected

Definition at line 956 of file GUIhelper.C.

References jevois::warnAndIgnoreException().

◆ setparval()

template<class T >
void jevois::GUIhelper::setparval ( std::string const &  descriptor,
T const &  val 
)
protected

◆ startFrame()

bool jevois::GUIhelper::startFrame ( unsigned short &  w,
unsigned short &  h 
)

Start a new rendering frame.

This should be called on every new video frame to be rendered. Will initialize OpenGL and open the window or screen if needed. Sets the current window size into w and h, returns true if idle (no keyboard/mouse/etc events received in more than hidesecs seconds).

Definition at line 139 of file GUIhelper.C.

References jevois::imu::get(), h, LFATAL, and LINFO.

◆ toggleButton()

bool jevois::GUIhelper::toggleButton ( char const *  name,
bool *  val 
)

Helper to draw a toggle button.

Definition at line 2335 of file GUIhelper.C.

Friends And Related Function Documentation

◆ JEVOIS_DECLARE_PARAMETER() [1/7]

JEVOIS_DECLARE_PARAMETER ( allowquit  ,
bool  ,
"Quit application on ESC key (platform) or window close (host)"  ,
false  ,
ParamCateg   
)
related

Parameter.

◆ JEVOIS_DECLARE_PARAMETER() [2/7]

JEVOIS_DECLARE_PARAMETER ( fillalpha  ,
float  ,
"Alpha multiplier for overlay fills"  ,
0.  25F,
jevois::Range< float >  0.0F, 1.0F,
ParamCateg   
)
related

Parameter.

◆ JEVOIS_DECLARE_PARAMETER() [3/7]

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   
)
related

Parameter.

◆ JEVOIS_DECLARE_PARAMETER() [4/7]

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   
)
related

Parameter.

◆ JEVOIS_DECLARE_PARAMETER() [5/7]

JEVOIS_DECLARE_PARAMETER ( linethick  ,
float  ,
"Line thickness for overlay drawings"  ,
5.  0F,
jevois::Range< float >  0.1F, 20.0F,
ParamCateg   
)
related

Parameter.

◆ JEVOIS_DECLARE_PARAMETER() [6/7]

JEVOIS_DECLARE_PARAMETER ( overlaycolor  ,
ImColor  ,
"Default color to use for overlay text"  ,
ImColor(255, 255, 255, 255)  ,
ParamCateg   
)
related

Parameter.

◆ JEVOIS_DECLARE_PARAMETER() [7/7]

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(1920, 1080)  ,
ParamCateg   
)
related

Parameter.

◆ JEVOIS_DECLARE_PARAMETER_WITH_CALLBACK() [1/3]

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."  ,
,
jevois::Range< int >  0, 24,
ParamCateg   
)
related

Parameter.

◆ JEVOIS_DECLARE_PARAMETER_WITH_CALLBACK() [2/3]

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   
)
related

Parameter.

◆ JEVOIS_DECLARE_PARAMETER_WITH_CALLBACK() [3/3]

JEVOIS_DECLARE_PARAMETER_WITH_CALLBACK ( style  ,
GuiStyle  ,
"Color style for the JeVois GUI"  ,
GuiStyle::Light  ,
GuiStyle_Values  ,
ParamCateg   
)
related

Parameter.

◆ JEVOIS_DEFINE_ENUM_CLASS()

JEVOIS_DEFINE_ENUM_CLASS ( GuiStyle  ,
(Light)(Dark)(Classic)   
)
related

Enum for Parameter.

Member Data Documentation

◆ itsBackend

ImGuiBackendSDL jevois::GUIhelper::itsBackend
protected

Definition at line 350 of file GUIhelper.H.

◆ itsCfgCurrentAction

CfgSaveAction jevois::GUIhelper::itsCfgCurrentAction = CfgSaveAction::None
protected

Definition at line 416 of file GUIhelper.H.

◆ itsCfgCurrentItem

int jevois::GUIhelper::itsCfgCurrentItem = 0
protected

Definition at line 415 of file GUIhelper.H.

◆ itsCfgEditor

TextEditor jevois::GUIhelper::itsCfgEditor
protected

Definition at line 397 of file GUIhelper.H.

Referenced by GUIhelper().

◆ itsCfgFileName

std::string jevois::GUIhelper::itsCfgFileName
protected

Definition at line 398 of file GUIhelper.H.

◆ itsCfgItems

std::vector<CfgItem> jevois::GUIhelper::itsCfgItems
protected

Definition at line 412 of file GUIhelper.H.

Referenced by GUIhelper().

◆ itsCfgNewItem

int jevois::GUIhelper::itsCfgNewItem = 0
protected

Definition at line 420 of file GUIhelper.H.

◆ itsCfgOkToLoad

bool jevois::GUIhelper::itsCfgOkToLoad = false
protected

Definition at line 419 of file GUIhelper.H.

◆ itsCfgWantAction

bool jevois::GUIhelper::itsCfgWantAction = false
protected

Definition at line 418 of file GUIhelper.H.

◆ itsCfgWantLoad

bool jevois::GUIhelper::itsCfgWantLoad = true
protected

Definition at line 417 of file GUIhelper.H.

◆ itsCodeEditor

TextEditor jevois::GUIhelper::itsCodeEditor
protected

Definition at line 423 of file GUIhelper.H.

Referenced by GUIhelper().

◆ itsCodeFileName

std::string jevois::GUIhelper::itsCodeFileName
protected

Definition at line 424 of file GUIhelper.H.

◆ itsConsLock

bool jevois::GUIhelper::itsConsLock
protected

Definition at line 346 of file GUIhelper.H.

◆ itsCurrentStyle

gui::GuiStyle jevois::GUIhelper::itsCurrentStyle = gui::GuiStyle::Dark
protected

Definition at line 360 of file GUIhelper.H.

◆ itsDnnGetFut

std::future<std::string> jevois::GUIhelper::itsDnnGetFut
protected

Definition at line 427 of file GUIhelper.H.

◆ itsEndFrameCalled

bool jevois::GUIhelper::itsEndFrameCalled = true
protected

Definition at line 330 of file GUIhelper.H.

◆ itsErrorMtx

std::mutex jevois::GUIhelper::itsErrorMtx
mutableprotected

Definition at line 332 of file GUIhelper.H.

◆ itsErrors

std::list<ErrorData> jevois::GUIhelper::itsErrors
protected

Definition at line 339 of file GUIhelper.H.

◆ itsHeadless

ImGuiImage jevois::GUIhelper::itsHeadless
protected

Definition at line 354 of file GUIhelper.H.

◆ itsIcon

ImGuiImage jevois::GUIhelper::itsIcon
protected

Definition at line 353 of file GUIhelper.H.

◆ itsIdle

bool jevois::GUIhelper::itsIdle
protected

Idle state, updated by startFrame(), used by endFrame() to decide whether to draw GUI.

Definition at line 329 of file GUIhelper.H.

◆ itsImages

std::map<std::string , GPUimage> jevois::GUIhelper::itsImages
protected

Definition at line 322 of file GUIhelper.H.

◆ itsImages2

std::map<std::string , GPUimage> jevois::GUIhelper::itsImages2
protected

Definition at line 322 of file GUIhelper.H.

◆ itsLastDrawnImage

GPUimage* jevois::GUIhelper::itsLastDrawnImage = nullptr
protected

Definition at line 323 of file GUIhelper.H.

◆ itsLastDrawnTextLine

int jevois::GUIhelper::itsLastDrawnTextLine = -1
protected

Definition at line 324 of file GUIhelper.H.

◆ itsLastEventTime

std::chrono::time_point<std::chrono::steady_clock> jevois::GUIhelper::itsLastEventTime
protected

Definition at line 328 of file GUIhelper.H.

◆ itsModAuth

std::string jevois::GUIhelper::itsModAuth
protected

Definition at line 357 of file GUIhelper.H.

◆ itsModDesc

std::string jevois::GUIhelper::itsModDesc
protected

Definition at line 356 of file GUIhelper.H.

◆ itsModDoc

std::vector<std::string> jevois::GUIhelper::itsModDoc
protected

Definition at line 359 of file GUIhelper.H.

◆ itsModLang

std::string jevois::GUIhelper::itsModLang
protected

Definition at line 358 of file GUIhelper.H.

◆ itsModName

std::string jevois::GUIhelper::itsModName
protected

Definition at line 355 of file GUIhelper.H.

◆ itsNumFixedCfgItems

size_t jevois::GUIhelper::itsNumFixedCfgItems
protected

Definition at line 413 of file GUIhelper.H.

Referenced by GUIhelper().

◆ itsOpenModals

std::set<std::string> jevois::GUIhelper::itsOpenModals
protected

Definition at line 341 of file GUIhelper.H.

◆ itsRefreshCfgList

bool jevois::GUIhelper::itsRefreshCfgList = true
protected

Definition at line 414 of file GUIhelper.H.

◆ itsRefreshVideoMappings

bool jevois::GUIhelper::itsRefreshVideoMappings = false
protected

Definition at line 430 of file GUIhelper.H.

◆ itsScaledImageFacX

float jevois::GUIhelper::itsScaledImageFacX = 1.0F
protected

Definition at line 326 of file GUIhelper.H.

◆ itsScaledImageFacY

float jevois::GUIhelper::itsScaledImageFacY = 1.0F
protected

Definition at line 326 of file GUIhelper.H.

◆ itsSerLogEnabled

bool jevois::GUIhelper::itsSerLogEnabled = true
protected

Definition at line 364 of file GUIhelper.H.

◆ itsSerOutEnabled

bool jevois::GUIhelper::itsSerOutEnabled = true
protected

Definition at line 365 of file GUIhelper.H.

◆ itsShowAppMetrics

bool jevois::GUIhelper::itsShowAppMetrics = false
protected

Definition at line 362 of file GUIhelper.H.

◆ itsShowImGuiDemo

bool jevois::GUIhelper::itsShowImGuiDemo = false
protected

Definition at line 363 of file GUIhelper.H.

◆ itsShowStyleEditor

bool jevois::GUIhelper::itsShowStyleEditor = false
protected

Definition at line 361 of file GUIhelper.H.

◆ itsUsingScaledImage

bool jevois::GUIhelper::itsUsingScaledImage = false
protected

Definition at line 325 of file GUIhelper.H.

◆ itsVideoMappingListType

int jevois::GUIhelper::itsVideoMappingListType = 0
protected

Definition at line 431 of file GUIhelper.H.

◆ itsWindowTitle

std::string jevois::GUIhelper::itsWindowTitle
protected

Definition at line 352 of file GUIhelper.H.

Referenced by GUIhelper().

◆ pixel_perfect_z

const float jevois::GUIhelper::pixel_perfect_z

Z distance from camera to image plane to achieve pixel-perfect rendering.

Definition at line 288 of file GUIhelper.H.

◆ proj

glm::mat4 jevois::GUIhelper::proj

Our projection matrix.

Definition at line 291 of file GUIhelper.H.

◆ view

glm::mat4 jevois::GUIhelper::view

Our view matrix.

On the first call to startFrame(), the whole OpenGL engine is initialized and the view matrix is set so that the pixel perfect image plane is vertical and centered on the origin, while the camera is translated in negative Z to achieve pixel perfect rendering.

Definition at line 297 of file GUIhelper.H.


The documentation for this class was generated from the following files: