0

I would like to access my web camera on my python program using cv2 library.

I can see and use my camera in any mac program (photobooh, facetime,..) as well as skype,...

But if I try to access it in python I can't:

cap = cv

cv2.VideoCapture(1)
success,image = cap.read() 
print(success)
>> False

I also try to get list of all devices (cameras) like this:

for i in range(1600):
    cap = cv2.VideoCapture(i)
    success,image = cap.read() 
    if success:
        print(i)
    cap.release()
>> 0
>> 1200

Both are default mac cameras,...

Marko Zadravec
  • 8,298
  • 10
  • 55
  • 97

2 Answers2

0

Try to use

cv2.VideoCapture(-1)

it worked for me as I found out that external devices for both video and audio always take the last index

Skander HR
  • 580
  • 3
  • 14
0

Apparently all you need to do is restart the kernel.

Marko Zadravec
  • 8,298
  • 10
  • 55
  • 97