Jetson Nano Detectnet Save Video

Hello everyone. So I have been using the github library and trying to use detectnet/imagenet codes to run some classification and things of that nature. More of playing around and modifying for a particular use I have.

I have been using the py (python) extension codes in terms of what I’m playing around with and adjusting. I have been able to input an excel file in the detectnet code and send into it information that I’m looking for. I have also been able to run detectnet and have it display on the video screen the confidence of detection (original code does not do that, only displays in terminal). So I have only done minor adjustments, all in python code.

So my problem: I do not know how to save the live video I get from the stream (since I’m using a raspberry pi camera v2). Ideally I want to save it as an avi file.

What I’ve tried: 1) I have tried to use python open cv (cv2) in order to initialize the camera and save it but the problem I have is when the image is read by cv, I do not get a pointer out that will send the image to the detectnet part of the code. So that is the problem I face with that. 2) When i actually go into the header file (.h) of the glDisplay.h or gstCamera.h. One problem with this is I’m not familiar with C/C++ only know some basics but never used header files too well. I see in the imageIO.h file there is some saveIMAGERGBA but I have not been able to use that to save the video/maybe don’t know exactly how.

I’m sure this is something minor that people have been able to do but my familiarity with scripts being python and calling in C/C++ headers and files is very limited. Any help would be useful.

Do you want to save the raw camera video, or the output including the detection bounding boxes? There is a gstEncoder class in jetson-utils for saving video, but I haven’t the Python bindings for it yet.

saveImageRGBA() would probably be too slow for saving every frame from a high-res live stream (it’s meant for individual images).

Regarding OpenCV, if you can get the OpenCV image into a 4-channel numpy array, see the cuda-from-numpy.py example in jetson-utils/python/examples. That will give you back the PyCapsule CUDA pointer object to use with detectNet.

1 Like

Aha, it appears that cv2 already uses numpy ndarrays:

https://stackoverflow.com/a/7776579

Hey dusty! Yes I would ideally just like to save the video file that has the output including the bounding boxes.

Thanks for the reply!

Dusty help please!

Can u write a function to save video from picamera to disk in python? (For detectnet-camera.py)