Loading...
Searching...
No Matches
Form based GUI
Prev Tutorial: Custom Source and Sink
Next Tutorial: V4D
Original author | Amir Hassan (kallaballa) amir@.nosp@m.viel.nosp@m.-zu.o.nosp@m.rg |
Compatibility | OpenCV >= 4.7 |
Font rendering with form based GUI
Draws "Hello World" to the screen and let's you control the font size and color with a GUI.
Downloading...
#include <opencv2/v4d/v4d.hpp>
using namespace cv;
using namespace cv::v4d;
struct Params {
//The font size
float size_ = 40.0f;
//The text hue
cv::Scalar_<float> color_ = {1.0f, 0.0f, 0.0f, 1.0f};
} params_;
//The text
string hw_ = "hello world";
public:
window->imgui([](Ptr<V4D> win, ImGuiContext* ctx, Params& params) {
CV_UNUSED(win);
using namespace ImGui;
SetCurrentContext(ctx);
Begin("Settings");
SliderFloat("Font Size", ¶ms.size_, 1.0f, 100.0f);
ColorPicker4("Text Color", params.color_.val);
End();
}, params_);
}
//Render the text at the center of the screen using parameters from the GUI.
using namespace cv::v4d::nvg;
clear();
fontFace("sans-bold");
textAlign(NVG_ALIGN_CENTER | NVG_ALIGN_TOP);
}, window->fbSize(), hw_, params_);
}
};
int main() {
Ptr<V4D> window = V4D::make(960, 960, "Font Rendering with GUI");
window->run<FontWithGuiPlan>(0);
}
Definition: v4d.hpp:68
PyParams params(const std::string &tag, const std::string &model, const std::string &weights, const std::string &device)
Net::Result infer(cv::GOpaque< cv::Rect > roi, T in)
Calculates response for the specified network (template parameter) for the specified region in the so...
Definition: infer.hpp:474
Definition: nvg.hpp:20
void textAlign(int align)
void fontSize(float size)
void fontFace(const char *font)
void fillColor(const cv::Scalar &color)
void clear(const cv::Scalar &bgra=cv::Scalar(0, 0, 0, 255))
float text(float x, float y, const char *string, const char *end)
Definition: backend.hpp:15
"black box" representation of the file storage associated with a file on disk.
Definition: core.hpp:106