How to add a new object type attribute in deepstream python app?

Please provide complete information as applicable to your setup.

• Hardware Platform (Jetson / GPU) GPU
• DeepStream Version 5.0.1
• JetPack Version (valid for Jetson only)
• TensorRT Version 7.0.0.1
• NVIDIA GPU Driver Version (valid for GPU only) 450
• Issue Type( questions, new requirements, bugs) questions
• How to reproduce the issue ? (This is for bugs. Including which sample app is using, the configuration files content, the command line used and other details for reproducing)
• Requirement details( This is for new requirement. Including the module name-for which plugin or for which sample application, the function description)

Hi, I want to customize kafka message in deepstream python test4 app, trying to add a new attribute to NvDsVehicleObject in nvdsmeta_schma.h as follows:

typedef struct NvDsVehicleObject {
  gchar *type;
  gchar *make;  
  gchar *model; 
  gchar *color;   
  gchar *region; 
  gchar *license; 
  gchar *imgpath;   /**< THE NEW ATTRIBUTE I ADD. Holds a pointer to the image snapshot path. */
} NvDsVehicleObject;

I replace the nvdsmeta_schma.h in /opt/nvidia/deepstream/deepstream-5.0/sources/includes with the new one, and modify the message processing part in nvmsgconv.cpp, for example:

static gchar*
generate_deepstream_message_minimal (NvDsMsg2pCtx *ctx, NvDsEvent *events, guint size)
{

......

if (meta->extMsg && meta->extMsgSize) {
      // Attach secondary inference attributes.
      switch (meta->objType) {
        case NVDS_OBJECT_TYPE_VEHICLE: {
          NvDsVehicleObject *dsObj = (NvDsVehicleObject *) meta->extMsg;
          if (dsObj) {
            ss << "|#|" << to_str(dsObj->type) << "|" << to_str(dsObj->make) << "|"
               << to_str(dsObj->model) << "|" << to_str(dsObj->color) << "|" << to_str(dsObj->license)
               << "|" << to_str(dsObj->region) << "|" << meta->confidence << "|" << to_str(dsObj->imgpath);
          }
        }

/*add the imgpath to the end of message string*/

Run my app, but it raise an error:

Traceback (most recent call last):
  File "deepstream_test_4_custom_msg.py", line 304, in osd_sink_pad_buffer_probe
    msg_meta = generate_event_msg_meta(msg_meta, obj_meta.class_id)
  File "deepstream_test_4_custom_msg.py", line 195, in generate_event_msg_meta
    obj = generate_vehicle_meta(obj)
  File "deepstream_test_4_custom_msg.py", line 164, in generate_vehicle_meta
    obj.imgpath = "testttttttttttttttttttt.jpg"
AttributeError: 'pyds.NvDsVehicleObject' object has no attribute 'imgpath'

Seems the new attribute didn’t add successfully, and I don’t know if I have to recompile the pyds.so, so how to add a new object type attribute in deepstream python app? Thanks everyone.

Hi @CoderJustin,
Will check and get back to you.

There is a 3rd party reference for generating new python binding for pyds, you can refer to it.