Select timeout error when re-plug camera

asked 2018-05-11 17:10:34 -0600

svolvo gravatar image

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?

edit retag flag offensive close merge delete

Comments

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.

sjhalayka gravatar imagesjhalayka ( 2018-05-11 19:48:36 -0600 )edit

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

svolvo gravatar imagesvolvo ( 2018-05-13 20:17:12 -0600 )edit

There is a GitHub repository for OpenCV. I believe that there's some kind of 'issue' reporting tools in GitHub.

sjhalayka gravatar imagesjhalayka ( 2018-05-13 20:54:10 -0600 )edit

Hmm... Does not happen with 'HD Pro Webcam C920'

svolvo gravatar imagesvolvo ( 2018-05-14 09:54:24 -0600 )edit

Still could be a driver bug? I dunno LOL

sjhalayka gravatar imagesjhalayka ( 2018-05-14 10:17:15 -0600 )edit

Both usb cameras I tried as well as Integrated camera use the same driver. Technically it could... but I doubt it is

svolvo gravatar imagesvolvo ( 2018-05-14 11:48:49 -0600 )edit