JeVois
1.22
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 129 of file GUIhelper.H.
Classes | |
struct | ErrorData |
Public Member Functions | |
GUIhelper (std::string const &instance, bool conslock=false) | |
Constructor. | |
virtual | ~GUIhelper () |
Destructor. | |
bool | startFrame (unsigned short &w, unsigned short &h) |
Start a new rendering frame. | |
bool | idle () const |
Check for idle in case startFrame() was called elsewhere. | |
bool | frameStarted () const |
Helper to indicate that startFrame() was called, and thus endFrame() should be called. | |
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. | |
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. | |
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. | |
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. | |
ImVec2 | i2d (ImVec2 p, char const *name=nullptr) |
Convert coordinates of a point from within a rendered image to on-screen. | |
ImVec2 | i2d (float x, float y, char const *name=nullptr) |
Convert coordinates of a point from within a rendered image to on-screen. | |
ImVec2 | i2ds (ImVec2 p, char const *name=nullptr) |
Convert a 2D size from within a rendered image to on-screen. | |
ImVec2 | i2ds (float x, float y, char const *name=nullptr) |
Convert a 2D size from within a rendered image to on-screen. | |
void | drawLine (float x1, float y1, float x2, float y2, ImU32 col=IM_COL32(128, 255, 128, 255)) |
Draw line over an image. | |
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 | drawPoly (std::vector< cv::Point > const &pts, ImU32 col=IM_COL32(128, 255, 128, 255), bool filled=true) |
Draw polygon over an image. | |
void | drawPoly (std::vector< cv::Point2f > const &pts, ImU32 col=IM_COL32(128, 255, 128, 255), bool filled=true) |
Draw polygon over an image. | |
void | drawPoly (cv::Mat const &pts, ImU32 col=IM_COL32(128, 255, 128, 255), bool filled=true) |
Draw polygon over an image. | |
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 | 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. | |
void | drawText (float x, float y, char const *txt, ImU32 col=IM_COL32(128, 255, 128, 255)) |
Draw text over an image. | |
void | drawText (float x, float y, std::string const &txt, ImU32 col=IM_COL32(128, 255, 128, 255)) |
Draw text over an image. | |
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. | |
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 | itext (std::string const &txt, ImU32 const &col=IM_COL32_BLACK_TRANS, int line=-1) |
Draw some overlay text on top of 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. | |
void | releaseImage (char const *name) |
Release an image. | |
void | releaseImage2 (char const *name) |
Release an image, second video stream. | |
void | endFrame () |
Finish current frame and render it. | |
void | resetstate (bool modulechanged=true) |
Reset to default state, typically called on Module or video format change. | |
void | reportError (std::string const &err) |
Report an error in an overlay window. | |
void | reportAndIgnoreException (std::string const &prefix="") |
Report current exception in a modal dialog, then ignore it. | |
void | reportAndRethrowException (std::string const &prefix="") |
Report current exception in a modal dialog, then re-throw it. | |
void | clearErrors () |
Clear all errors currently displayed in the JeVois-Pro GUI. | |
void | helpMarker (char const *msg, char const *msg2=nullptr, char const *msg3=nullptr) |
Display a (?) label and show tooltip when it is hovered. | |
bool | toggleButton (char const *name, bool *val) |
Helper to draw a toggle button. | |
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. | |
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 | headlessDisplay () |
Show a message that we are running headless. | |
bool | serlogEnabled () const |
Tell whether user enabled serlog messages to GUI console. | |
bool | seroutEnabled () const |
Tell whether user enabled serout messages to GUI console. | |
ImVec2 | d2i (ImVec2 p, char const *name=nullptr) |
Convert coordinates of a point from on-screen to within a rendered image. | |
ImVec2 | d2i (float x, float y, char const *name=nullptr) |
Convert coordinates of a point from on-screen to within a rendered image. | |
ImVec2 | d2is (ImVec2 p, char const *name=nullptr) |
Convert a 2D size from on-screen to within a rendered image. | |
ImVec2 | d2is (float x, float y, char const *name=nullptr) |
Convert a 2D size from on-screen to within a rendered image. | |
void | startCompilation () |
Compile a newly created module. | |
void | highlightText (std::string const &str) |
Like ImGui::Textunformatted but in a highlight color (typically, red) | |
void | demoBanner (std::string const &title="", std::string const &msg="") |
Display some text in a big banner, used by demo mode. | |
Public Member Functions inherited from jevois::Component | |
Component (std::string const &instance) | |
Constructor. | |
virtual | ~Component () |
Virtual destructor for safe inheritance. | |
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. | |
template<class Comp > | |
void | removeSubComponent (std::shared_ptr< Comp > &component) |
Remove a sub-Component from this Component, by shared_ptr. | |
void | removeSubComponent (std::string const &instance, bool warnIfNotFound=true) |
Remove a sub-Component from this Component, by instance name. | |
template<class Comp = jevois::Component> | |
std::shared_ptr< Comp > | getSubComponent (std::string const &instance) const |
Get a sub-component by instance name. | |
bool | isTopLevel () const |
Returns true if this component is top-level, i.e., its parent is jevois::Manager. | |
bool | initialized () const |
Has this component been initialized yet? | |
std::string const & | className () const |
The class name of this component. | |
std::string const & | instanceName () const |
The instance name of this component. | |
template<typename T > | |
std::vector< std::string > | setParamVal (std::string const ¶mdescriptor, T const &val) |
Set a parameter value. | |
template<typename T > | |
void | setParamValUnique (std::string const ¶mdescriptor, T const &val) |
Set a parameter value, simple version assuming only one parameter match. | |
template<typename T > | |
std::vector< std::pair< std::string, T > > | getParamVal (std::string const ¶mdescriptor) const |
Get parameter(s) value(s) by descriptor. | |
template<typename T > | |
T | getParamValUnique (std::string const ¶mdescriptor) const |
Get a parameter value, simple version assuming only one parameter match. | |
std::vector< std::string > | setParamString (std::string const ¶mdescriptor, std::string const &val) |
Set a parameter value, by string. | |
void | setParamStringUnique (std::string const ¶mdescriptor, std::string const &val) |
Set a parameter value by string, simple version assuming only one parameter match. | |
std::vector< std::pair< std::string, std::string > > | getParamString (std::string const ¶mdescriptor) const |
Get a parameter value, by string. | |
std::string | getParamStringUnique (std::string const ¶mdescriptor) const |
Get a parameter value by string, simple version assuming only one parameter match. | |
void | freezeParam (std::string const ¶mdescriptor, bool doit) |
Freeze/unfreeze a parameter, by name, see ParameterBase::freeze() | |
void | freezeAllParams (bool doit) |
Freeze all parameters. | |
std::string | descriptor () const |
Get our full descriptor (including all parents) as [Instancename]:[...]:[...]. | |
void | setParamsFromFile (std::string const &filename) |
Set some parameters from a file. | |
std::istream & | setParamsFromStream (std::istream &is, std::string const &absfile) |
Set some parameters from an open stream. | |
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. | |
void | foreachParam (std::function< void(std::string const &compname, ParameterBase *p)> func, std::string const &cname="") |
Run a function on every param we hold. | |
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. | |
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. | |
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. | |
void | removeDynamicParameter (std::string const &name, bool throw_if_not_found=true) |
Remove a previously added dynamic parameter. | |
void | setPath (std::string const &path) |
Assign a filesystem path to this component. | |
std::filesystem::path | absolutePath (std::filesystem::path const &path="") |
If given path is relative (not starting with /), prepend the Component path to it. | |
Public Member Functions inherited from jevois::ParameterRegistry | |
virtual | ~ParameterRegistry () |
Virtual destructor for safe inheritance. | |
Public Attributes | |
float const | pixel_perfect_z = 0.0F |
Z distance from camera to image plane to achieve pixel-perfect rendering. | |
glm::mat4 | proj |
Our projection matrix. | |
glm::mat4 | view |
Our view matrix. | |
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. | |
virtual void | postInit () |
Called after all sub-Components are init()ed. | |
virtual void | preUninit () |
Called before all sub-Components are uninit()ed. | |
virtual void | postUninit () |
Called after all sub-Components are uninit()ed. | |
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. | |
void | removeParameter (ParameterBase *const param) |
The Parameter class uses this method to un-register itself on destruction with its owning Component. | |
void | callbackInitCall () |
For all parameters that have a callback which has never been called, call it with the default param value. | |
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. | |
bool | itsIdleBlocked = false |
While creating/compiling new modules, prevent idle. | |
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 |
bool | itsShowHardSerialWin = false |
bool | itsShowUsbSerialWin = 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 Symbols | |
(Note that these are not member symbols.) | |
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. | |
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 (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. | |
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. | |
JEVOIS_DEFINE_ENUM_CLASS (GuiStyle,(Light)(Dark)(Classic)) | |
Enum for Parameter. | |
JEVOIS_DECLARE_PARAMETER_WITH_CALLBACK (style, GuiStyle, "Color style for the JeVois GUI", GuiStyle::Light, GuiStyle_Values, ParamCateg) | |
Parameter. | |
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. | |
JEVOIS_DECLARE_PARAMETER (overlaycolor, ImColor, "Default color to use for overlay text", ImColor(255, 255, 255, 255), ParamCateg) | |
Parameter. | |
JEVOIS_DECLARE_PARAMETER (linethick, float, "Line thickness for overlay drawings", 5.0F, jevois::Range< float >(0.1F, 20.0F), ParamCateg) | |
Parameter. | |
JEVOIS_DECLARE_PARAMETER (fillalpha, float, "Alpha multiplier for overlay fills", 0.25F, jevois::Range< float >(0.0F, 1.0F), ParamCateg) | |
Parameter. | |
JEVOIS_DECLARE_PARAMETER (allowquit, bool, "Quit application on ESC key (platform) or window close (host)", false, ParamCateg) | |
Parameter. | |
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. | |
|
protected |
Enumerator | |
---|---|
Idle | |
Start | |
Cmake | |
Make | |
Install | |
CPack | |
Success | |
Error |
Definition at line 511 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::getFileString(), h, itsCfgEditor, itsCodeEditor, itsWindowTitle, JEVOIS_CUSTOM_DNN_PATH, JEVOIS_PYDNN_PATH, JEVOIS_ROOT_PATH, JEVOIS_VERSION_STRING, LINFO, and jevois::split().
|
virtual |
|
protected |
Definition at line 636 of file GUIhelper.C.
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 2631 of file GUIhelper.C.
bool jevois::GUIhelper::combo | ( | std::string const & | name, |
std::vector< std::string > const & | items, | ||
int & | selected_index | ||
) |
Helper to draw a combobox from a vector of strings.
Note that selected_index is read-write: the passed value is used to display the current item in the combobox, and, when a new item is selected, its index is returned in selected_index and true is returned.
Definition at line 1710 of file GUIhelper.C.
Referenced by jevois::dnn::Pipeline::showDataPeekWindow().
|
protected |
Definition at line 3002 of file GUIhelper.C.
References jevois::async(), LERROR, LINFO, jevois::system(), and jevois::warnAndIgnoreException().
|
protected |
Definition at line 2816 of file GUIhelper.C.
References LERROR, LINFO, and jevois::Engine::reloadVideoMappings().
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 735 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 702 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 772 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 739 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 2776 of file GUIhelper.C.
|
protected |
Definition at line 1651 of file GUIhelper.C.
References jevois::Engine::drawCameraGUI().
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(). Color order is IMCOL_32(R,G,B,A).
Definition at line 598 of file GUIhelper.C.
Referenced by jevois::dnn::PostProcessorPose::report(), and jevois::dnn::PostProcessorYuNet::report().
|
protected |
Definition at line 1516 of file GUIhelper.C.
References jevois::GUIconsole::draw(), jevois::Manager::getComponent(), jevois::Component::getParamValUnique(), jevois::Engine::module(), jevois::Component::setParamValUnique(), and jevois::warnAndIgnoreException().
void jevois::GUIhelper::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.
Coordinates used should be image coordinates, as this function internally calls i2d().
Definition at line 611 of file GUIhelper.C.
|
protected |
Definition at line 2670 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 312 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 287 of file GUIhelper.C.
References jevois::RawImage::bufindex, and h.
Referenced by jevois::dnn::PostProcessorSegment::report().
|
protected |
Definition at line 1100 of file GUIhelper.C.
References jevois::extractString(), jevois::Engine::getCurrentVideoMapping(), JEVOIS_SHARE_PATH, jevois::join(), LERROR, LINFO, jevois::VideoMapping::modinfopath(), jevois::Engine::module(), jevois::VideoMapping::modulename, 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 334 of file GUIhelper.C.
References jevois::RawImage::bufindex, jevois::InputFrame::get(), jevois::InputFrame::get2(), h, jevois::InputFrame::hasScaledImage(), jevois::RawImage::height, and jevois::RawImage::width.
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 364 of file GUIhelper.C.
References jevois::RawImage::bufindex, jevois::InputFrame::get2(), and h.
|
protected |
Definition at line 841 of file GUIhelper.C.
References jevois::Manager::getComponent().
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(). Color order is IMCOL_32(R,G,B,A).
Definition at line 472 of file GUIhelper.C.
Referenced by jevois::dnn::PostProcessorPose::report(), and jevois::dnn::PostProcessorYuNet::report().
|
protected |
Definition at line 964 of file GUIhelper.C.
References jevois::Engine::quit().
|
protected |
Definition at line 1020 of file GUIhelper.C.
References JEVOISPRO_FMT_GUI, LFATAL, jevois::VideoMapping::menustr(), and jevois::VideoMapping::ofmt.
|
protected |
Definition at line 2060 of file GUIhelper.C.
References jevois::VideoMapping::c2fmt, jevois::VideoMapping::c2h, jevois::VideoMapping::c2w, jevois::VideoMapping::cfmt, jevois::VideoMapping::cfps, jevois::VideoMapping::ch, jevois::VideoMapping::cmakepath(), jevois::VideoMapping::crop, jevois::VideoMapping::cw, jevois::VideoMapping::ispython, JEVOIS, JEVOIS_MODULE_PATH, JEVOIS_SHARE_PATH, JEVOISPRO_FMT_GUI, LFATAL, LINFO, jevois::VideoMapping::menustr2(), jevois::VideoMapping::modulename, jevois::VideoMapping::ofmt, jevois::VideoMapping::ofps, jevois::VideoMapping::oh, jevois::VideoMapping::ow, jevois::VideoMapping::path(), PLFATAL, jevois::sformat(), jevois::VideoMapping::srcpath(), jevois::VideoMapping::str(), jevois::system(), jevois::VideoMapping::vendor, and jevois::VideoMapping::wdr.
|
protected |
Definition at line 1282 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(), and jevois::ParameterBase::summary().
void jevois::GUIhelper::drawPoly | ( | cv::Mat const & | pts, |
ImU32 | col = IM_COL32(128,255,128,255) , |
||
bool | filled = true |
||
) |
Draw polygon over an image.
For N vertices, pts should be either CV_32F and 2xN or Nx2 for x,x,x,x,... y,y,y,y,..., or 1x2N or 2Nx1 for x,y,x,y,x,y...; or CV_32FC2 and 1xN or Nx1. If N < 2, nothing is drawn. Other shapes are illegal. Color order is IMCOL_32(R,G,B,A).
Definition at line 538 of file GUIhelper.C.
References LFATAL, and jevois::dnn::shapestr().
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(). Color order is IMCOL_32(R,G,B,A).
Definition at line 514 of file GUIhelper.C.
Referenced by jevois::dnn::PostProcessorDetect::report(), and jevois::dnn::PostProcessorDetectOBB::report().
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(). Color order is IMCOL_32(R,G,B,A).
Definition at line 526 of file GUIhelper.C.
|
protected |
Definition at line 492 of file GUIhelper.C.
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(). Color order is IMCOL_32(R,G,B,A).
Definition at line 478 of file GUIhelper.C.
Referenced by jevois::dnn::PostProcessorDetect::report(), jevois::dnn::PostProcessorPose::report(), and jevois::dnn::PostProcessorYuNet::report().
|
protected |
Definition at line 1739 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_CUSTOM_DNN_PATH, JEVOIS_CUSTOM_DNN_URL, JEVOIS_VERSION_STRING, JEVOISPRO_GSERIAL_FILE, 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(). Color order is IMCOL_32(R,G,B,A).
Definition at line 624 of file GUIhelper.C.
Referenced by jevois::dnn::PostProcessorDetect::report(), jevois::dnn::PostProcessorDetectOBB::report(), jevois::dnn::PostProcessorPose::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(). Color order is IMCOL_32(R,G,B,A).
Definition at line 630 of file GUIhelper.C.
|
protected |
Definition at line 2532 of file GUIhelper.C.
References drawTinyImGUIdemo().
void jevois::GUIhelper::endFrame | ( | ) |
Finish current frame and render it.
This should be called once for every call to startFrame().
Definition at line 776 of file GUIhelper.C.
References jevois::Engine::abortDemo(), LERROR, and jevois::Engine::nextDemo().
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 283 of file GUIhelper.C.
void jevois::GUIhelper::headlessDisplay | ( | ) |
Show a message that we are running headless.
Definition at line 2748 of file GUIhelper.C.
References JEVOIS_SHARE_PATH, and 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 2712 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 2768 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 432 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 400 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 468 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 436 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 667 of file GUIhelper.C.
References jevois::fccstr(), jevois::RawImage::fmt, jevois::InputFrame::get(), jevois::InputFrame::get2(), jevois::InputFrame::hasScaledImage(), jevois::RawImage::height, jevois::sformat(), and jevois::RawImage::width.
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 644 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 654 of file GUIhelper.C.
Referenced by 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 661 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 1657 of file GUIhelper.C.
|
protected |
Definition at line 1724 of file GUIhelper.C.
|
overrideprotected |
|
overrideprotected |
|
overrideprotected |
|
overrideprotected |
Definition at line 388 of file GUIhelper.C.
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 688 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 695 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 2638 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 2663 of file GUIhelper.C.
void jevois::GUIhelper::reportError | ( | std::string const & | err | ) |
Report an error in an overlay window.
Definition at line 2605 of file GUIhelper.C.
Referenced by jevois::dnn::Pipeline::showDataPeekWindow().
void jevois::GUIhelper::resetstate | ( | 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::VideoMapping::cmakepath(), jevois::Engine::getCurrentVideoMapping(), jevois::Component::getParamStringUnique(), h, and LFATAL.
|
protected |
Definition at line 2498 of file GUIhelper.C.
References jevois::Engine::foreachVideoMapping(), JEVOISPRO_FMT_GUI, LERROR, LFATAL, jevois::Engine::reloadVideoMappings(), and jevois::Engine::requestSetFormat().
bool jevois::GUIhelper::serlogEnabled | ( | ) | const |
Tell whether user enabled serlog messages to GUI console.
Definition at line 1643 of file GUIhelper.C.
bool jevois::GUIhelper::seroutEnabled | ( | ) | const |
Tell whether user enabled serout messages to GUI console.
Definition at line 1647 of file GUIhelper.C.
|
protected |
Definition at line 1274 of file GUIhelper.C.
References jevois::Component::setParamStringUnique(), and 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 2784 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 h, LFATAL, LINFO, and jevois::Engine::quit().
bool jevois::GUIhelper::toggleButton | ( | char const * | name, |
bool * | val | ||
) |
Helper to draw a toggle button.
Definition at line 2729 of file GUIhelper.C.
Referenced by jevois::dnn::Pipeline::showDataPeekWindow().
|
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 446 of file GUIhelper.H.
|
protected |
Definition at line 520 of file GUIhelper.H.
|
protected |
Definition at line 520 of file GUIhelper.H.
|
protected |
Definition at line 495 of file GUIhelper.H.
Referenced by GUIhelper().
|
protected |
Definition at line 498 of file GUIhelper.H.
Referenced by GUIhelper().
|
protected |
Definition at line 514 of file GUIhelper.H.
|
protected |
Definition at line 516 of file GUIhelper.H.
|
protected |
Definition at line 512 of file GUIhelper.H.
|
protected |
Definition at line 444 of file GUIhelper.H.
|
protected |
Definition at line 458 of file GUIhelper.H.
|
protected |
Definition at line 501 of file GUIhelper.H.
|
protected |
Definition at line 428 of file GUIhelper.H.
|
mutableprotected |
Definition at line 430 of file GUIhelper.H.
|
protected |
Definition at line 437 of file GUIhelper.H.
|
protected |
Definition at line 521 of file GUIhelper.H.
|
protected |
Definition at line 452 of file GUIhelper.H.
|
protected |
Definition at line 451 of file GUIhelper.H.
|
protected |
Idle state, updated by startFrame(), used by endFrame() to decide whether to draw GUI.
Definition at line 426 of file GUIhelper.H.
|
protected |
While creating/compiling new modules, prevent idle.
Definition at line 427 of file GUIhelper.H.
|
protected |
Definition at line 419 of file GUIhelper.H.
|
protected |
Definition at line 419 of file GUIhelper.H.
|
protected |
Definition at line 420 of file GUIhelper.H.
|
protected |
Definition at line 421 of file GUIhelper.H.
|
protected |
Definition at line 425 of file GUIhelper.H.
|
protected |
Definition at line 455 of file GUIhelper.H.
|
protected |
Definition at line 454 of file GUIhelper.H.
|
protected |
Definition at line 457 of file GUIhelper.H.
|
protected |
Definition at line 456 of file GUIhelper.H.
|
protected |
Definition at line 453 of file GUIhelper.H.
|
protected |
Definition at line 513 of file GUIhelper.H.
|
protected |
Definition at line 439 of file GUIhelper.H.
|
protected |
Definition at line 504 of file GUIhelper.H.
|
protected |
Definition at line 423 of file GUIhelper.H.
|
protected |
Definition at line 423 of file GUIhelper.H.
|
protected |
Definition at line 462 of file GUIhelper.H.
|
protected |
Definition at line 463 of file GUIhelper.H.
|
protected |
Definition at line 460 of file GUIhelper.H.
|
protected |
Definition at line 464 of file GUIhelper.H.
|
protected |
Definition at line 461 of file GUIhelper.H.
|
protected |
Definition at line 459 of file GUIhelper.H.
|
protected |
Definition at line 465 of file GUIhelper.H.
|
protected |
Definition at line 508 of file GUIhelper.H.
|
protected |
Definition at line 422 of file GUIhelper.H.
|
protected |
Definition at line 505 of file GUIhelper.H.
|
protected |
Definition at line 450 of file GUIhelper.H.
Referenced by GUIhelper().
float const jevois::GUIhelper::pixel_perfect_z = 0.0F |
Z distance from camera to image plane to achieve pixel-perfect rendering.
Definition at line 338 of file GUIhelper.H.
glm::mat4 jevois::GUIhelper::proj |
Our projection matrix.
Definition at line 341 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 347 of file GUIhelper.H.