Deepstream_app.c:(.text+0x17b8): undefined reference to `EdgeDection'

Please provide complete information as applicable to your setup.

**• Hardware Platform (Jetson / GPU)**Jetson
• DeepStream Version6.1.1
**• JetPack Version (valid for Jetson only)**5.0.1
**• Issue Type( questions, new requirements, bugs)**questions
Hi guys, I am trying to use my custom function EdgeDection in the deepstream_app samples:
the folder is like:
image

my custom function EdgeDection is defined in the deepstream_app_config_parser_yaml.cpp
and make declaration in the deepstream_app.h.
To be sure, the

gboolean
parse_config_file_yaml (NvDsConfig * config, gchar * cfg_file_path);

is defined in the deepstream_app_config_parser_yaml.cpp and also make declaration in the deepstream_app.h.In that way ,the function can be used in the deepstream_app_main.c.

So, my question is,in the similar situation,why my custom function can’t be used in the deepstream_app.c with the errors:

/usr/bin/ld: deepstream_app.o: in function `gie_processing_done_buf_prob':
deepstream_app.c:(.text+0x17b8): undefined reference to `EdgeDection'
collect2: error: ld returned 1 exit status
make: *** [Makefile:77:deepstream-apptest] error 1

Could you attach your source code?

Of course,to begin with,the EdgeDection is defined in the deepstream_app_config_parser_yaml.cpp:

//custom function
void EdgeDection(guint height,guint width,NvBufSurface *surface,NvDsFrameMeta *frame_meta,float * angle){
  Mat nv12_mat = Mat(height*3/2, width, CV_8UC1, surface->surfaceList[frame_meta->batch_id].mappedAddr.addr[0],
  surface->surfaceList[frame_meta->batch_id].pitch);
  //Convert nv12 to RGBA to apply algo based on RGBA
  Mat rgba_mat;
  cvtColor(nv12_mat, rgba_mat, COLOR_YUV2BGRA_NV12);
  for (NvDsMetaList * l_obj = frame_meta->obj_meta_list; l_obj != NULL;
  l_obj = l_obj->next) {
    NvDsObjectMeta *obj = (NvDsObjectMeta *) l_obj->data;
    Rect bbox(obj->rect_params.left, obj->rect_params.top,
                obj->rect_params.width, obj->rect_params.height);
    Mat roi = rgba_mat(bbox);
    float angle;
    Ellipse_feature_extraction(roi,angle);  
    }
}

the Ellipse_feature_extraction is another custom function to get the angle of the detected object.
And the declaration in deepstream_app.h:

gboolean
parse_config_file_yaml (NvDsConfig * config, gchar * cfg_file_path);

void EdgeDection(int height,int width,NvBufSurface *surface,NvDsFrameMeta *frame_meta, float * angle);

the parse_config_file_yaml function, just like what I have mentioned,is originally defined in that cpp file and can be used in the deepstream_app_main.c

After that,my custom funtion is used in the deepstream_app.c,the code snippet:

static GstPadProbeReturn
gie_processing_done_buf_prob (GstPad * pad, GstPadProbeInfo * info,
    gpointer u_data)
{
  GstBuffer *buf = (GstBuffer *) info->data;
  NvDsInstanceBin *bin = (NvDsInstanceBin *) u_data;
  guint index = bin->index;
  AppCtx *appCtx = bin->appCtx;
  //extra  
  NvDsBatchMeta *batch_meta = gst_buffer_get_nvds_batch_meta(buf);
  // Get original raw data
  GstMapInfo in_map_info;
  if (!gst_buffer_map (buf, &in_map_info, GST_MAP_READ)) {
      g_print ("Error: Failed to map gst buffer\n");
      gst_buffer_unmap (buf, &in_map_info);
      return GST_PAD_PROBE_OK;
      }
  NvBufSurface *surface = (NvBufSurface *)in_map_info.data;
  for (NvDsMetaList * l_frame = batch_meta->frame_meta_list; l_frame != NULL;
      l_frame = l_frame->next) {
      NvDsFrameMeta *frame_meta = l_frame->data;
      //TODO for cuda device memory we need to use cudamemcpy
      NvBufSurfaceMap (surface, -1, -1, NVBUF_MAP_READ);
      /* Cache the mapped data for CPU access */
      NvBufSurfaceSyncForCpu (surface, 0, 0); //will do nothing for unified memory type on dGPU
      guint height = surface->surfaceList[frame_meta->batch_id].height;
      guint width = surface->surfaceList[frame_meta->batch_id].width;
      float angle;
      EdgeDection(height,width,surface,frame_meta,& angle);  
       }
      }

As you can see,I call that funtion in the end,trying to get the ultimate angle parameter.If there are other codes you want to know,please feel free to tell me.

You can try include the header file in the deepstream_app.c. We suggest you take a brief look at the C language and its compilation rules if you want to modify the C code.

hi,it seems that the statement in the deepstream_app.h has something to do with the problem.I change the statement:
int width to guint width
then it works

Glad to hear that.

oh,glad to see you online.Here is another problem for me.As you can see,the object loop is in the EdgeDection funtion:

//custom function
void EdgeDection(guint height,guint width,NvBufSurface *surface,NvDsFrameMeta *frame_meta,float * angle){
  Mat nv12_mat = Mat(height*3/2, width, CV_8UC1, surface->surfaceList[frame_meta->batch_id].mappedAddr.addr[0],
  surface->surfaceList[frame_meta->batch_id].pitch);
  //Convert nv12 to RGBA to apply algo based on RGBA
  Mat rgba_mat;
  cvtColor(nv12_mat, rgba_mat, COLOR_YUV2BGRA_NV12);
  for (NvDsMetaList * l_obj = frame_meta->obj_meta_list; l_obj != NULL;
  l_obj = l_obj->next) {
    NvDsObjectMeta *obj = (NvDsObjectMeta *) l_obj->data;
    Rect bbox(obj->rect_params.left, obj->rect_params.top,
                obj->rect_params.width, obj->rect_params.height);
    Mat roi = rgba_mat(bbox);
    float angle;
    Ellipse_feature_extraction(roi,angle);  
    }
}

then I call this funtion in the frame loop,in this way,is the object loop works fine?

We will discuss this problem in your new topic 309342.

Oh,thanks,sincerely looking forward to your reply

Is this the same as the topic with 309784?

yes,it has been solved

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