def get_contour_mask(dshape, img_fl): mask = np.zeros(dshape) hull = cv2.convexHull(img_fl) cv2.drawContours(mask, [hull], 0, (1, 1, 1) , -1) return np.uint8(mask) # Orients input_ mask onto tmpl_ face