我正在用Python尝试openCV,我制作了一个简单的网络摄像头,它只会以黑白方式显示给你,但我想知道是否有可能以某种方式将它连接到discord,所以每当我打电话给朋友时,他都会看到我是黑白的.`
import cv2
capture = cv2.VideoCapture(0)
capture.set(3, 640)
capture.set(4, 480)
capture.set(10, 300)
while True:
sucess, img = capture.read()
img = cv2.Canny(img, 100, 100)
cv2.imshow("Webcam", img)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
这可能会迟到,但请检查一下 pyvirtualcam
先安装:
pip install pyvirtualcam
你可以这样做:
import pyvirtualcam
import numpy as np
with pyvirtualcam.Camera(width=1280, height=720, fps=30) as cam:
while True:
frame = np.zeros((cam.height, cam.width, 4), np.uint8) # RGBA
frame[:,:,:3] = cam.frames_sent % 255 # grayscale animation
frame[:,:,3] = 255
cam.send(frame)
cam.sleep_until_next_frame()
正如之前的评论中提到的,
pyvirtualcam
应该可以工作,但它依赖于现有的虚拟相机软件。