Labels not showing on deepstream_test3

I’m working on top of deepstream_test3, trying to make a social-distance detector.
(Deepstream 5.0 on Jetson Xavier NX, Python samples)
I’ve managed to detect when the label is “person”, get it’s position and calculate the distance between everybody.
However, I need to print the number of violations on the image and it’s not working:

    display_meta.num_labels = 1 
    py_nvosd_text_params = display_meta.text_params[0]
    py_nvosd_text_params.display_text = "People: {}.  Social Distance Warnings: {}".format(obj_counter[PGIE_CLASS_ID_PERSON], num_violations)
    print(pyds.get_string(py_nvosd_text_params.display_text))  # This print is working fine!
    py_nvosd_text_params.x_offset = 10
    py_nvosd_text_params.y_offset = 12
    py_nvosd_text_params.font_params.font_name = "Serif"
    py_nvosd_text_params.font_params.font_size = 10
    py_nvosd_text_params.font_params.font_color.set(1.0, 1.0, 1.0, 1.0)
    py_nvosd_text_params.set_bg_clr = 1
    py_nvosd_text_params.text_bg_clr.set(0.0, 0.0, 0.0, 1.0) 
    pyds.nvds_add_display_meta_to_frame(frame_meta, display_meta)

I checked with the original deepstream_test3 script and it doesn’t show the text or the labels either.
I added a print(pyds.get_string(py_nvosd_text_params.display_text)) which is printing my information ok. It just doesn’t show on the stream!
Is there a way to “enable” the text on the image? (By the way, as well as the labels that aren’t appearing either)

Did you mean this text not shown with original test3 python sample?

    display_meta.num_labels = 1
    py_nvosd_text_params = display_meta.text_params[0]
    py_nvosd_text_params.display_text = "Frame Number={} Number of Objects={} Vehicle_count={} Person_count={}".format(frame_number, num_rects, vehicle_count, person)
    py_nvosd_text_params.x_offset = 10;
    py_nvosd_text_params.y_offset = 12;
    py_nvosd_text_params.font_params.font_name = "Serif"
    py_nvosd_text_params.font_params.font_size = 10 = 1.0 = 1.0 = 1.0
    py_nvosd_text_params.font_params.font_color.alpha = 1.0
    py_nvosd_text_params.set_bg_clr = 1 = 0.0 = 0.0 = 0.0
    py_nvosd_text_params.text_bg_clr.alpha = 1.0
    #print("Frame Number=", frame_number, "Number of Objects=",num_rects,"Vehicle_count=",vehicle_count,"Person_count=",person)
    pyds.nvds_add_display_meta_to_frame(frame_meta, display_meta)"""

First I ran it exactly like that… didn’t even look at the code.
Then, I realized those triple quotes might be interpreted as a “comment”, so I eliminated those and declared vehicle_count and person for it to run.
Both cases I got the same result: only bounding boxes appeared, no text showing on the video.
As a third test, I uncommented the print sentence in the second to last line you’re showing, and it seems to print correcty in the console, but still, no text on the video.
I’m attaching an image with the code I’m running, the video output and the console output.
Any idea what I’m doing wrong?

By default, display text on screen disabled,
change to 1 and try again.

1 Like