def getMask(self, shape):
p = self.state['pos']
s = self.state['size']
center = p + s / 2
a = self.state['angle']
# opencv convention:
shape = (shape[1], shape[0])
arr = np.zeros(shape, dtype=np.uint8)
# draw rotated rectangle:
vertices = np.int0(cv2.boxPoints((center, s, a)))
cv2.drawContours(arr, [vertices],
0,
color=1,
thickness=-1)
return arr.astype(bool).T
评论列表
文章目录