I have the following code:
import cv2
import numpy
ar = numpy.zeros((10,10))
triangle = numpy.array([ [1,3], [4,8], [1,9] ], numpy.int32)
cv2.fillPoly
and cv2.fillConvexPoly
use different data types for their point arrays, because fillConvexPoly
draws only one polygon and fillPoly
draws a (python) list of them. Thus,
cv2.fillConvexPoly(ar, triangle, 1)
cv2.fillPoly(ar, [triangle], 1)
are the correct ways to call these two methods. If you had square
and hexagon
point arrays, you could use
cv2.fillPoly(ar, [triangle, square, hexagon], 1)
to draw all three.