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) {

                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;
    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

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?

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

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.


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):


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

@Fiona.Chen Any update on this issue?

Hi RajeshMuthuswamy,

Have you triedi with the suggestion from Unable to write all the cropped faces from the frame- Segmentation core dumped - #8 by PhongNT?

@kayccc I tried that option but the issue still same

Did this still be an issue?

Yes still this issue is not solved

Can you share the code, the model, test video and configurations?

@Amycao I have sent you the model, config files, code and videos via private message.

Please check and let me know if you need any additional details.

You just got one image saved although detected more than one objects, that’s because in function pgie_src_pad_buffer_probe, there one condition as below, it just save one image for PGIE_CLASS_ID_FACE, if remove num_rects == 1, you can get all the objects saved.
if ((obj_meta->class_id == PGIE_CLASS_ID_FACE)
&& num_rects == 1) {
as for core dumped, i upload my modified code, remove anything customized, i did not have this issue. i do not have much time, you can go ahead check from your customized part, which caused the core dumped issue.deepstream_test2_app.c (33.1 KB)

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