1

Error in using python open cv to initialize the camera in a face recognition task

import cv2
camera = cv2.VideoCapture(1)
camera.grab()
ret, frame = camera.retrieve()
cv2.namedWindow('frame')

.

OpenCV: out device of bound (0-0): 1
OpenCV: camera failed to properly initialize!
1
  • in my laptop camera has number 0. Did you try other numbers ? Commented Jul 20, 2019 at 21:22

1 Answer 1

4

The problem is that I'm not using an extra webcam and my pc has just one camera, so this line should be: camera = cv2.VideoCapture(0)

Sign up to request clarification or add additional context in comments.

1 Comment

You'd think that, but sometimes the order of USB enumeration is surprising. Try 0. lsusb might provide some evidence, if you have it installed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.