How to create a ring buffer for camera images?

Please provide the following info (tick the boxes after creating this topic):
Software Version
DRIVE OS 6.0.10.0
DRIVE OS 6.0.8.1
DRIVE OS 6.0.6
DRIVE OS 6.0.5
DRIVE OS 6.0.4 (rev. 1)
DRIVE OS 6.0.4 SDK
other

Target Operating System
Linux
QNX
other

Hardware Platform
DRIVE AGX Orin Developer Kit (940-63710-0010-300)
DRIVE AGX Orin Developer Kit (940-63710-0010-200)
DRIVE AGX Orin Developer Kit (940-63710-0010-100)
DRIVE AGX Orin Developer Kit (940-63710-0010-D00)
DRIVE AGX Orin Developer Kit (940-63710-0010-C00)
DRIVE AGX Orin Developer Kit (not sure its number)
other

SDK Manager Version
2.1.0
other

Host Machine Version
native Ubuntu Linux 20.04 Host installed with SDK Manager
native Ubuntu Linux 20.04 Host installed with DRIVE OS Docker Containers
native Ubuntu Linux 18.04 Host installed with DRIVE OS Docker Containers
other

Issue Description
Hi, we are currently trying to implement a ring recording tool for the camera sensors. Currently, I am basing my implementations off “sample_camera” example from Driveworks. I am using the camera serializer framework/method to record videos which is implemented in the sample code.

My use case for the ring recorder would be: once triggered, the ring recorder will write x seconds of data prior to the trigger and y seconds of data after the trigger into a log file. In this case, an mp4/h264/h265 video file.

From my understandings, the serializer can only serialize a camera frame (NOT an image frame). The camera frames are stored in a memory pool. New frames can only be written if there are frames that have been returned. However, the ring recorder requires to store x+y seconds of frames. My questions would be: is there a way to increase the memory pool size? Also, is there a way to make a deep copy of the camera frame so that I can store it in an external queue (I can also then return the camera frame in the memory pool so that new data can keep coming in)? And finally, if anyone has good suggestions in creating a ring recorder for cameras using Driveworks, I would be really grateful if you can share your experience! Thanks!

Please see fifo-size helps for your case. Please see DriveWorks SDK Reference: Camera

So is it like you send a stop signal from user interface and the final record should have x secs(frames) earlier and y(frames) secs later from the signal issued time?

Hi Siva,

Thank you for replying. I was actually looking into the fifo-size parameter however, I saw in this page that the fifo-size of camera-gmsl can only go up to 20 frames. This would only contain less than 1 second of data (our cameras go at 30 Hz). The ring buffer that I want to implement should contain at least 30 seconds of data which means that it would have at least 900 frames. However, is it possible to set a fifo-size greater than 20 frames?

And you are correct about our use case. Take the 30 seconds of data I mentioned before. If I send a stop signal from the user interface, I would need a recording of 20 seconds before I send the signal and 10 seconds after I send the signal.

I was also experimenting with a parameter called frames-pool in the link you have sent me. However, the memory pool size for camera frames doesn’t change no matter how I change this parameter.

I was able to solve this problem using the Sensor Serializer interface. Here is a general workflow on how I made it work:

  1. Create the callback function onData to stream serialized h264 frames locally or across other machines.
  2. Run the serializer from the beginning.
  3. Get camera frame and call the serializer to serialize the camera frame.
  4. Retrieve data from the callback function and store it into the ring buffer.

It is important that the ring buffer should always have a key frame in the beginning so that when you concatenate the frames together it actually forms a video that makes sense. Make sure you go through the encoded frame and try to look for nal_unit_type == 5 in each frame. Always preserve a frame that has nal_unit_type == 5 in the beginning of the buffer. I will mark this as closed.

Hello,
Could you please let me know how to run Nvidia Driveworks 5.8 camera sample application on Nvidia SPC device.
I have tried below command, but its not working.
./sample_camera --rig /home/nvidia/spc-image-capture/ --write-file sample_video-mp4 --enable-user-event-callbacks 1 --reset-on-error 1 --dwTracePath /home/nvidia/spc-image-capture/trace.json
Sample illustrating how to use camera interfaces
–enable-user-event-callbacks: default=0
If this set to 1, then the user-defined error handling will be enabled

–offscreen: default=0
Used for running windowed apps in headless mode. 0 = show window, 1 = offscreen window, 2 = no window created
–profiling: default=1
Enables/disables sample profiling
–reset-on-error: default=0
If this flag set to 1, then the camera link will be reset when errors occur. This parameter only takes effect when --enable-user-event-callbacks=1
–rig: default=/home/nvidia/spc-image-capture/data/samples/sensors/camera/camera/rig.json
This is the main source of input configuration for the cameras, can setup any possible configuration
–write-file: default=
If this string is not empty, then the serializer will record in this location

terminate called after throwing an instance of ‘std::runtime_error’
what(): Unknown option --dwTracePath

Aborted (core dumped)

I have a GMSL camera connected to the SPC device.

Hello,

I guess Siva will let you open a new topic on your questions since I have already closed mine. But what it looks like is that you don’t parse the argument --dwTracePath. This seems like a rather easy fix. Try removing this argument in your command line and see if it works.

Dear @a.ratnakaram ,
Please file a new topic for your issue.