发送到 pyvirtualcam 的网络摄像头输入是蓝色的(使用 pyvirtualcam 和 opencv)

Webcam input sent to pyvirtualcam is blue(using pyvirtualcam and opencv)

我正在尝试使用 OpenCv 从我的网络摄像头获取输入并使用 pyvirtualcam 将其发送到虚拟相机。出于某种原因,当我的网络摄像头显示时,它会给它一个蓝色滤镜。当我显示我的网络摄像头而不将其发送到虚拟相机时,没有过滤器,一切正常。

import pyvirtualcam
import cv2

cap = cv2.VideoCapture(0)
with pyvirtualcam.Camera(width=1280, height=720, fps=20) as cam:
    while True:
        ret_val, frame = cap.read()

        frame = cv2.resize(frame, (1280, 720), interpolation=cv2.BORDER_DEFAULT)
        # cv2.imshow('my webcam', frame)
        cam.send(frame)
        cam.sleep_until_next_frame()
        if cv2.waitKey(1) == 27:
            break  # esc to quit
    cv2.destroyAllWindows()

OpenCV 使用 BGR 作为像素格式。 pyvirtualcam 默认需要 RGB,但它也支持 BGR:

fmt = pyvirtualcam.PixelFormat.BGR
with pyvirtualcam.Camera(width=1280, height=720, fps=20, fmt=fmt) as cam: