Ask Your Question

Revision history [back]

Second camera is not opening until the first camera is released

I want to display the video inputs from two cameras at the same time. I used below code.

capL = cv.VideoCapture(0)
capR = cv.VideoCapture(1)

if capL.isOpened() & capR.isOpened():
    while True:
        retL, frameL = capL.read()
        retR, frameR = capR.read()

        leftImage = cv.cvtColor(frameL, cv.COLOR_BGR2GRAY)
        rightImage = cv.cvtColor(frameL, cv.COLOR_BGR2GRAY)

        cv.imshow('Left Camera', leftImage)
        cv.imshow('Right Camera', leftImage)

        if cv.waitKey(25) & 0xFF == ord('q'):
            break
else:
    print("unable to open camera")

But the output always shows

unable to open camera

To debug it, I used below code

capL = cv.VideoCapture(0)
while not capL.isOpened():
    print('L not open')

capR = cv.VideoCapture(1)
while not capR.isOpened():
    print('R not open')

And I found out the second camera is not opening. But if I release the first camera then the second camera is opening.

capL = cv.VideoCapture(0)
while not capL.isOpened():
    print('L not open')
capL.release()

capR = cv.VideoCapture(1)
while not capR.isOpened():
    print('R not open')

Am I doing something wrong?

Second camera is not opening until the first camera is released

I want to display the video inputs from two cameras at the same time. I used below code.

capL = cv.VideoCapture(0)
capR = cv.VideoCapture(1)

if capL.isOpened() & capR.isOpened():
    while True:
        retL, frameL = capL.read()
        retR, frameR = capR.read()

        leftImage = cv.cvtColor(frameL, cv.COLOR_BGR2GRAY)
        rightImage = cv.cvtColor(frameL, cv.COLOR_BGR2GRAY)

        cv.imshow('Left Camera', leftImage)
        cv.imshow('Right Camera', leftImage)

        if cv.waitKey(25) & 0xFF == ord('q'):
            break
else:
    print("unable to open camera")

But the output always shows

unable to open camera

To debug it, I used below code

capL = cv.VideoCapture(0)
while not capL.isOpened():
    print('L not open')

capR = cv.VideoCapture(1)
while not capR.isOpened():
    print('R not open')

And I found out the second camera is not opening. But if I release the first camera then the second camera is opening.

capL = cv.VideoCapture(0)
while not capL.isOpened():
    print('L not open')
capL.release()

capR = cv.VideoCapture(1)
while not capR.isOpened():
    print('R not open')

Am I doing something wrong?

Second camera is not opening until the first camera is released

I want to display the video inputs from two cameras at the same time. I used below code.

capL = cv.VideoCapture(0)
capR = cv.VideoCapture(1)

if capL.isOpened() & capR.isOpened():
    while True:
        retL, frameL = capL.read()
        retR, frameR = capR.read()

        leftImage = cv.cvtColor(frameL, cv.COLOR_BGR2GRAY)
        rightImage = cv.cvtColor(frameL, cv.cvtColor(frameR, cv.COLOR_BGR2GRAY)

        cv.imshow('Left Camera', leftImage)
        cv.imshow('Right Camera', leftImage)

        if cv.waitKey(25) & 0xFF == ord('q'):
            break
else:
    print("unable to open camera")

But the output always shows

unable to open camera

To debug it, I used below code

capL = cv.VideoCapture(0)
while not capL.isOpened():
    print('L not open')

capR = cv.VideoCapture(1)
while not capR.isOpened():
    print('R not open')

And I found out the second camera is not opening. But if I release the first camera then the second camera is opening.

capL = cv.VideoCapture(0)
while not capL.isOpened():
    print('L not open')
capL.release()

capR = cv.VideoCapture(1)
while not capR.isOpened():
    print('R not open')

Am I doing something wrong?

Second camera is not opening until the first camera is released

I want to display the video inputs from two cameras at the same time. I used below code.

capL = cv.VideoCapture(0)
capR = cv.VideoCapture(1)

if capL.isOpened() & capR.isOpened():
    while True:
        retL, frameL = capL.read()
        retR, frameR = capR.read()

        leftImage = cv.cvtColor(frameL, cv.COLOR_BGR2GRAY)
        rightImage = cv.cvtColor(frameR, cv.COLOR_BGR2GRAY)

        cv.imshow('Left Camera', leftImage)
        cv.imshow('Right Camera', leftImage)
rightImage)

        if cv.waitKey(25) & 0xFF == ord('q'):
            break
else:
    print("unable to open camera")

But the output always shows

unable to open camera

To debug it, I used below code

capL = cv.VideoCapture(0)
while not capL.isOpened():
    print('L not open')

capR = cv.VideoCapture(1)
while not capR.isOpened():
    print('R not open')

And I found out the second camera is not opening. But if I release the first camera then the second camera is opening.

capL = cv.VideoCapture(0)
while not capL.isOpened():
    print('L not open')
capL.release()

capR = cv.VideoCapture(1)
while not capR.isOpened():
    print('R not open')

Am I doing something wrong?