Last active
August 31, 2018 03:17
-
-
Save daljeet-hcl/9eee797715ac504e1694846d65eb3f78 to your computer and use it in GitHub Desktop.
This file contains 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 pyfakewebcam | |
import numpy as np | |
import time | |
import timeit | |
import cv2 | |
import sys | |
from PIL import Image | |
cam = pyfakewebcam.FakeWebcam('/dev/video1', 1280, 720) | |
cam.print_capabilities() | |
cap = cv2.VideoCapture(0) | |
#set the width and height | |
cap.set(3,1280) | |
cap.set(4,720) | |
while(cap.isOpened()): | |
ret, frame = cap.read() | |
if ret==True: | |
# flip the frame | |
frame = cv2.flip(frame,0) | |
cv2.imshow('frame',frame) | |
#t1 = timeit.default_timer() | |
frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB) | |
cam.schedule_frame(frame) | |
#show the captured frame | |
if cv2.waitKey(1) & 0xFF == ord('q'): | |
break | |
else: | |
break | |
# Release everything if job is finished | |
cap.release() | |
out.release() | |
cv2.destroyAllWindows() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment