What is the difference between cv2.polylines, cv2.fillPoly, and cv2.drawContours?

Why does opencv have these different functions which all appear doing something very similar?

In my application I am working with arrays that contain coordinates, and I realized that the outcome when feeding them to polylines and drawContours is essentially the same. So I am wondering why I should care about using one over the other, as I have done in the past? It’s extra effort to make this distinction…

1 Like

polylines and fillpoly differ in that one brushes/fills them, the other strokes/draws the outline.

drawContours has special machinery to handle a contours array plus hierarchy information.

yes, there appears to be little thought behind this proliferation. it could all be done by one function and some optional arguments. the API grew and I suspect these functions grew 20 years ago and won’t be deprecated any time soon… except if someone completely overhauls all the drawing in OpenCV, which would be nice.

1 Like