Hello, I am trying to write a script which sends data gathered from video feed run threw DeepStream to Kafka in Azure EventHubs and I ran into an issue. I am using Python I would like to send a custom message which would contain data about the vehicle which passed by the camera as such (current speed, average speed, highest speed, …). I would like to send them in a JSON format. For the seding of the message I am using nvmsgconv in my pipeline. Unfortunately I can’t find anywhere how to add those custom data to the message. How to also configure the .txt config file of the nvmsgconv? The output that would be send to kafka should look something like this: {“messageId”:1234, “data”:{“average_speed”:38, “max_speed”:45}}
Here is the current code which unfortunately doesn’t work (it doesn’t output anything like that is in this code):
user_event_meta = pyds.nvds_acquire_user_meta_from_pool(batch_meta)
if user_event_meta:
data = {
"custom_objects": obj_count
}
json_data = json.dumps(data)
buffer = ctypes.create_string_buffer(json_data.encode("utf-8"))
# Create a PyCapsule that wraps our C buffer.
ctypes.pythonapi.PyCapsule_New.restype = ctypes.py_object
capsule = ctypes.pythonapi.PyCapsule_New(buffer, None, None)
msg_meta = pyds.alloc_nvds_event_msg_meta(user_event_meta)
msg_meta.extMsg = capsule
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)
print("Event generated\n")
else:
print("Error in attaching event meta to buffer\n")