objNum in NvDsObjEncUsrArgs

• Hardware Platform (Jetson / GPU): rtx 3090
• DeepStream Version: 5.1
• TensorRT Version: 7.2.3
• NVIDIA GPU Driver Version (valid for GPU only): 460.73.01
• Issue Type( questions, new requirements, bugs): questions

nvds_obj_enc_process function has 4 arguments. The second arguments is NvDsObjEncUsrArgs and and fourth argument is NvDsObjectMeta.

The second arguments NvDsObjEncUsrArgs has variable objNum to set object number in the frame.

What is idea behind the objNum variable if this function nvds_obj_enc_process takes exaclty one detected object NvDsObjectMeta ?

If I take a look to the deepstream-image-meta-test example from sample_apps, they use the nvds_obj_enc_process function like this:

guint num_rects = 0;
for (l_obj = frame_meta->obj_meta_list; l_obj != NULL; l_obj = l_obj->next) {
obj_meta = (NvDsObjectMeta ) (l_obj->data);
if (obj_meta->class_id == PGIE_CLASS_ID_VEHICLE) {
if (obj_meta->class_id == PGIE_CLASS_ID_PERSON) {
Conditions that user needs to set to encode the detected objects of
* interest. Here, by default all the detected objects are encoded.
* For demonstration, we will encode the first object in the frame /
if ((obj_meta->class_id == PGIE_CLASS_ID_PERSON
|| obj_meta->class_id == PGIE_CLASS_ID_VEHICLE)
&& num_rects == 1) {
NvDsObjEncUsrArgs userData = { 0 };
To be set by user /
userData.saveImg = save_img;
userData.attachUsrMeta = attach_user_meta;
Set if Image scaling Required /
userData.scaleImg = FALSE;
userData.scaledWidth = 0;
userData.scaledHeight = 0;
Preset */
userData.objNum = num_rects;
/*Main Function Call */
nvds_obj_enc_process (ctx, &userData, ip_surf, obj_meta, frame_meta);

they put num_rects variable to userData.objNum, but I do not undestand why, because the nvds_obj_enc_process function takes only one obj_meta object.

Can anyone explain to me why and how to set userData.objNum?

When you enable the file saving, nvds_obj_enc_process() will save the encoded picture into a file. The file name needs objNum as part of it. The file name looks in this way: framenum_batchid_objNum_objLabel_widthxheight.jpg". So the objNum is used to make the filename unique for every object.

1 Like