Skip to content
Advertisement

DNN OpenCV Python using RSTP always crash after few minutes

Description:

I want to create a people counter using DNN. The model I’m using is MobileNetSSD. The camera I use is IPCam from Hikvision. Python communicates with IPCam using the RSTP protocol.

The program that I made is good and there are no bugs, when running the sample video the program does its job well. But when I replaced it with IPcam there was an unknown error.

Error:

Sometimes the error is:

JavaScript

Sometimes the error does not appear and the program is killed.


Update Error

After revising the code, I caught the error. The error found is

JavaScript

Now I don’t know what to do, because the error is not in Google.

Source Code:

Old Code

This is my very earliest code before getting suggestions from the comments field.

JavaScript

New Code

I have revised my code and the program still stops taking frames. I just revised the PersonDetection_UsingMobileNetSSD() function. I’ve also removed the multithreading I was using. The code has been running for about 30 minutes but after a broken frame, the code will never re-execute the program block if ret == True.

JavaScript

Requirement:

Hardware : Intel i5-1035G1, RAM 8 GB, NVIDIA GeForce MX330

Software : Python 3.6.2 , OpenCV 4.5.1, Numpy 1.16.0

Question:

  1. What should i do for fixing this error?
  2. What causes this to happen?

Best Regards,


Thanks

Advertisement

Answer

The main problem here is that RSTP always has some corrupted frames in it. The solution is to run video capture on thread 1 and video processing on thread 2.

As an example:

JavaScript

This example will work according to the case you are experiencing. Damage to the frame will not affect the quality of data processing. It’s just that this method can cause delays in processing. Time on video and real time have a delay of up to 10 minutes. Want to know what kind of delay? Just try it!

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement