Can someone help me figure this out? I want to try to create a custom message meta as stated in the README of python test-app 4:
Generating custom metadata for different type of objects:
In addition to common fields provided in NvDsEventMsgMeta structure, user can
also create custom objects and attach to buffer as NVDS_META_EVENT_MSG metadata.
To do that NvDsEventMsgMeta provides "extMsg" and "extMsgSize" fields. User can
create custom structure, fill that structure and assign the pointer of that
structure as "extMsg" and set the "extMsgSize" accordingly.
If custom object contains fields that can't be simply mem copied then user should
also provide function to copy and free those objects.
Refer generate_event_msg_meta() to know how to use "extMsg" and "extMsgSize"
fields for custom objects and how to provide copy/free function and attach that
object to buffer as metadata.
Therefore I created a simple python class with one member:
class MyObject:
def __init__(self, num):
self.num = num
and I want to assign an instance of this to the meta.extMsg:
# set the values of the meta object
meta.type = pyds.NvDsEventType.NVDS_EVENT_CUSTOM
meta.objType = 42
meta.objClassId = 42
# create the meta extension object and set its obj
obj = MyObject(42)
obj_size = sys.getsizeof(obj)
# allocate a c buffer and assign the pointer address
meta.extMsg = pyds.alloc_buffer(obj_size)
meta.extMsgSize = obj_size
But this will only allocate empty memory without a reference to “obj”. How can I write it to the pointer address?
Sadly there is no documentation at all on how to use custom objects. I searched the Github and “alloc_buffer” is only used for a timestamp and not for python objects.