如何在OpenCV绘图功能中添加断点线(虚线/点线),例如
cv2.line()
,cv2.rectangle()
?是否有一种适用于断点线的线型?cv2.line()
,cv2.rectangle()
?是否有一种适用于断点线的线型?y = 100 # vertical position of the line
thickness = 2 # thickness of the line
x0 = 0 # leftmost part of the line
x1 = img.shape[1] # rightmost part of the line
on_time = 10 # pixels out of period that are solid
period = 20 # period between dashes
colour = (0, 0, 255)
img[
y - thickness // 2:y + thickness // 2,
[x for x in range(x0, x1) if x % period < on_time]
] = colour