带有虚线或虚线的opencv多边形

时间:2023-02-10 00:17:37

I have a line of code here that uses the python binding for opencv:

我在这里有一行代码,它使用opencv的python绑定:

cv2.polylines(mask, [pts],True, ignore_mask_color)

This draws a blue polygon on image mask.

这会在图像蒙版上绘制蓝色多边形。

But is there a way the lines of the polygon can be stylized? Not too much. Just dotted, or dashed, that's it really.

但有多种方法可以将多边形的线条风格化?不是太多。只是点缀,或虚线,这是真的。

1 个解决方案

#1


0  

In addition to color you can use the thickness annd lineType arguments in cv2.polylines method. Refer the OpenCV docs for cv2.polylines for more detail.

除了颜色,您还可以使用cv2.polylines方法中的thickness和lineType参数。有关cv2.polylines的详细信息,请参阅OpenCV文档。

Unfortunately, the only options you can get for lineType in here would be

不幸的是,你可以在这里获得lineType的唯一选择

  • 8 (or omitted) - 8-connected line.
  • 8(或省略) - 8连接线。

  • 4 - 4-connected line.
  • 4 - 4连接线。

  • CV_AA - antialiased line.
  • CV_AA - 抗锯齿线。

Not sure why OpenCV hasn't got a direct way to implement this yet. However, this post might help you achieve what you require.

不知道为什么OpenCV还没有直接的方法来实现它。但是,这篇文章可能会帮助您实现所需。

#1


0  

In addition to color you can use the thickness annd lineType arguments in cv2.polylines method. Refer the OpenCV docs for cv2.polylines for more detail.

除了颜色,您还可以使用cv2.polylines方法中的thickness和lineType参数。有关cv2.polylines的详细信息,请参阅OpenCV文档。

Unfortunately, the only options you can get for lineType in here would be

不幸的是,你可以在这里获得lineType的唯一选择

  • 8 (or omitted) - 8-connected line.
  • 8(或省略) - 8连接线。

  • 4 - 4-connected line.
  • 4 - 4连接线。

  • CV_AA - antialiased line.
  • CV_AA - 抗锯齿线。

Not sure why OpenCV hasn't got a direct way to implement this yet. However, this post might help you achieve what you require.

不知道为什么OpenCV还没有直接的方法来实现它。但是,这篇文章可能会帮助您实现所需。