NvOSD_TextParams¶
- class pyds.NvOSD_TextParams¶
Holds the parameters of the text to be overlaid.
- Variables:
display_text – str, Holds the text to be overlaid.
x_offset – int, Holds horizontal offset w.r.t top left pixel of the frame.
y_offset – int, Holds vertical offset w.r.t top left pixel of the frame.
font_params –
NvOSD_FontParams
, Holds the font parameters of the text to be overlaid.set_bg_clr – int, Boolean to indicate text has background color.
text_bg_clr –
NvOSD_ColorParams
, Holds the text’s background color, if specified.
Example usage:
display_meta=pyds.nvds_acquire_display_meta_from_pool(batch_meta) #Retrieve NvDsDisplayMeta object from given NvDsBatchMeta object. See NvDsMeta docs for more details. display_meta.num_labels = 1 py_nvosd_text_params = display_meta.text_params[0] #Retrieve NvOSD_TextParams object from list in display meta. # Setting display text to be shown on screen # Note that the pyds module allocates a buffer for the string, and the # memory will not be claimed by the garbage collector. # Reading the display_text field here will return the C address of the # allocated string. Use pyds.get_string() to get the string content. py_nvosd_text_params.display_text = "Frame Number={} Number of Objects={} Vehicle_count={} Person_count={}".format(frame_number, num_rects, obj_counter[PGIE_CLASS_ID_VEHICLE], obj_counter[PGIE_CLASS_ID_PERSON]) # Now set the offsets where the string should appear py_nvosd_text_params.x_offset = 10 py_nvosd_text_params.y_offset = 12 # Font , font-color and font-size py_nvosd_text_params.font_params.font_name = "Serif" #Set attributes of our NvOSD_TextParams object's NvOSD_FontParams member py_nvosd_text_params.font_params.font_size = 10 # set(red, green, blue, alpha); set to White py_nvosd_text_params.font_params.font_color.set(1.0, 1.0, 1.0, 1.0) #See NvOSD_ColorParams for more details. # Text background color py_nvosd_text_params.set_bg_clr = 1 #Set boolean indicating that text has bg color to true. # set(red, green, blue, alpha); set to Black py_nvosd_text_params.text_bg_clr.set(0.0, 0.0, 0.0, 1.0) # Using pyds.get_string() to get display_text as string print(pyds.get_string(py_nvosd_text_params.display_text)) pyds.nvds_add_display_meta_to_frame(frame_meta, display_meta) #Add display meta to frame after setting text params attributes.
- cast(*args, **kwargs)¶
Overloaded function.
cast(self: capsule) -> pyds.NvOSD_TextParams
cast given object/data to
NvOSD_TextParams
, call pyds.NvOSD_TextParams.cast(data)cast(self: int) -> pyds.NvOSD_TextParams
cast given object/data to
NvOSD_TextParams
, call pyds.NvOSD_TextParams.cast(data)