如何在OpenCV绘图函数(如cv2.line()
、cv2.rectangle()
)中添加断线(虚线/虚线)?
有用于断线的线型吗?
发布于 2022-07-13 18:23:21
如果这条线是水平的或垂直的,你可以这样做。有点烦人,但如果你不需要任何花哨的东西,你只需几行就能把工作做完。
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
https://stackoverflow.com/questions/40319980
复制相似问题