【深度学习】OpenCV——基本图形绘制:矩形、文字、圆、直线、椭圆、多边形
OpenCV的基本图形绘制,主要掌握矩形和文字的绘制。""" Python 绘制文字"""import cv2import numpy as npimg = cv2.imread(r"../Image/SpongeBobSquarePants.jpg")print(img.shape)""" 绘制直线 """cv2.line(img,(0,0), (100,100), (110,110,110),
·
OpenCV的基本图形绘制,主要掌握矩形和文字的绘制。
""" Python 绘制文字"""
import cv2
import numpy as np
img = cv2.imread(r"../Image/SpongeBobSquarePants.jpg")
print(img.shape)
""" 绘制直线 """
cv2.line(img,(0,0), (100,100), (110,110,110),thickness=2)
""" 绘制圆 thickness=-1 为填充 """
cv2.circle(img,(50, 50),50, (255, 0, 0), thickness=-1)
""" 绘制矩形 """
cv2.rectangle(img,(0,0),(100,100),(0,255,0), thickness=2)
""" 椭圆 """
cv2.ellipse(img, (200,200), (100, 40),angle=25,startAngle=180, endAngle=360, color=(255,200, 255),thickness=2)
"""
angle 为椭圆旋转角度
startAngle 为起始角度
endAngle 为终止角度,主要用来选择保留椭圆的那部分
"""
""" 画多边形 """
pts = np.array([[10,5],[100,220],[410,57],[110,11],])
cv2.polylines(img, [pts], isClosed=True,color=(10, 10,255),thickness=2)
""" 绘制文字 lineType=cv2.LINE_AA抗锯齿 """
cv2.putText(img, 'SpongeBob SquarePants', (10, 30), cv2.FONT_HERSHEY_SIMPLEX, fontScale=1,color=(0, 0, 255), thickness=1, lineType=cv2.LINE_AA)
cv2.imshow("pic show", img)
cv2.waitKey(0)
作者:阳一子
本文地址:https://blog.csdn.net/qq_279033270/article/details/110235515
更多推荐
所有评论(0)