Unable to write all the cropped faces from the frame- Segmentation core dumped

Please provide complete information as applicable to your setup.

• Hardware Platform: Jetson TX2
• DeepStream Version: 5.1
• JetPack Version: 4.5.1
• TensorRT Version: 7.1.3

I am using deepstream-image-meta-test application for the image cropping…
I have integrated the same image cropping code in deepstream-test2

My issue is

If 2 faces are in a single frame, both the faces are detected but only 2nd face is writing to disk till 10 images then 1st face is writen to disk
till 20 images.

But both the faces are present in a single frame

The following is the code which im using for cropping images

static GstPadProbeReturn
osd_sink_pad_buffer_probe (GstPad * pad, GstPadProbeInfo * info,
    gpointer u_data)
{
for (l_frame = batch_meta->frame_meta_list; l_frame != NULL;
      l_frame = l_frame->next) {
        NvDsFrameMeta *frame_meta = (NvDsFrameMeta *) (l_frame->data);
        int offset = 0;
        int obj_ids[50];
        int current_pos = 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_FACE) {
                face_count++;
                num_rects++;

                for(l_classifier = obj_meta->classifier_meta_list; l_classifier != NULL;
                l_classifier = l_classifier->next) {
                  class_meta = (NvDsClassifierMeta *)(l_classifier->data);
                  for(l_label = class_meta->label_info_list; l_label != NULL;
                  l_label = l_label->next) {
                    label_info = (NvDsLabelInfo *) (l_label->data);
                                     
                }
                
              }          
                     
            }
            char fileNameString[FILE_NAME_SIZE];
            const char *osd_string = "OSD";
            int obj_res_width = (int) obj_meta->rect_params.width;
            int obj_res_height = (int) obj_meta->rect_params.height;
            if(prop.integrated) {
              obj_res_width = GST_ROUND_DOWN_2(obj_res_width);
              obj_res_height = GST_ROUND_DOWN_2(obj_res_height);
            } 

            snprintf (fileNameString, FILE_NAME_SIZE, "/opt/nvidia/deepstream/deepstream-5.1/samples/images/%s_%d_%d_%d.jpg",
                osd_string, frame_number, frame_meta->source_id, num_rects);
            
            /* For Demonstration Purposes we are writing metadata to jpeg images of
            * only face for the first 100 frames only.
            * The files generated have a 'OSD' prefix. */
            if (obj_meta->class_id == PGIE_CLASS_ID_FACE || obj_meta->class_id == NULL) {
              NvDsUserMetaList *usrMetaList = obj_meta->obj_user_meta_list;
              FILE *file;
              while (usrMetaList != NULL) {
                NvDsUserMeta *usrMetaData = (NvDsUserMeta *) usrMetaList->data;
                if (usrMetaData->base_meta.meta_type == NVDS_CROP_IMAGE_META) {
                  NvDsObjEncOutParams *enc_jpeg_image =
                      (NvDsObjEncOutParams *) usrMetaData->user_meta_data;
                  /* Write to File */
                   file = fopen (fileNameString, "wb");
                
                   fwrite (enc_jpeg_image->outBuffer, sizeof (uint8_t),
                      enc_jpeg_image->outLen, file);
                   fclose (file);
                  usrMetaList = NULL;
                } else {
                  usrMetaList = usrMetaList->next;
                }
              }
            } 
        }
}  
    frame_number++;
    return GST_PAD_PROBE_OK;
}

While running the executable file it is not running the full video, instead it runs upto certain number of frames and it gets dumped

Output:
Segmentation fault (core dumped)

Image Reference-1:

In the above images 2 faces are detected but look at the below image how it writes to disk

Image Reference-2:


In the above images 3 faces are detected but look at the below image how it writes to disk

After it detects face upto 140 frames then it is core dumped

Anyone help me to solve this case

Can you tell us how to reproduce your problem? Can you send us your code, the model, test video and your configurations?

@Fiona.Chen
I can share you the code, the model, test video and configurations.
I’ll share you via private message

@Fiona.Chen
Please check your private message, I have sent the model, code and config files uploaded to dropbox

It may take some time.

Ok. Please inform if anything comes up.

Thanks

i think problem at this line

try with [nvds_obj_encode.h] to save image
(NVIDIA DeepStream SDK API Reference: nvds_obj_encode.h File Reference):

https://docs.nvidia.com/metropolis/deepstream/5.0DP/dev-guide/DeepStream_Development_Guide/baggage/nvds__obj__encode_8h_source.html

@Fiona.Chen Is there any update on the issue?

@Fiona.Chen Any update on this issue?