class pyds.NvDsEventMsgMeta

Holds event message meta data. You can attach various types of objects (vehicle, person, face, etc.) to an event by setting a pointer to the object in extMsg. Similarly, you can attach a custom object to an event by setting a pointer to the object in extMsg. A custom object must be handled by the metadata parsing module accordingly.

  • typeNvDsEventType, Type of event.

  • objTypeNvDsObjectType, Type of object.

  • bboxNvDsRect, Bounding box of object.

  • locationNvDsGeoLocation, Geo-location of object.

  • coordinateNvDsCoordinate, Coordinate of object.

  • objSignatureNvDsObjectSignature, Signature of object.

  • objClassIdint, Class id of object.

  • sensorIdint, ID of sensor that generated the event.

  • moduleIdint, ID of analytics module that generated the event.

  • placeIdint, ID of place related to the object.

  • componentIdint, ID of component that generated this event.

  • frameIdint, Video frame ID of this event.

  • confidenceint, Confidence level of the inference.

  • trackingIdint, Tracking ID of object.

  • tsstr, Time stamp of generated event.

  • objectIdstr, ID of detected / inferred object.

  • sensorStrstr, Identity string of sensor.

  • otherAttrsstr, Other attributes associated with the object.

  • videoPathstr, Name of video file.

  • extMsg – Object to extend the event message meta data. This can be used for custom values that can’t be accommodated in the existing fields OR if object(vehicle, person, face etc.) Specific values must be attached.

  • extMsgSizeint, Size of the custom object at extMsg.

Example usage:

def generate_event_msg_meta(data, class_id):
    meta =pyds.NvDsEventMsgMeta.cast(data)
    meta.sensorId = 0
    meta.placeId = 0
    meta.moduleId = 0
    meta.sensorStr = "sensor-0"
    meta.ts = pyds.alloc_buffer(MAX_TIME_STAMP_LEN + 1)
    pyds.generate_ts_rfc3339(meta.ts, MAX_TIME_STAMP_LEN) #Generate timestamp

    # This demonstrates how to attach custom objects.
    # Any custom object as per requirement can be generated and attached
    # like NvDsVehicleObject / NvDsPersonObject. Then that object should
    # be handled in payload generator library (nvmsgconv.cpp) accordingly.
        meta.type = pyds.NvDsEventType.NVDS_EVENT_MOVING
        meta.objType = pyds.NvDsObjectType.NVDS_OBJECT_TYPE_VEHICLE
        meta.objClassId = PGIE_CLASS_ID_VEHICLE
        obj = pyds.alloc_nvds_vehicle_object()
        obj = generate_vehicle_meta(obj) #See NvDsVehicleObject example code
        meta.extMsg = obj
        meta.extMsgSize = sys.getsizeof(pyds.NvDsVehicleObject);
    if(class_id == PGIE_CLASS_ID_PERSON):
        meta.type =pyds.NvDsEventType.NVDS_EVENT_ENTRY
        meta.objType = pyds.NvDsObjectType.NVDS_OBJECT_TYPE_PERSON;
        meta.objClassId = PGIE_CLASS_ID_PERSON
        obj = pyds.alloc_nvds_person_object()
        meta.extMsg = obj
        meta.extMsgSize = sys.getsizeof(pyds.NvDsPersonObject)
    return meta


# Allocating an NvDsEventMsgMeta instance and getting reference
# to it. The underlying memory is not manged by Python so that
# downstream plugins can access it. Otherwise the garbage collector
# will free it when this probe exits.
msg_meta.bbox.top =  obj_meta.rect_params.top
msg_meta.bbox.left =  obj_meta.rect_params.left
msg_meta.bbox.width = obj_meta.rect_params.width
msg_meta.bbox.height = obj_meta.rect_params.height
msg_meta.frameId = frame_number
msg_meta.trackingId = long_to_uint64(obj_meta.object_id)
msg_meta.confidence = obj_meta.confidence
msg_meta = generate_event_msg_meta(msg_meta, obj_meta.class_id)
user_event_meta = pyds.nvds_acquire_user_meta_from_pool(batch_meta)
    user_event_meta.user_meta_data = msg_meta;
    user_event_meta.base_meta.meta_type = pyds.NvDsMetaType.NVDS_EVENT_MSG_META
    # Setting callbacks in the event msg meta. The bindings layer
    # will wrap these callables in C functions. Currently only one
    # set of callbacks is supported.
    pyds.user_copyfunc(user_event_meta, meta_copy_func)
    pyds.user_releasefunc(user_event_meta, meta_free_func)
    pyds.nvds_add_user_meta_to_frame(frame_meta, user_event_meta)
    print("Error in attaching event meta to buffer\n")
cast(*args, **kwargs)

Overloaded function.

  1. cast(self: capsule) -> pyds.NvDsEventMsgMeta

casts to NvDsEventMsgMeta object, call pyds.NvDsEventMsgMeta(data)

  1. cast(self: int) -> pyds.NvDsEventMsgMeta

casts to NvDsEventMsgMeta object, call pyds.NvDsEventMsgMeta(data)