Created
December 7, 2019 04:15
-
-
Save toandaominh1997/c914717c91dd6dbd07b45058bd1b1aac 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 cv2 | |
cap = cv2.VideoCapture() | |
# cap.open(2, apiPreference=cv2.CAP_V4L2) | |
cap.open(2) | |
cap.set(cv2.CAP_PROP_FOURCC, cv2.VideoWriter_fourcc('M', 'J', 'P', 'G')) | |
cap.set(cv2.CAP_PROP_FRAME_WIDTH, 1920) | |
cap.set(cv2.CAP_PROP_FRAME_HEIGHT, 1080) | |
cap.set(cv2.CAP_PROP_FPS, 30.0) | |
import time | |
num_frame = 0 | |
start = time.time() | |
while(True): | |
ret, frame = cap.read() | |
num_frame +=1 | |
if(num_frame%100==0): | |
print('FPS: ', 100/(time.time()-start)) | |
start = time.time() | |
cv2.imshow('Frame', frame) | |
if cv2.waitKey(1) & 0xFF == ord('q'): | |
break | |
# When everything done, release the capture | |
cap.release() | |
cv2.destroyAllWindows() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment