How to output the num_rects in NvDsDisplay Meta

I would like to output the value of num_rects in NvDsDisplay Meta because I am going to count the number of people in one frame with DeepStream SDK and then I would like to forward this value to kafka server.
So, could you please tell me how to do it?
reference : https://docs.nvidia.com/metropolis/deepstream/dev-guide/DeepStream%20Development%20Guide/baggage/structNvDsDisplayMeta.html#a88ce54ac4a43b4e21c65c9a8e7b14a1f

You could refer to
source/apps/sample_apps/deepstream-infer-tensor-meta-test/deepstream_infer_tensor_meta_test.cpp::osd_sink_pad_buffer_probe
for how to count objects.