Capturing an image from an already opened gstreamer pipeline when an event occurs

Please provide complete information as applicable to your setup.

• Hardware Platform (Jetson / GPU) | Jetson
• DeepStream Version | 6.0.1
• JetPack Version (valid for Jetson only) | JetPack 4.6.3 (L4T 32.7.3)
• TensorRT Version | 8.2.1.8
• NVIDIA GPU Driver Version (valid for GPU only) -
• Issue Type( questions, new requirements, bugs) | Question
I am currently using the deepstream-occupancy-analytics project available here. I modified the config files a bit and enabled overcrowding and defined the 4 points of the polygon and the detection is working correctly and everything’s running smoothly.
However, I need to capture an image from the current stream (the same one shown in the camera preview when I run the solution, with the bounding boxes and rectangle…etc). I can access the ocStatus boolean value and print something to the console whenever a overcrowding occurs by adding a few lines to the provided C++ file (deepstream_nvdsanalytics_meta.cpp). It goes something like this:

 if (meta->ocStatus["OC"]) {
        std::cout << "OVERCROWDING DETECTED!" << std::endl;

        // Capture an image from the gstreamer pipeline already opened
        ...
    }

I couldn’t find a solution to this on this forum and from Google. Is there a reference C++ file that contains the same functionality I want? If not, can someone please provide some assistance and guide me through the process?
Thanks.

nvosd plugin will draws bounding boxes, text, arrows, lines, circles and region of interest (RoI) polygons on the original buffer. you can add a probe function on nvosd’s src element, and use nvds_obj_enc_process to encode the whole frame in this probe function, please refer to deepstream native sample deepstream-image-meta-test and this topic How to encode multiple images using the same objectMeta inside obj_meta_list

1 Like

Hey, thanks for responding. I looked into the C code of deepstream_image_meta_test and I found how the nvds_obj_enc_process function was used. However, it seems that the function only saves the detected objects. I want to save the entire frame to a JPEG image which I can specify its name and path, but I couldn’t find this information in several forum posts. I know I’m supposed to use NvBufSurface to map the entire frame, but I can’t find exactly how when reading through the referenced files.
I just need to capture the full frame when overcrowding occurs. Could you please walk me through the steps needed to do so?

no, it can save the whole frame, please refer to save frame , you can set newMeta.rect_params using the frame’s rect.

Ohh okay I’ll check this. However, I also need to only take one picture for each instance of overcrowding, but when I use the snippet of code in the cpp file mentioned in the question, the print statement goes off for each frame a detection occurs in. How can I do it only once when the OverCrowding status is 1 and wait until it’s zero again?

I suggest to use two global variables, one represents OverCrowding status A, the other one represents whether have saved frame B, if save frame when A is 1 and B is 0.

Thank you for that idea; simple but I didn’t think of it. I’ll try it.

Sorry for the late reply, Is this still an DeepStream issue to support? Thanks

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.