1

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

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.

Martin Evans
  • 45,791
  • 17
  • 81
  • 97
prosenjit
  • 805
  • 3
  • 9
  • 10

1 Answers1

2

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.

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

  • 8 (or omitted) - 8-connected line.
  • 4 - 4-connected line.
  • CV_AA - antialiased line.

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

Ébe Isaac
  • 11,563
  • 17
  • 64
  • 97
  • 1
    It's puzzling that this question seems to use the exact same wording as the post you link as "this post" in this answer. – Harun May 08 '18 at 11:45
  • 2
    @Harun Can't believe I didn't notice that. You're absolutely right. This is more than a duplicate question; it's verbatim! – Ébe Isaac May 08 '18 at 11:48
  • @Harun Thanks for replying. I have used the same words intentionally. As the rectangle has the solution, I used the same words for polygon to getting the solution. – prosenjit May 08 '18 at 14:38