Saturday 7 August 2021

How to terminate cv2.VideoCapture(rtsp_url) call if execution is taking longer time?

I have RTSP urls of total 80 cameras. I am trying to get screenshot from every camera using cv2.VideoCapture(rtsp_url). I am doing some Image Processing operations on the captured screenshots from each camera. I have total 80 such URLs each for every camera. Sample RTSP URL is:

rtsp://192.168.0.101:554/user=admin_password=oyXv12aW_channel=1_stream=0.sdp?real_stream

Now, sometimes due to network or other technical issues some the cameras temporarily don't function. In that case cv2.VideoCapture(rtsp_url) takes more than 30 seconds to return. In normal scenario it usually takes 2-3 seconds to get back with screenshots. But if camera is down then it takes too long time. Since my application is running in for loop on number of cameras I cannot afford to wait this longer. Sometimes inactive camera count is high, in that case it takes forever to execute the loop. What can be done to reduce the waiting time for cv2.VideoCapture?

P.S. I have used multiprocessing and have tried terminating process give time threshold crosses. I don't want to use multiprocessing though it is working very fine. I want to find solution with opencv only



from How to terminate cv2.VideoCapture(rtsp_url) call if execution is taking longer time?

No comments:

Post a Comment