VideoCapture "frame grabbing" is blocking using an IP Camera (Bug #2786)


Added by Walter Lucetti about 12 years ago. Updated over 9 years ago.


Status:Open Start date:2013-02-08
Priority:Normal Due date:
Assignee:Vadim Pisarevsky % Done:

0%

Category:highgui-camera
Target version:-
Affected version:branch 'master' (2.4.9) Operating System:
Difficulty: HW Platform:
Pull request:

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.


cap_ffmpeg_impl.hpp_patch (2.1 kB) Alexandro Picolini, 2014-04-27 10:59 pm

cap_ffmpeg_impl.hpp (60.9 kB) Corentin Hamel, 2014-08-06 05:33 am


Associated revisions

Revision ea1b14ee
Added by Alexander Alekhin over 10 years ago

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.

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 Maksim Shabunin over 9 years ago

Issue has been transferred to GitHub: https://github.com/Itseez/opencv/issues/4506

Also available in: Atom PDF