Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Timeout on VideoCapture.open(0)?

I am calling VideoCapture.open(0) and everything works like a charm if I have a device at ID 0. Problem is if I don't have a openable device there, OpenCV will continue trying to establish a connection afaik - FOREVER. This occurs for example when I run the code on my laptop which has a facetime HD camera in the lid. if i run the computer from an external monitor and I have the lid down then it just hangs forever. As soon as I open the lid it springs to life. Is there any way to specify a timeout for trying? If it will never stop trying to connect then constructs like ...

if (!cap.isOpened()) // check if we succeeded

make no sense, because it will never report that it did not succeed. any solutions? I am using OpenCV 2.4.10 on Mac OSX 10.10 with Java 1.8.0_25. Thanks,