VideoCapture "frame grabbing" is blocking using an IP Camera (Bug #2786)
Description
Grabbing a frame using VideoCapture with an IP Camera is blocking if the camera goes disconnected.
I tried the methods:
1) grabber >> frame;
2) grabber.read( frame );
3) grabber.grab(); <- blocks here
grabber.retrieve( frame );
each one blocks if the camera is disconnected from the network.
This is very bad because it does not let you understand if there are problems with the connections.
Associated revisions
Merge pull request #2786 from ElenaGvozdeva:ocl_matchTemplate
History
Updated by Alexandro Picolini almost 11 years ago
Hi Vadim,
This freezing occurs in the read method which calls av_read_frame function. So that this function does not freeze in the event of disconnection must be registered to url_set_interrupt_cb callback.
Exist forecast for this fix?
Tks,
Updated by Alexandro Picolini almost 11 years ago
Hello Vadim.
Following patch to fix this problem.
You can put this in the official build?
Thank you.
- File cap_ffmpeg_impl.hpp_patch added
Updated by Andy Bean almost 11 years ago
I can confirm this issue in 2.4.9 release running on windows 7. This is really a showstopper when using opencv with network cameras.
Updated by Corentin Hamel over 10 years ago
Hi Alexandro,
I'm having trouble to see how this patch is gonna work and actually I can't get it work. The capture.read() is still blocking if there is a connection loss.
Even with the patch, the program is getting stuck in the _ while (!valid)_ loop of CvCapture_FFMPEG::grabFrame() line 693 as there is no new frame, the only way to get out of this loop is when count_errs > max_number_of_attempts line 738 but this is taking a while so the capture.read() is blocked.
I thought when the callback function cvCapture_FFMPEG_Timeout::checkInterrupt called with opaque argument and will return 1 (when timeout is reached), the blocking operation will be aborted. But I'm not sure what the blocking operation at this point (I thought it will exist the while loop).
My knowledge on the openCV code are limited so maybe I'm not understanding something.
Thanks
Updated by Corentin Hamel over 10 years ago
- File cap_ffmpeg_impl.hpp added
Updated by Maksim Shabunin over 9 years ago
Issue has been transferred to GitHub: https://github.com/Itseez/opencv/issues/4506