【OpenCV-Python】cvui 之 图像

CVUI 之 图像

在这里插入图片描述

Python

import numpy as np
import cv2
import cvui


def image_test():
    WINDOW_NAME = 'Image-Test'

    # 创建画布
    frame = np.zeros((400, 600, 3), np.uint8)

    # 读取图像
    image = cv2.imread("lena-face.jpg", cv2.IMREAD_COLOR)
    cvui.init(WINDOW_NAME)

    while True:
        # 画布填色
        frame[:] = (100, 200, 100)

        # 写文字
        cvui.text(frame, 100, 100, 'The image component')

        # 渲染图像控件
        cvui.image(frame, 200, 256, image)

        # 显示
        cvui.imshow(WINDOW_NAME, frame)

        # ESC 退出
        if cv2.waitKey(20) == 27:
            break


if __name__ == '__main__':
    image_test()

CPP

void image(cv::Mat& theWhere, int theX, int theY, cv::Mat& theImage);

参数
theWhere: 画布
theX: 画布横坐标
theY: 画布纵坐标
theImage: 图像

cv::Mat lena_face = cv::imread("lena_face.jpg", cv::IMREAD_COLOR);
cvui::image(frame, 10, 10, lena_face);

【参考】

cvui image

猜你喜欢

转载自blog.csdn.net/zhoujinwang/article/details/129992631