I have two cameras with 4MP at 60 fps. In case of an external trigger, I have to make two videos of the last 2 minutes for each camera. The cameras are basler cameras and I'm using pypyplon to get the images and using OpenCV to process them.
For now, I am storing the last 10 seconds of each camera into my RAM on ring buffers.
As the external trigger occurs, I create the videos from the ring buffers. This uses all my RAM and I was wondering how I can store the 2 minutes instead of just buying more RAM.
I tried to convert them into jpgs to reduce the RAM usage but it was too slow for 60fps :
cv2.imencode('.jpg', image, encode_param)
These are the ideas I've had for improvement so far:
- Keep the ring buffers in the Disk. This would reduce the RAM usage. But I am concerned about the r/w speed and the lifetime of the SSD as the program will be running for a very long time.
- Compress the images on a GPU and keep them in the buffer.
- Compress the images using gstreamer.
Is there a standard way of solving problems like this?
Thanks in advance.