Python 2.7 OpenCV 3.4 - 3.1 video capture crashes

asked 2018-02-06 09:26:48 -0500

raffra gravatar image

##### System information (version)

  • OpenCV => 3.1 or 3.4 (details in text)
  • Operating System / Platform => Windows 7 32 Bit
  • Anaconda2 Python 2.7 32 bit
Detailed description

I'm trying to capture video from webcam but program crashes even with the simple test script: the first frame is a complete blank image. After returning this frame, program crashes. I tried to do the typical fix: -I'm waiting even 5 seconds before reading on the opened device. -isOpened() returns True, like ret. -I've added to the path user environment variable the two folder Anaconda2 and Anaconda2/Scripts.

I'm running anaconda2 2.7 32 bit. I tried to install opencv 3.4 pyd copying from official zip or installing opencv3 from conda repo with conda install -c menpo opencv3. VideoCapture on avi,mpeg1,mpeg2,mpeg4 videos works fine. Imread works with jpg, png but not with gif. I tried even to install ffmpeg in conda usingconda -c install menpo ffmpeg, but nothing seems to work. Any help?

Steps to reproduce

Program Output:

('numpy v.', '1.13.3')

('openCV v.', '3.4.0')

Device Opened

new iter

(True, (480, 640, 3))

new iter

import numpy as np
print('numpy v.', np.__version__)
import cv2
print('openCV v.', cv2.__version__)

#open dev
cap = cv2.VideoCapture(0)
if cap.isOpened():
    print("Device Opened\n")
    print("Failed to open Device\n")

    print('new iter')
    ret, frame =
    if cv2.waitKey(1) & 0xFF == ord('q'):

edit retag flag offensive close merge delete