Created
March 12, 2022 14:31
-
-
Save ola0x/dd184e13d91f503161d7443ef5686daa 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 | |
import numpy as np | |
width_res = 640 | |
height_res = 480 | |
def readcam1(): | |
cam1 = cv2.VideoCapture(0) | |
print("[INFO] stating camera 1") | |
cam1.set(3,width_res) | |
cam1.set(4,height_res) | |
while True: | |
if (cam1.isOpened() == None): | |
print("Failed to connect to the camera 1") | |
_,frame = cam1.read() | |
if frame is None: | |
print("Camera1 ==> Failed to capture an image") | |
cv2.imshow('cam1',frame) | |
if cv2.waitKey(1) & 0xFF == ord('q'): | |
break | |
def readcam2(): | |
cam2 = cv2.VideoCapture(2) | |
print("[INFO] stating camera 2") | |
cam2.set(3,width_res) | |
cam2.set(4,height_res) | |
while True: | |
if (cam2.isOpened() == None): | |
print("Failed to connect to the camera 2") | |
_,frame2 = cam2.read() | |
if frame2 is None: | |
print("Camera2 ==> Failed to capture an image") | |
cv2.imshow('cam2',frame2) | |
if cv2.waitKey(1) & 0xFF == ord('q'): | |
break | |
readcam1() | |
readcam2() | |
cv2.destroyAllWindows() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment