OpenCV python 绘制椭圆形
程序员文章站
2024-03-18 19:50:46
...
OpenCV python 绘制椭圆形
import numpy as np
import cv2
def main():
# 1.创建白色背景图片
d = 400
img = np.ones((d, d, 3), np.uint8) * 255
# 2.设置椭圆中心点, 长短轴
center = (round(d/2), round(d/2))
size = (100, 200)
# 2.循环绘制椭圆
for i in range(0, 10):
# 随机角度,线宽
angle = np.random.randint(0, 361)
thickness = np.random.randint(1, 9)
# 随机颜色
color = np.random.randint(0, high=256, size=(3,)).tolist()
# 绘制椭圆
cv2.ellipse(img, center, size, angle, 0, 360, color, thickness)
# 3.显示结果
cv2.imshow("img", img)
cv2.waitKey()
cv2.destroyAllWindows()
if __name__ == '__main__':
main()
处理结果图片
推荐阅读
-
OpenCV python 绘制椭圆形
-
【Linux】Ubuntu18.04使用【python2】安装PIL、opencv、numpy、matplotlib、pandas、seaborn
-
python+opencv 一个简单地检查课堂人头数的程序
-
图像分割:最大类间方差法、自适应阈值分割(基于python-opencv实现)
-
OpenCV Python 椭圆 和 FDDB 数据库
-
Python+Opencv图像处理新手入门教程(一):介绍,安装与起步
-
python实现人脸口罩检测(基于opencv和深度学习两种方法)
-
win10系统python下opencv的安装
-
Python语言-NL-Python蟒蛇绘制
-
Python语言-NL-turtle八边形绘制