Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/opencv/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 为什么fillPoly用错误的颜色填充多边形?_Python_Opencv - Fatal编程技术网

Python 为什么fillPoly用错误的颜色填充多边形?

Python 为什么fillPoly用错误的颜色填充多边形?,python,opencv,Python,Opencv,我创建了一个大小为650x475的零掩码。当我用fillPoly函数(第三个参数255表示白色)填充它时,我的窗口显示的是蓝色而不是白色 if __name__ == "__main__": with mss.mss() as sct: monitor = {"top": 360, "left": 810, "width": 650, "height": 475}

我创建了一个大小为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


为什么它以蓝色显示?

OpenCV将彩色图像读取为蓝色、绿色、红色(BGR)形式

因此,当您设置
255
=
[255,0,0]
时,表示显示蓝色,但不显示绿色和红色

要将颜色设置为白色,请执行以下操作:

cv2.fillPoly(掩码,a3,[255,255,255])