Skip to content

Instantly share code, notes, and snippets.

@ola0x
Last active February 26, 2022 00:32
Show Gist options
  • Save ola0x/4fa664df2b0260528ccaced77a6bf4e6 to your computer and use it in GitHub Desktop.
Save ola0x/4fa664df2b0260528ccaced77a6bf4e6 to your computer and use it in GitHub Desktop.
Using opencv for multiple webcam
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