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[:]=255
while 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' % a
cv2.putText(yuan, text=text, org=(x1, y1), fontFace=font, fontScale=0.9, color=(255, 255, 255),
thickness=1) # text,
if a == 10:
a=a+0
else:
cv2.putText(yuan, text=text, org=(x2, y2), fontFace=font, fontScale=0.9, color=(255, 255, 255),
thickness=1) # text,
x1=x1+30
y2=y2+30
if a==10:
b=-1
x1=x1+24
y2=y2+24
a = a + b
cv2.imshow('yuan', yuan) # 显示图片
cv2.waitKey(0)
cv2.destroyAllWindows()