Object detection ending after 4h with this failure...
Hello Community
I use the Camera D435 with a RasperryPi 4, 4GB RAM and an SD card with 32GB.
The camera detects objects and simultaneously measures the distance. Is an object closer than e.g. 4m switches a relay on the PiFace digital 2. All of this actually works very well.
However, only about 4 hours later the function stops and the following message appears in the console:
Traceback (most recent call last):
File "object-detection.py", line 210, in <module>
images = object_detection(color_frame, depth_frame,background)
File "object-detection.py", line 88, in object_detection
images = np.hstack((color_image, depth_colormap))
File "/usr/lib/python3/dist-packages/numpy/core/shape_base.py", line 340, in hstack
return _nx.concatenate(arrs, 1)
MemoryError
What could be the reason for this and how can this be remedied?
Thank you for your help and your great support.
Greetings
Martin
-
Given that the log says that there is a MemoryError and the problem occurs after 4 hours of successful running, the first possibility I would recommend checking is whether your program has a memory leak. This is where memory is not being properly released for re-use, so the available memory gets consumed over time until it runs out. This can cause stability problems or even a freeze / exiting of the program.
How long a memory leak takes to stop a program depends on what the application is doing. For example in RealSense, a program that is running multiple streams at high resolution or FPS speed will fail sooner than a program that has a single stream and a modest resolution / FPS speed and so is consuming memory resources at a slower rate.
The easiest way to check for the possibility of a memory leak is to monitor your computer's memory usage and observe whether it is continuously reducing over time.
-
Hello Marty
I followed your tip and monitored the program with htop, resp. looked at what's happening there.
In fact, the memory requirement in RAM is continuously increasing.
The Raspi also loads the file 23x into RAM.
As soon as the RAM has exceeded the 2.2GB limit, the software crashes.
I thought about whether I should monitor the RAM with a watchdog and end the program when a certain limit was exceeded and then start it again ...
is probably not the optimal solution, is it?
May I send you the code? Maybe you see what it could be?Greeting
Martin
Please sign in to leave a comment.
Comments
3 comments