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 :

You could refer to
for how to count objects.