我创建一个尺寸为650x475的零遮罩。当我用fillPoly
函数填充它(白色的第三个参数255)时,我的窗口显示的是蓝色而不是白色
if __name__ == "__main__":
with mss.mss() as sct:
monitor = {"top": 360, "left": 810, "width": 650, "height": 475}
output = "sct-{top}x{left}_{width}x{height}.png".format(**monitor)
# Grab the data
sct_img = np.array(sct.grab(monitor))
shap = sct_img.shape
while 2>1:
mask = np.zeros_like(sct_img)
a3 = np.array([[[590, 12], [650, 12], [650, 460], [590, 460]]], dtype=np.int32)
cv2.fillPoly(mask, a3, 255)
cv2.imshow("OPENCV/NUMPY normal", mask)
if cv2.waitKey(25) & 0xFF == ord("q"):
cv2.destroyAllWindows()
break
为什么它显示为蓝色?
答案 0 :(得分:0)
OpenCV读取彩色图像为蓝色,绿色,红色(BGR)形式。 source
因此,当您设置255
= [255, 0, 0]
时,表示显示蓝色,但不显示绿色和红色。
要将颜色设置为白色:
cv2.fillPoly(mask, a3, [255, 255, 255])