python - OpenCV cv2.fillPoly vs. cv2.fillConvexPoly: expected data type for array of polygon vertices? -


i have following code:

import cv2 import numpy  ar = numpy.zeros((10,10)) triangle = numpy.array([ [1,3], [4,8], [1,9] ], numpy.int32) 

if use cv2.fillconvexpoly so:

cv2.fillconvexpoly(ar, triangle, 1) 

then results expected. if, however, try:

cv2.fillpoly(ar, triangle, 1) 

then failed assertion. seems identical assertion fails if use numpy array cv2.fillconvexpoly not have dtype numpy.int32. cv2.fillpoly , cv2.fillconvexpoly expect different data types second argument? if so, should using cv2.fillpoly?

cv2.fillpoly , cv2.fillconvexpoly use different data types point arrays, because fillconvexpoly draws 1 polygon , fillpoly draws (python) list of them. thus,

cv2.fillconvexpoly(ar, triangle, 1) cv2.fillpoly(ar, [triangle], 1) 

are correct ways call these 2 methods. if had square , hexagon point arrays, use

cv2.fillpoly(ar, [triangle, square, hexagon], 1) 

to draw three.


Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -