Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenCV VideoCapture timeout on Open or Constructor?

Tags:

c++

opencv

ffmpeg

OpenCV has the VideoCapture class to load video from external sources. I have a network camera on my network that I'm accessing with RTSP (using the FFMPEG plugin).

The sad thing is that it seems the open method and the constructor block on opening the video stream. This means if the stream is down, the program is stuck there forever.

Is there any sort of timeout ability? I tried looking in the source code, but in the end it calls external FFMPEG functions I believe and I'm unable to go further.

If there isn't timeout, is there any sort of library for a nonblocking VideoCapture method for RTSP or HTTP?

like image 884
Robert Avatar asked Jul 14 '16 03:07

Robert


People also ask

How does OpenCV VideoCapture work?

VideoCapture is a function of openCV library(used for computer vision, machine learning, and image processing) which allows working with video either by capturing via live webcam or by a video file.

What does cv2 VideoCapture return?

The VideoCapture class returns a video capture object which we can use to display the video. The class has several methods, for example, there is the get() method which takes a property identifier from cv2.


1 Answers

Although this question is quite old, I will supply more summarizing info for other people as well.

There is the possibility to build the dll for ffmpeg for opencv with a wrapper library Github issue refers to Peter's repo with a wrapper file (on line 198 is a timeout which can be set). (Sorry, I can't post more links). As long as you are comfortable with Make'ing this, then you should be set (this wrapper is quite easy, it's stated). If you are looking for the actual issue on github, read the issue linked above. There you can find more information on the actual problem fixed.

To rebuild OpenCV (python cv2) with CMake: Example Visual Studio.

like image 148
David Zwart Avatar answered Oct 23 '22 05:10

David Zwart