1

I needed two cameras for a project requirement. To test the working of the tow cameras together I wrote a short that goes as follows:

{

   import cv2,os
   import numpy as np

   webcam = cv2.VideoCapture(0)
   webcam1 = cv2.VideoCapture(1)

   while True:
   ret0,frame = webcam.read()
   ret1,frame1 = webcam1.read()

   if(ret0):
        cv2.imshow('Webcam',frame)

   if(ret1):
        cv2.imshow('Webcam1',frame1)

   if cv2.waitKey(1) & 0xFF == ord("q"):
        break

   cv2.destroyAllWindows()
   webcam.release()
   webcam1.release()

}

On running the code one camera starts running fine while the other raises an error below:

VIDEOIO ERROR: V4L2: Could not obtain specifics of capture window. VIDEOIO ERROR: V4L: can't open camera by index 1 /dev/video1 does not support memory mapping

How do I rectify this?

  • just a quick note. your indentation seems to be off. I am not sure your code will behave the way you intend, even after fixing the posted error. – oh.dae.su Mar 2 at 17:45
1

Try to change the webcam1 = cv2.VideoCapture(1)(the one that raises the error) to webcam1 = cv2.VideoCapture(-1).

Also, check the camera drivers by ls /dev/video* to make sure all cameras plugged.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.