在Opencv中绘制虚线的断点线。

3
如何在OpenCV绘图功能中添加断点线(虚线/点线),例如cv2.line()cv2.rectangle()?是否有一种适用于断点线的线型?

1
你说的“断行”是什么意思?或许可以阅读一下OpenCV文档。 - furas
2
断行意味着虚线/破折号。 - user119o
1
@userblock25 那你为什么不去更新你的问题,而不是让这个误导性的文本留在那里呢? - Dan Mašek
1
@userblock25 哦,你是说“breaklines”(一个单词)。这就解释了一切 :) - Dan Mašek
1
可能是opencv带虚线或点线的矩形的重复问题。 - Yohai Devir
显示剩余2条评论
1个回答

1
如果线条是水平或垂直的,您可以像这样操作。有点“hacky”,但如果您不需要任何花哨的东西,只需几行代码即可完成工作。
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

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接