Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Select timeout error when re-plug camera

OS: Ubuntu 16.04 OpenCV v3.2.0 Python v3.5.2 Camera: ICT

Issue: Every time after computer reboot or back from sleep, or unplug/plug-in the camera attempt to grab the first frame

    success, frame = capture.read()

fails with the error

    select timeout
    OpenCV Error: Assertion failed (total() == 0 || data != __null) in Mat,  file 
                             /io/opencv/modules/core/include/opencv2/core/mat.inl.hpp, line 500

All following attempts work fine. My simple workaround is to use

 capture.release()

once that happened and then retry, i.e reopen VideoCapture and grab frame again

 capture = cv2.VideoCapture(dev_id)   # dev_id = /dev/video1 in my case
 success, frame = capture.read()

Second attempt is successful in 100% cases so far

Question: Do I do anything wrong or that's a bug in OpenCV?