Created
September 4, 2021 10:38
-
-
Save minons1/4bf33f94fc117654d2b11bce48200346 to your computer and use it in GitHub Desktop.
Access camera and make virtual camera using python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pyvirtualcam | |
import cv2 | |
fmt = pyvirtualcam.PixelFormat.BGR | |
cap = cv2.VideoCapture(0) | |
with pyvirtualcam.Camera(width=1280, height=720, fps=20, fmt=fmt) 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() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment