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?
I would say it's a camera driver or hardware problem, sorry.
select
tells you if and when there is data to be received from the camera. If it times out, it means that the camera's not responding, not passing along data.This is related to the network socket or file system object ("everything's a file in UNIX") used to connect to the camera.
Thanks for the comment, but i doubt it's a driver/hardware issue. In exactly the the same situation fswebcam tool works fine with no timeout which tells me it's a software issue
There is a GitHub repository for OpenCV. I believe that there's some kind of 'issue' reporting tools in GitHub.
Hmm... Does not happen with 'HD Pro Webcam C920'
Still could be a driver bug? I dunno LOL
Both usb cameras I tried as well as Integrated camera use the same driver. Technically it could... but I doubt it is