官方文档链接:https://dovyski.github.io/cvui/components/text/
Text
cvui::text() 渲染一段字符串。函数声明为:
void text (
cv::Mat& theWhere,
int theX,
int theY,
const cv::String& theText,
double theFontScale = 0.4,
unsigned int theColor = 0xCECECE
)
theWhere 是渲染图像的图像/帧,theX 是 X 的坐标,theY 是 Y 的坐标,theText 是文字内容,theFontScale 是文字的字号大小,theColor 是文字的颜色,格式为 0xRRGGBB,例如:0xff0000 表示红色。
下面是 text 组件的示例以及结果展示:
#define CVUI_IMPLEMENTATION
#define CVUI_DISABLE_COMPILATION_NOTICES
#include "cvui.h"
#include <iostream>
#include <opencv2/core/core.hpp>
#include <opencv2/imgcodecs/imgcodecs.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>
#define WINDOW_NAME "CVUI Test"
int main(int argc, char** argv)
{
cvui::init(WINDOW_NAME);
cv::Mat frame = cv::Mat(cv::Size(600, 200), CV_8UC3);
frame = cv::Scalar(49, 52, 200);
cvui::text(frame, 50, 90, "This is my first Text!", 1.5, 0xffff00);
cvui::imshow(WINDOW_NAME, frame);
cv::waitKey(0);
return 0;
}
运行结果