3.2 创建掩码
# 创建0矩阵
stencil = np.zeros_like(col_images[idx][:,:,0])
# 指定多边形的坐标
polygon = np.array([[50,270...], [220,160], [360,160], [480,270]])
# 用1填充多边形
cv2.fillConvexPoly(stencil, polygon, 1)
# 画出多边形
plt.figure...(figsize=(10,10))
plt.imshow(stencil, cmap= "gray")
plt.show()
?...3.3 将掩码应用到图片上
# 应用该多边形作为掩码
img = cv2.bitwise_and(col_images[idx][:,:,0], col_images[idx][:,:,0], mask=stencil...img in notebook.tqdm(col_images):
# 应用帧掩码
masked = cv2.bitwise_and(img[:,:,0], img[:,:,0], mask=stencil