我有这个密码。它拍摄图像并在定义的点上绘制椭圆。像这样sample。但我正在努力想我该如何在里面填充颜色呢
def annotate_image(annotations, i):
file_name = annotations[i][0]
PATH= "/content/content/train/Class1_def/"+file_name+'.png'
img=cv2.imread(PATH)
#print(img.shape)
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
semi_major= int(float(annotations[i][1]))
semi_minor= int(float(annotations[i][2]))
rotation= int(float(annotations[i][3]))
x_pos_ellip= int(float(annotations[i][4]))
y_pos_ellip= int(float(annotations[i][5]))
center_coordinates= (x_pos_ellip, y_pos_ellip)
axesLength= (semi_major,semi_minor)
angle= int(float(rotation))
startAngle = 0
endAngle = 360
# Red color
color = (255, 0, 0)
# Line thickness
thickness = 2
cv2.ellipse(img, center_coordinates, axesLength,
angle, startAngle, endAngle, color, thickness)
return img
“厚度”参数使用负值。从docs on ^{} 开始:
OpenCV的所有闭合形状绘图函数都是如此。如果同时需要填充和单独的笔划,只需先绘制填充椭圆,然后在顶部绘制笔划
设置
thickness = -1
,这将填充其中的颜色相关问题 更多 >
编程相关推荐