#!/usr/bin/env python3
# -*- coding:UTF8 -*-
"""
使用函数cv2.line,cv2.rectangle
cv2.circle,cv2.ellipse,cv2.polylines,cv2.putText进行创作
"""
import cv2 as cv
import numpy as np
# 创建一张灰白色的图片
img = np.ones((500, 500, 3), np.uint8) * 127
# 绘制线段
cv.line(img, (60, 240), (220, 240), (0, 0, 255), 3, cv.LINE_AA)
cv.line(img, (140, 160), (140, 320), (0, 0, 255), 3, cv.LINE_AA)
# 绘制矩形
cv.rectangle(img, (100, 200), (180, 280), (0, 255, 255), 3, cv.LINE_AA)
cv.rectangle(img, (80, 180), (200, 300), (0, 255, 255), 3, cv.LINE_AA)
cv.rectangle(img, (60, 160), (220, 320), (0, 255, 255), 3, cv.LINE_AA)
# 绘制圆
cv.circle(img, (140, 240), 80, (255, 255, 0), 2, cv.LINE_AA)
cv.circle(img, (140, 240), 60, (255, 255, 0), 2, cv.LINE_AA)
cv.circle(img, (140, 240), 40, (255, 255, 0), 2, cv.LINE_AA)
# 绘制椭圆
cv.ellipse(img, (140, 80), (100, 50), 0, 0, 360, (0, 255, 0), 2, cv.LINE_AA)
cv.ellipse(img, (140, 80), (90, 40), 0, 0, 90, (255, 0, 0), 2, cv
opencv——图像图形绘制
最新推荐文章于 2024-03-27 12:23:17 发布