0

My code (copied from https://stackoverflow.com/a/21797253/8387437) shows a mostly black screen some of the times, but works other times. I've tried uninstalling my Imaging Device, but this does not always work. I am using python 2.7.13, on a Windows 64 bit laptop. I pip installed opencv_python getting opencv_python-3.2.0.8. Here is the code: import cv2

cam = cv2.VideoCapture(0)
print cam.isOpened()

while(True):
    ret, frame = cam.read()
    cv2.imshow('frame', frame)
    if cv2.waitKey(1) & 0xFF == ord('q'):
        break

cam.release()
cv2.destroyAllWindows()

Here is an image of what it looks like. It switches between this frame and another similar one.

EDIT: Image wasn't inserted correctly.

Jeru Luke
  • 20,118
  • 13
  • 80
  • 87

1 Answers1

0

I get black frames reading the first few images from my laptop's built-in webcam. I've worked around it by discarding the first 10 frames.

Hardly an explanation, but "it works on my computer."

Dave W. Smith
  • 24,318
  • 4
  • 40
  • 46