Last active
February 26, 2022 00:32
-
-
Save ola0x/4fa664df2b0260528ccaced77a6bf4e6 to your computer and use it in GitHub Desktop.
Using opencv for multiple webcam
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 | |
cam0 = cv2.VideoCapture(0) | |
cam1 = cv2.VideoCapture(1) | |
while True: | |
ret0, frame0 = cam0.read() | |
ret1, frame1 = cam1.read() | |
if (ret0): | |
cv2.imshow("Cam 0", frame0) | |
if (ret1): | |
cv2.imshow("Cam 1", frame1) | |
k = cv2.waitKey(1) | |
if k != -1: | |
break | |
cam0.release() | |
cam1.release() | |
cv2.destroyAllWindows()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment