本文介紹了如何用python制作虛擬相機?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
我正在 python 中嘗試使用 openCV,我制作了一個簡單的網(wǎng)絡攝像頭,它只會以黑白顯示,但我想知道是否有可能以某種方式將它與不和諧聯(lián)系起來,所以每當我打電話給朋友時,他看到我是黑色的和白色.`
I am experimenting with openCV in python and I made a simple webcam that will only show you in black and white but I was wondering if it was possible to somehow connect it to discord so whenever I call a friend he sees me in black and white.`
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
This may be late but check this out 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()
cam.sleep_until_next_frame()
這篇關于如何用python制作虛擬相機?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!
【網(wǎng)站聲明】本站部分內容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯(lián)系我們刪除處理,感謝您的支持!