7. CVUI 2.7.0 組件:Text (官方文檔翻譯)

官方文檔鏈接: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;
}

運行結果
在這裏插入圖片描述

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章