使用 OpenCV Python 创建虚拟网络摄像头

时间:2021-06-24 04:43:21

标签: python opencv

我在做什么:在 Python 中创建一个程序,该程序可以从相机获取流,使其看起来像视频帧闪烁,然后将其输出为虚拟视频溪流。可以通过 Zoom 等应用检测到。

问题:从摄像头获取流并出现故障是正常的,我只是想办法让它成为虚拟网络摄像头。

代码

from glitch_this import ImageGlitcher
from PIL import Image
import cv2
import numpy as np

glitcher = ImageGlitcher()
RUN = True

cap = cv2.VideoCapture(0)

while RUN:
    success, frame = cap.read()

    if success:
        image = Image.fromarray(frame)
        glitch_image = glitcher.glitch_image(image, 10, scan_lines=True)

        cv2_image_to_show = np.asarray(glitch_image)
        cv2.imshow('Glitched Frame', cv2_image_to_show)

        if cv2.waitKey(1) & 0xFF == ord('q'):
            RUN = False

    else:
        RUN = False

结论:对于任何糟糕的编码或拼写错误,我们深表歉意。

编辑:要下载glitch_this 包,请使用命令 pip install glitch-this 及其 Github 页面 Github

0 个答案:

没有答案