10环圆靶
使用python画一个10环圆靶
import cv2
import numpy as np
i=11
dot_red=(300,300) #圆心
black=(0,0,0) #黑色
red = (0, 0, 255) #红色
white=(255,255,255) #白色
blue=(255,0,0) #蓝色
green=(0,255,0) #绿色
gray=(185,188,178) #灰色
font = cv2.FONT_HERSHEY_SIMPLEX #字体
yuan = np.zeros((600, 600, 3), np.uint8)
yuan[:]=255while i>1:i=i-1#print(i)radius = (i*30)if i==10:cv2.circle(yuan, dot_red, radius, black, -1)elif i==9:cv2.circle(yuan, dot_red, radius, white, 1)elif i==8:cv2.circle(yuan, dot_red, radius, gray, -1)elif i==7:cv2.circle(yuan, dot_red, radius, black, 1)elif i==6:cv2.circle(yuan, dot_red, radius, blue, -1)elif i==5:cv2.circle(yuan, dot_red, radius, white, 1)elif i==4:cv2.circle(yuan, dot_red, radius, red, -1)elif i==3:cv2.circle(yuan, dot_red, radius, white, 1)elif i==2:cv2.circle(yuan, dot_red, radius, green, -1)elif i==1:cv2.circle(yuan, dot_red, radius, red, 1)#显示字
a=1
b=1
x1 = 9
y1 = 310
x2=290
y2=27
while a>0:text = '%d' % acv2.putText(yuan, text=text, org=(x1, y1), fontFace=font, fontScale=0.9, color=(255, 255, 255),thickness=1) # text,if a == 10:a=a+0else:cv2.putText(yuan, text=text, org=(x2, y2), fontFace=font, fontScale=0.9, color=(255, 255, 255),thickness=1) # text,x1=x1+30y2=y2+30if a==10:b=-1x1=x1+24y2=y2+24a = a + bcv2.imshow('yuan', yuan) # 显示图片
cv2.waitKey(0)
cv2.destroyAllWindows()
本文发布于:2024-02-02 22:23:40,感谢您对本站的认可!
本文链接:https://www.4u4v.net/it/170688382146829.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
留言与评论(共有 0 条评论) |