Draw the mask with fillPoly:
fillPoly
mask = np.ones((1000, 2000)) # (height, width)myROI = [(750, 0), (900, 1000), (1000, 1000), (1500, 0)] # (x, y)cv2.fillPoly(mask, [np.array(myROI)], 0)
This should take ~1ms.