NvDsEventMsgMeta¶
- 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 inextMsg
. A custom object must be handled by the metadata parsing module accordingly.- Variables:
type –
NvDsEventType
, Type of event.objType –
NvDsObjectType
, Type of object.bbox –
NvDsRect
, Bounding box of object.location –
NvDsGeoLocation
, Geo-location of object.coordinate –
NvDsCoordinate
, Coordinate of object.objSignature –
NvDsObjectSignature
, Signature of object.objClassId – int, Class id of object.
sensorId – int, ID of sensor that generated the event.
moduleId – int, ID of analytics module that generated the event.
placeId – int, ID of place related to the object.
componentId – int, ID of component that generated this event.
frameId – int, Video frame ID of this event.
confidence – int, Confidence level of the inference.
trackingId – int, Tracking ID of object.
ts – str, Time stamp of generated event.
objectId – str, ID of detected / inferred object.
sensorStr – str, Identity string of sensor.
otherAttrs – str, Other attributes associated with the object.
videoPath – str, 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.
extMsgSize – int, 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. if(class_id==PGIE_CLASS_ID_VEHICLE): 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() obj=generate_person_meta(obj) meta.extMsg = obj meta.extMsgSize = sys.getsizeof(pyds.NvDsPersonObject) return meta ... user_event_meta = pyds.nvds_acquire_user_meta_from_pool(batch_meta) if(user_event_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=pyds.alloc_nvds_event_msg_meta(user_event_meta) 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.user_meta_data = msg_meta; user_event_meta.base_meta.meta_type = pyds.NvDsMetaType.NVDS_EVENT_MSG_META pyds.nvds_add_user_meta_to_frame(frame_meta, user_event_meta) else: print("Error in attaching event meta to buffer\n")
- cast(*args, **kwargs)¶
Overloaded function.
cast(self: capsule) -> pyds.NvDsEventMsgMeta
casts to
NvDsEventMsgMeta
object, call pyds.NvDsEventMsgMeta(data)cast(self: int) -> pyds.NvDsEventMsgMeta
casts to
NvDsEventMsgMeta
object, call pyds.NvDsEventMsgMeta(data)