Callback function for deep-copying an NvDsEventMsgMeta struct
def meta_copy_func(data,user_data):
# Cast data to pyds.NvDsUserMeta
user_meta=pyds.NvDsUserMeta.cast(data)
src_meta_data=user_meta.user_meta_data
# Cast src_meta_data to pyds.NvDsEventMsgMeta
srcmeta=pyds.NvDsEventMsgMeta.cast(src_meta_data)
# Duplicate the memory contents of srcmeta to dstmeta
# First use pyds.get_ptr() to get the C address of srcmeta, then
# use pyds.memdup() to allocate dstmeta and copy srcmeta into it.
# pyds.memdup returns C address of the allocated duplicate.
dstmeta_ptr=pyds.memdup(pyds.get_ptr(srcmeta), sys.getsizeof(pyds.NvDsEventMsgMeta))
# Cast the duplicated memory to pyds.NvDsEventMsgMeta
dstmeta=pyds.NvDsEventMsgMeta.cast(dstmeta_ptr)
# Duplicate contents of ts field. Note that reading srcmeat.ts
# returns its C address. This allows to memory operations to be
# performed on it.
dstmeta.ts=pyds.memdup(srcmeta.ts, MAX_TIME_STAMP_LEN+1)
# Copy the sensorStr. This field is a string property.
# The getter (read) returns its C address. The setter (write)
# takes string as input, allocates a string buffer and copies
# the input string into it.
# pyds.get_string() takes C address of a string and returns
# the reference to a string object and the assignment inside the binder copies content.
dstmeta.sensorStr=pyds.get_string(srcmeta.sensorStr)
if(srcmeta.objSignature.size>0):
dstmeta.objSignature.signature=pyds.memdup(srcmeta.objSignature.signature,srcMeta.objSignature.size)
dstmeta.objSignature.size = srcmeta.objSignature.size;
if(srcmeta.extMsgSize>0):
if(srcmeta.objType==pyds.NvDsObjectType.NVDS_OBJECT_TYPE_VEHICLE):
srcobj = pyds.NvDsVehicleObject.cast(srcmeta.extMsg);
obj = pyds.alloc_nvds_vehicle_object();
obj.type=pyds.get_string(srcobj.type)
obj.make=pyds.get_string(srcobj.make)
obj.model=pyds.get_string(srcobj.model)
obj.color=pyds.get_string(srcobj.color)
obj.license = pyds.get_string(srcobj.license)
obj.region = pyds.get_string(srcobj.region)
dstmeta.extMsg = obj;
dstmeta.extMsgSize = sys.getsizeof(pyds.NvDsVehicleObject)
if(srcmeta.objType==pyds.NvDsObjectType.NVDS_OBJECT_TYPE_PERSON):
srcobj = pyds.NvDsPersonObject.cast(srcmeta.extMsg);
obj = pyds.alloc_nvds_person_object()
obj.age = srcobj.age
obj.gender = pyds.get_string(srcobj.gender);
obj.cap = pyds.get_string(srcobj.cap)
obj.hair = pyds.get_string(srcobj.hair)
obj.apparel = pyds.get_string(srcobj.apparel);
dstmeta.extMsg = obj;
dstmeta.extMsgSize = sys.getsizeof(pyds.NvDsVehicleObject);
return dstmeta
}
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.set_user_copyfunc(user_event_meta, meta_copy_func)
pyds.set_user_releasefunc(user_event_meta, meta_free_func)
pyds.nvds_add_user_meta_to_frame(frame_meta, user_event_meta)
else:
print("Error in attaching event meta to buffer\n")
I am trying to send event meta data to kafka But I am getting segmentation fault after running for some time can anyone help?After debbuging i got this error
Frame Number = 2578 Vehicle Count = 0 Person Count = 1
Frame Number = 2579 Vehicle Count = 0 Person Count = 1
Frame Number = 2580 Vehicle Count = 0 Person Count = 1
Frame Number = 2581 Vehicle Count = 0 Person Count = 1
Fatal Python error: Segmentation fault
Current thread 0x00007f0bde477700 (most recent call first):
File “kafka_deep4.py”, line 73 in meta_copy_func
Thread 0x00007f0c4e4dd740 (most recent call first):
File “/usr/lib/python3/dist-packages/gi/overrides/GLib.py”, line 585 in run
File “kafka_deep4.py”, line 598 in main
File “kafka_deep4.py”, line 661 in
Segmentation fault