11. CVUI 2.7.0 组件:Window 【有问题 未解决】(官方文档翻译)

官方文档链接:https://dovyski.github.io/cvui/components/window/


Window

cvui::window() 渲染一个窗口(一个带有标题和主题的块),函数声明如下:

void window (
    cv::Mat& theWhere,
    int theX,
    int theY,
    int theWidth,
    int theHeight,
    const cv::String& theTitle
)

theWhere 是用于渲染图像的图像/帧,theX 是 X 坐标,theY 是 Y 坐标,theWidth 是 window 的宽度,theHeight 是 window 的高度,theTitle 是显示为标题的文本。

下面是一个 window 的示例和输出结果:以下示例是直接从官方文档中贴过来的,本人在编写程序时总是报错,目前还没有解决,下面贴出了本人的代码,希望能有大佬帮忙解答,不胜感激

核心语句

cvui::window(frame, 60, 10, 130, 90, "Title");

输出结果

在这里插入图片描述

cvui::window() 可以用作其他 UI 组件的背景,特别是将它们与屏幕上的其他元素区分开来。下面是用作另一个组件背景的 cvui::window() :

在这里插入图片描述
问题代码

#define CVUI_IMPLEMENTATION
#define CVUI_DISABLE_COMPILATION_NOTICES
#include "cvui.h"

#include <iostream>

#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/imgcodecs/imgcodecs.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(400, 500), CV_8UC3);

	while (true)
	{
		frame = cv::Scalar(100, 100, 100);

		cvui::window(frame, 50, 100, 100, 100, "Window");

		cvui::imshow(WINDOW_NAME, frame);

		if (cv::waitKey(20) == 27)
			break;
	}


	return 0;
}

错误提示

在这里插入图片描述
在这里插入图片描述

发布了73 篇原创文章 · 获赞 14 · 访问量 3万+

猜你喜欢

转载自blog.csdn.net/wangyuankl123/article/details/105405036