JeVois
1.20
JeVois Smart Embedded Machine Vision Toolkit
|
|
#include <jevois/GPU/GUIhelper.H>
Helper class to assist modules in creating graphical and GUI elements.
This class only works on JeVois-Pro.
Definition at line 128 of file GUIhelper.H.
Classes | |
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 | idle () const |
Check for idle in case startFrame() was called elsewhere. 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 | clearErrors () |
Clear all errors currently displayed in the JeVois-Pro GUI. 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, int *default_val=nullptr, 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... | |
ImVec2 | d2i (ImVec2 p, char const *name=nullptr) |
Convert coordinates of a point from on-screen to within a rendered image. More... | |
ImVec2 | d2i (float x, float y, char const *name=nullptr) |
Convert coordinates of a point from on-screen to within a rendered image. More... | |
ImVec2 | d2is (ImVec2 p, char const *name=nullptr) |
Convert a 2D size from on-screen to within a rendered image. More... | |
ImVec2 | d2is (float x, float y, char const *name=nullptr) |
Convert a 2D size from on-screen to within a rendered image. More... | |
void | startCompilation () |
Compile a newly created module. More... | |
void | highlightText (std::string const &str) |
Like ImGui::Textunformatted but in a highlight color (typically, red) More... | |
void | demoBanner (std::string const &title="", std::string const &msg="") |
Display some text in a big banner, used by demo mode. 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... | |
Engine * | engine () 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 ¶mdescriptor, T const &val) |
Set a parameter value. More... | |
template<typename T > | |
void | setParamValUnique (std::string const ¶mdescriptor, 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 ¶mdescriptor) const |
Get parameter(s) value(s) by descriptor. More... | |
template<typename T > | |
T | getParamValUnique (std::string const ¶mdescriptor) const |
Get a parameter value, simple version assuming only one parameter match. More... | |
std::vector< std::string > | setParamString (std::string const ¶mdescriptor, std::string const &val) |
Set a parameter value, by string. More... | |
void | setParamStringUnique (std::string const ¶mdescriptor, 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 ¶mdescriptor) const |
Get a parameter value, by string. More... | |
std::string | getParamStringUnique (std::string const ¶mdescriptor) const |
Get a parameter value by string, simple version assuming only one parameter match. More... | |
void | freezeParam (std::string const ¶mdescriptor) |
Freeze a parameter, by name, see ParameterBase::freeze() More... | |
void | unFreezeParam (std::string const ¶mdescriptor) |
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... | |
template<typename T > | |
std::shared_ptr< DynamicParameter< T > > | addDynamicParameter (std::string const &name, std::string const &description, T const &defaultValue, ParameterCategory const &category) |
Add a new parameter after the Component has already been constructed. More... | |
template<typename T , template< typename > class ValidValuesSpec> | |
std::shared_ptr< DynamicParameter< T > > | addDynamicParameter (std::string const &name, std::string const &description, T const &defaultValue, ValidValuesSpec< T > const &validValuesSpec, ParameterCategory const &category) |
Add a new parameter after the Component has already been constructed. More... | |
template<typename T > | |
void | setDynamicParameterCallback (std::string const &name, std::function< void(T const &)> cb, bool callnow=true) |
Register a callback with a previously created dynamic parameter. More... | |
void | removeDynamicParameter (std::string const &name) |
Remove a previously added dynamic parameter. More... | |
void | setPath (std::string const &path) |
Assign a filesystem path to this component. More... | |
std::filesystem::path | absolutePath (std::filesystem::path 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 = 0.0F |
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 | CompilationState { Idle, Start, Cmake, Make, Install, CPack, Success, Error } |
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 | drawCamCtrls () |
void | drawTweaks () |
void | drawSystem () |
void | drawMenuBar () |
void | drawModuleSelect () |
void | drawErrorPopup () |
void | drawNewModuleForm () |
void | compileModule () |
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 ¶m, float const &newval) override |
void | onParamChange (gui::rounding const ¶m, int const &newval) override |
void | onParamChange (gui::style const ¶m, gui::GuiStyle const &newval) override |
void | onParamChange (gui::twirl const ¶m, float const &newval) override |
bool | compileCommand (std::string const &cmd, std::string &msg) |
void | runNewModule () |
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, GPUimage > | itsImages |
std::map< std::string, GPUimage > | itsImages2 |
GPUimage * | itsLastDrawnImage = 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 = true |
Idle state, updated by startFrame(), used by endFrame() to decide whether to draw GUI. More... | |
bool | itsIdleBlocked = false |
While creating/compiling new modules, prevent idle. More... | |
bool | itsEndFrameCalled = true |
std::mutex | itsErrorMtx |
std::list< ErrorData > | itsErrors |
std::set< std::string > | itsOpenModals |
bool | itsConsLock |
ImGuiBackendMALI | 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 = false |
std::shared_ptr< GUIeditor > | itsCfgEditor |
std::shared_ptr< GUIeditor > | itsCodeEditor |
std::future< std::string > | itsDnnGetFut |
bool | itsRefreshVideoMappings = false |
int | itsVideoMappingListType = 0 |
bool | itsUSBserial = false |
CompilationState | itsCompileState = CompilationState::Idle |
VideoMapping | itsNewMapping = { } |
std::future< std::string > | itsCompileFut |
std::array< std::string, 4 > | itsCompileMessages |
std::string | itsBannerTitle |
std::string | itsBannerMsg |
float | itsGlobalAlpha = 1.0F |
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(0, 0), 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... | |
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. More... | |
|
protected |
Enumerator | |
---|---|
Idle | |
Start | |
Cmake | |
Make | |
Install | |
CPack | |
Success | |
Error |
Definition at line 483 of file GUIhelper.H.
jevois::GUIhelper::GUIhelper | ( | std::string const & | instance, |
bool | conslock = false |
||
) |
Constructor.
Definition at line 43 of file GUIhelper.C.
References jevois::imu::get(), jevois::getFileString(), h, itsCfgEditor, itsCodeEditor, itsWindowTitle, LINFO, and jevois::split().
|
virtual |
|
protected |
Definition at line 553 of file GUIhelper.C.
References jevois::imu::get().
void jevois::GUIhelper::clearErrors | ( | ) |
Clear all errors currently displayed in the JeVois-Pro GUI.
In the JevoisPro GUI, errors reported via reportError() remain displayed for a few seconds, but sometimes we want to clear them right away, e.g., after DNN pipeline threw, if the user selects another one, we want the previous error to disappear immediately since it is not applicable anymore.
Definition at line 2484 of file GUIhelper.C.
|
protected |
Definition at line 2802 of file GUIhelper.C.
References jevois::async(), LERROR, LINFO, jevois::system(), and jevois::warnAndIgnoreException().
|
protected |
Definition at line 2646 of file GUIhelper.C.
ImVec2 jevois::GUIhelper::d2i | ( | float | x, |
float | y, | ||
char const * | name = nullptr |
||
) |
Convert coordinates of a point from on-screen to within a rendered image.
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 652 of file GUIhelper.C.
ImVec2 jevois::GUIhelper::d2i | ( | ImVec2 | p, |
char const * | name = nullptr |
||
) |
Convert coordinates of a point from on-screen to within a rendered image.
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 619 of file GUIhelper.C.
References jevois::GPUimage::d2i().
ImVec2 jevois::GUIhelper::d2is | ( | float | x, |
float | y, | ||
char const * | name = nullptr |
||
) |
Convert a 2D size from on-screen to within a rendered image.
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 689 of file GUIhelper.C.
ImVec2 jevois::GUIhelper::d2is | ( | ImVec2 | p, |
char const * | name = nullptr |
||
) |
Convert a 2D size from on-screen to within a rendered image.
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 656 of file GUIhelper.C.
References jevois::GPUimage::d2is().
void jevois::GUIhelper::demoBanner | ( | std::string const & | title = "" , |
std::string const & | msg = "" |
||
) |
Display some text in a big banner, used by demo mode.
Any non-empty banner remains on screen until demoBanner() called again with empty title (default args).
Definition at line 2629 of file GUIhelper.C.
|
protected |
Definition at line 1524 of file GUIhelper.C.
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 528 of file GUIhelper.C.
References jevois::imu::get().
Referenced by jevois::dnn::PostProcessorYuNet::report().
|
protected |
Definition at line 1396 of file GUIhelper.C.
References jevois::GUIconsole::draw(), jevois::Manager::getComponent(), jevois::Component::getParamValUnique(), jevois::Engine::module(), jevois::module::SerStyle, jevois::module::SerStyle_Values, jevois::Component::setParamValUnique(), and jevois::warnAndIgnoreException().
|
protected |
Definition at line 2523 of file GUIhelper.C.
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 313 of file GUIhelper.C.
References h.
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 288 of file GUIhelper.C.
References jevois::RawImage::bufindex, h, and jevois::to_string().
Referenced by jevois::dnn::PostProcessorSegment::report().
|
protected |
Definition at line 975 of file GUIhelper.C.
References jevois::Component::absolutePath(), jevois::extractString(), jevois::join(), LERROR, LINFO, jevois::split(), jevois::stringStartsWith(), and jevois::system().
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 335 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.
Referenced by __MODULE__::process().
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 365 of file GUIhelper.C.
References jevois::RawImage::bufindex, jevois::InputFrame::get2(), h, and jevois::to_string().
|
protected |
Definition at line 758 of file GUIhelper.C.
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 473 of file GUIhelper.C.
References jevois::imu::get().
Referenced by jevois::dnn::PostProcessorYuNet::report().
|
protected |
Definition at line 839 of file GUIhelper.C.
|
protected |
Definition at line 895 of file GUIhelper.C.
References JEVOISPRO_FMT_GUI, and LFATAL.
|
protected |
Definition at line 1913 of file GUIhelper.C.
References jevois::Crop(), JEVOISPRO_FMT_GUI, LFATAL, LINFO, PLFATAL, jevois::sformat(), jevois::system(), and jevois::to_string().
|
protected |
Definition at line 1157 of file GUIhelper.C.
References jevois::ParameterSummary::category, jevois::Component::foreachParam(), jevois::Range< T >::max(), jevois::Range< T >::min(), jevois::Engine::module(), jevois::ParameterSummary::name, jevois::paramStringToVal(), jevois::split(), jevois::stringStartsWith(), jevois::ParameterBase::summary(), and jevois::to_string().
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 506 of file GUIhelper.C.
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 517 of file GUIhelper.C.
|
protected |
Definition at line 491 of file GUIhelper.C.
References jevois::imu::get().
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 479 of file GUIhelper.C.
References jevois::imu::get().
Referenced by jevois::dnn::PostProcessorDetect::report(), and jevois::dnn::PostProcessorYuNet::report().
|
protected |
Definition at line 1598 of file GUIhelper.C.
References jevois::async_little(), jevois::getFanSpeed(), jevois::getFileString(), jevois::getNumInstalledNPUs(), jevois::getNumInstalledSPUs(), jevois::getNumInstalledTPUs(), jevois::getNumInstalledVPUs(), jevois::getSysInfoCPU(), jevois::getSysInfoMem(), jevois::getSysInfoVersion(), jevois::split(), jevois::stringStartsWith(), and jevois::system().
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 541 of file GUIhelper.C.
Referenced by jevois::dnn::PostProcessorDetect::report(), and jevois::dnn::PostProcessorYuNet::report().
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 547 of file GUIhelper.C.
|
protected |
Definition at line 2385 of file GUIhelper.C.
References FX().
void jevois::GUIhelper::endFrame | ( | ) |
Finish current frame and render it.
This should be called once for every call to startFrame().
Definition at line 693 of file GUIhelper.C.
References jevois::imu::get(), and LERROR.
Referenced by __MODULE__::process().
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 284 of file GUIhelper.C.
void jevois::GUIhelper::headlessDisplay | ( | ) |
Show a message that we are running headless.
Definition at line 2601 of file GUIhelper.C.
References jevois::warnAndIgnoreException().
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 2565 of file GUIhelper.C.
void jevois::GUIhelper::highlightText | ( | std::string const & | str | ) |
Like ImGui::Textunformatted but in a highlight color (typically, red)
Definition at line 2621 of file GUIhelper.C.
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 433 of file GUIhelper.C.
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 401 of file GUIhelper.C.
References jevois::GPUimage::i2d().
Referenced by jevois::dnn::PostProcessorSegment::report(), and jevois::dnn::PreProcessor::sendreport().
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 469 of file GUIhelper.C.
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 437 of file GUIhelper.C.
References jevois::GPUimage::i2ds().
bool jevois::GUIhelper::idle | ( | ) | const |
Check for idle in case startFrame() was called elsewhere.
Definition at line 227 of file GUIhelper.C.
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 584 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.
Referenced by __MODULE__::process().
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 561 of file GUIhelper.C.
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 571 of file GUIhelper.C.
References jevois::imu::get().
Referenced by __MODULE__::process(), jevois::dnn::Pipeline::process(), and jevois::dnn::PostProcessorClassify::report().
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 578 of file GUIhelper.C.
int jevois::GUIhelper::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.
Returns 1 if the first button was clicked, 2 if the second was, or some other value if no button was clicked (caller should just wait and try again at the next frame if not 1 or 2, passing again that returned value). By default, the first button is in focus. If default_val is not nullptr, add a "don't ask again" checkbox. If default_val is 1 or 2, just return that without even showing the modal.
Definition at line 1530 of file GUIhelper.C.
|
protected |
Definition at line 1583 of file GUIhelper.C.
|
overrideprotected |
|
overrideprotected |
|
overrideprotected |
|
overrideprotected |
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 605 of file GUIhelper.C.
Referenced by jevois::dnn::PostProcessorSegment::~PostProcessorSegment().
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 612 of file GUIhelper.C.
void jevois::GUIhelper::reportAndIgnoreException | ( | std::string const & | prefix = "" | ) |
Report current exception in a modal dialog, then ignore it.
Definition at line 2491 of file GUIhelper.C.
References jevois::getPythonExceptionString().
Referenced by jevois::dnn::Pipeline::process().
void jevois::GUIhelper::reportAndRethrowException | ( | std::string const & | prefix = "" | ) |
Report current exception in a modal dialog, then re-throw it.
Definition at line 2516 of file GUIhelper.C.
void jevois::GUIhelper::reportError | ( | std::string const & | err | ) |
Report an error in an overlay window.
Definition at line 2458 of file GUIhelper.C.
Referenced by jevois::dnn::Pipeline::process().
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 114 of file GUIhelper.C.
References jevois::imu::get(), h, and LFATAL.
|
protected |
Definition at line 2351 of file GUIhelper.C.
References JEVOISPRO_FMT_GUI, LERROR, and LFATAL.
bool jevois::GUIhelper::serlogEnabled | ( | ) | const |
Tell whether user enabled serlog messages to GUI console.
Definition at line 1516 of file GUIhelper.C.
bool jevois::GUIhelper::seroutEnabled | ( | ) | const |
Tell whether user enabled serout messages to GUI console.
Definition at line 1520 of file GUIhelper.C.
|
protected |
Definition at line 1149 of file GUIhelper.C.
References jevois::warnAndIgnoreException().
|
protected |
void jevois::GUIhelper::startCompilation | ( | ) |
Compile a newly created module.
This is mainly for internal use. Called by the code editor when saving C++ code to let us know to start the compilation process again. itsNewMapping should contain the new module's data.
Definition at line 2637 of file GUIhelper.C.
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 169 of file GUIhelper.C.
References jevois::imu::get(), h, LFATAL, and LINFO.
Referenced by __MODULE__::process().
bool jevois::GUIhelper::toggleButton | ( | char const * | name, |
bool * | val | ||
) |
Helper to draw a toggle button.
Definition at line 2582 of file GUIhelper.C.
|
related |
Parameter.
|
related |
Parameter.
|
related |
Parameter.
|
related |
Parameter.
|
related |
Parameter.
|
related |
Parameter.
|
related |
Parameter.
|
related |
Parameter.
|
related |
Parameter.
|
related |
Parameter.
|
related |
Parameter.
|
related |
Enum for Parameter.
|
protected |
Definition at line 420 of file GUIhelper.H.
|
protected |
Definition at line 492 of file GUIhelper.H.
|
protected |
Definition at line 492 of file GUIhelper.H.
|
protected |
Definition at line 467 of file GUIhelper.H.
Referenced by GUIhelper().
|
protected |
Definition at line 470 of file GUIhelper.H.
Referenced by GUIhelper().
|
protected |
Definition at line 486 of file GUIhelper.H.
|
protected |
Definition at line 488 of file GUIhelper.H.
|
protected |
Definition at line 484 of file GUIhelper.H.
|
protected |
Definition at line 418 of file GUIhelper.H.
|
protected |
Definition at line 432 of file GUIhelper.H.
|
protected |
Definition at line 473 of file GUIhelper.H.
|
protected |
Definition at line 402 of file GUIhelper.H.
|
mutableprotected |
Definition at line 404 of file GUIhelper.H.
|
protected |
Definition at line 411 of file GUIhelper.H.
|
protected |
Definition at line 493 of file GUIhelper.H.
|
protected |
Definition at line 426 of file GUIhelper.H.
|
protected |
Definition at line 425 of file GUIhelper.H.
|
protected |
Idle state, updated by startFrame(), used by endFrame() to decide whether to draw GUI.
Definition at line 400 of file GUIhelper.H.
|
protected |
While creating/compiling new modules, prevent idle.
Definition at line 401 of file GUIhelper.H.
|
protected |
Definition at line 393 of file GUIhelper.H.
|
protected |
Definition at line 393 of file GUIhelper.H.
|
protected |
Definition at line 394 of file GUIhelper.H.
|
protected |
Definition at line 395 of file GUIhelper.H.
|
protected |
Definition at line 399 of file GUIhelper.H.
|
protected |
Definition at line 429 of file GUIhelper.H.
|
protected |
Definition at line 428 of file GUIhelper.H.
|
protected |
Definition at line 431 of file GUIhelper.H.
|
protected |
Definition at line 430 of file GUIhelper.H.
|
protected |
Definition at line 427 of file GUIhelper.H.
|
protected |
Definition at line 485 of file GUIhelper.H.
|
protected |
Definition at line 413 of file GUIhelper.H.
|
protected |
Definition at line 476 of file GUIhelper.H.
|
protected |
Definition at line 397 of file GUIhelper.H.
|
protected |
Definition at line 397 of file GUIhelper.H.
|
protected |
Definition at line 436 of file GUIhelper.H.
|
protected |
Definition at line 437 of file GUIhelper.H.
|
protected |
Definition at line 434 of file GUIhelper.H.
|
protected |
Definition at line 435 of file GUIhelper.H.
|
protected |
Definition at line 433 of file GUIhelper.H.
|
protected |
Definition at line 480 of file GUIhelper.H.
|
protected |
Definition at line 396 of file GUIhelper.H.
|
protected |
Definition at line 477 of file GUIhelper.H.
|
protected |
Definition at line 424 of file GUIhelper.H.
Referenced by GUIhelper().
const float jevois::GUIhelper::pixel_perfect_z = 0.0F |
Z distance from camera to image plane to achieve pixel-perfect rendering.
Definition at line 317 of file GUIhelper.H.
glm::mat4 jevois::GUIhelper::proj |
Our projection matrix.
Definition at line 320 of file GUIhelper.H.
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 326 of file GUIhelper.H.