Segmentation fault (core dumped) on deepstream-test5-ap

Hello every one,
I am working with deepstream-test5-app with a custom save object frame to image.

i has save object to image with function:

bool save_image(gchar *path,
                       NvBufSurface *ip_surf, NvDsObjectMeta *obj_meta,
                       NvDsFrameMeta *frame_meta, gint obj_counter, gpointer obj_ctx_handle) {
    NvDsObjEncUsrArgs userData = {0};
    if (strlen(path) >= sizeof(userData.fileNameImg)) {
        g_print ("Path save image out of size\n");
        return false;
    userData.saveImg = TRUE;
    userData.attachUsrMeta = FALSE;
    userData.fileNameImg[strlen(path)] = '\0';
    userData.objNum = obj_counter++;

    nvds_obj_enc_process(obj_ctx_handle, &userData, ip_surf, obj_meta, frame_meta);
    nvds_obj_enc_finish (obj_ctx_handle);
    return true;

i call this function in bbox_generated_probe_after_analytics() with two option:

Option1: Just save object

/// Save a cropped object
save_image("object_image.jpg", ip_surf, obj_meta, frame_meta, 0, appCtx->obj_ctx_handle);

Option2: Save object’s frame

/// Creating a special object meta in order to save a full frame
        gint dummy_counter = 0;
        NvDsObjectMeta *dummy_obj_meta = NULL;
        dummy_obj_meta->rect_params.width = ip_surf->surfaceList[frame_meta->batch_id].width;
        dummy_obj_meta->rect_params.height = ip_surf->surfaceList[frame_meta->batch_id].height;
        dummy_obj_meta-> = 0;
        dummy_obj_meta->rect_params.left = 0;
        save_image("full_frame.jpg", ip_surf, dummy_obj_meta, frame_meta, dummy_counter, appCtx->obj_ctx_handle);

• Issue: With option 1 it work well, but with option 2 i get an error:

**PERF:  FPS 0 (Avg)	FPS 1 (Avg)	
Mon Nov 30 13:13:40 2020
**PERF:  0.00 (0.00)	0.00 (0.00)	
** INFO: <bus_callback:181>: Pipeline ready

** INFO: <bus_callback:167>: Pipeline running

Segmentation fault (core dumped)

How i can fix it, help me

• Hardware Platform Jetson
• DeepStream Version 5.0
• JetPack Version 4.4.1
• TensorRT Version
• NVIDIA GPU Driver Version (valid for GPU only)
• Issue Type: bugs

Core dumped begin from line:
dummy_obj_meta->rect_params.width = ip_surf->surfaceList[frame_meta->batch_id].width;

but i don’t know why

It is of no use to just show some pieces of your codes. Why don’t you refer to deepstream-image-meta-test to understand the interfaces and usage of encoding object jpg image?

Can you refer to Encoding jpeg image after OSD causes segfault - Intelligent Video Analytics / DeepStream SDK - NVIDIA Developer Forums first? His codes can work.

with option1 it work well,
I have received object_image.jpg. But with option2 i get core dumped at line dummy_obj_meta->rect_params.width = ip_surf->surfaceList[frame_meta->batch_id].width; are you clear

i try print value of ip_surf->surfaceList[frame_meta->batch_id].width;

Mon Nov 30 15:58:09 2020
**PERF:  29.99 (31.95)	
Mon Nov 30 15:58:14 2020
**PERF:  30.01 (31.17)	
Mon Nov 30 15:58:19 2020
**PERF:  29.99 (30.84)	

the value of it not NULL , why core dumped

“dummy_obj_meta->rect_params.width = ip_surf->surfaceList[frame_meta->batch_id].width;” is wrong. The object is detected and inserted to meta by nvinfer, you can not do it in probe function.

Please refer to Encoding jpeg image after OSD causes segfault - Intelligent Video Analytics / DeepStream SDK - NVIDIA Developer Forums, he does the right thing. deepstream-test5 and deepstream-app are the same.

no, this value is right, this is width of source video
In option 2 i want to save frame has object.
can you see in deepstream_transfer_learning_app_main.cpp

NvDsObjectMeta *dummy_obj_meta = NULL;
dummy_obj_meta->rect_params.width = ip_surf->surfaceList[frame_meta->batch_id].width;

You define a NULL pointer, and then assign value to the member of this NULL pointer, why do you think this will work?

i has try with NvDsObjectMeta *dummy_obj_meta; but still error

Are you C/C++ programmer? C/C++ can not support NULL pointer(or random pointer) assignment. Please study C/C++ grammer and programming guide first.,

Can you focus on DeepStream related topic in DeepStream forum?

1 Like

sory i dont now it, thank yous