only 1 on 2 camera working

asked 2018-04-23 05:47:02 -0500

otiea gravatar image

updated 2018-04-23 05:51:27 -0500

berak gravatar image

hi guys I am new with opencv and i am trying to take a video image from a dual stereo camera module.

CAMERA : ELP 1.0 Megapixel Dual Lens Usb Camera Module with Two Megapixel Lens SOFTWARE : opencv 3.4

the module has 2 cameras and one usb door. when i run the code, it open 2 windows, but i receive only the output from one camera.

i am sure the camera are working because with an other software i was able to choose the camera i wanted use and it worked.

With videocapture (0) i got the image from camera module with videocapture (1) i got from my laptop camera with videocapture (2) it open the laptot camera again with videocapture (3) no more frame using 2 times videocapture (0) i got output from the same camera

the code is the following.

 import cv2

 left = cv2.VideoCapture(0)
 right = cv2.VideoCapture(1)

    if not (left.grab() and right.grab()):
        print("No more frames")

    _, leftFrame = left.retrieve()
    _, rightFrame = right.retrieve()

    cv2.imshow('left', leftFrame)
    cv2.imshow('right', rightFrame)
    if cv2.waitKey(1) & 0xFF == ord('q'):

edit retag flag offensive close merge delete


you could try with:

stereo = cv2.VideoCapture(0)
    _, left = stereo.retrieve(flag=0)
    _, right = stereo.retrieve(flag=1)
berak gravatar imageberak ( 2018-04-23 06:46:53 -0500 )edit

thanks for your reply. i tried with yours script but i just received 2 output from the same camera.

for the moment i solved running:

cams_test = 500
for i in range(0, cams_test):
    cap = cv2.VideoCapture(i)
    test, frame =
    if test:
        print("i : "+str(i)+" /// result: "+str(test))

and one time identified the door i have decrease cam resolution because i had usb problems

otiea gravatar imageotiea ( 2018-04-23 07:01:26 -0500 )edit