Drawing more than 16 line with nvdsosd

• Hardware Platform (Jetson / GPU) dGPU
• DeepStream Version 7.1.0, nvcr.io/nvidia/deepstream:7.1-gc-triton-devel
• JetPack Version (valid for Jetson only)
• TensorRT Version
• NVIDIA GPU Driver Version (valid for GPU only) 3090
• Issue Type( questions, new requirements, bugs) question, bugs
• How to reproduce the issue ? (This is for bugs. Including which sample app is using, the configuration files content, the command line used and other details for reproducing)
• Requirement details( This is for new requirement. Including the module name-for which plugin or for which sample application, the function description)

Hi All,

I am trying to set the display meta to show more than 16 lines on the screen with nvdsosd. With the default setting, the object pyds.NvDsDisplayMeta could only store 16 lines.

I found the following post: Increase MAX_ELEMENTS_IN_DISPLAY_META for pyds

Where I can change MAX_ELEMENTS_IN_DISPLAY_META in the header file nvdsmeta.h in source from 16 to 32.

and rebuild and reinstall the python binding following

deepstream_python_apps/bindings at master · NVIDIA-AI-IOT/deepstream_python_apps · GitHub.

In python, I am able to see the list NvOSD_LineParams size change from 16 to 32. But when I edit the color params, the whole pipeline freeze and crash. I reinstall the old wheel and the pipeline works again.

Please find the probe for changing the display meta as follow:

def draw_display_meta(batch_meta: pyds.NvDsBatchMeta, frame_meta: pyds.NvDsFrameMeta):
    display_meta: pyds.NvDsDisplayMeta = pyds.nvds_acquire_display_meta_from_pool(batch_meta)

    # generate 20 lines
    display_meta.num_lines = 4

    for i in range(4):
        line = display_meta.line_params[i]
        line.line_width = 3
        line.x1, line.y1, linex2, line.y2 = 50+10*i, 50+10*i, 500+10*i, 50+10*i
        # line.line_color.set(1.0, 0., 0., 1.0)
        line.line_color.red = 1.0
        line.line_color.green = 0.0
        line.line_color.blue = 0.0
        line.line_color.alpha = 1.0

    return None

I have also tried not changing the color, and the pipeline does not freeze on the modified (32 max element) wheel.

def draw_display_meta(batch_meta: pyds.NvDsBatchMeta, frame_meta: pyds.NvDsFrameMeta):
    display_meta: pyds.NvDsDisplayMeta = pyds.nvds_acquire_display_meta_from_pool(batch_meta)

    # generate 20 lines
    display_meta.num_lines = 4

    for i in range(4):
        line = display_meta.line_params[i]
        line.line_width = 3
        line.x1, line.y1, linex2, line.y2 = 50+10*i, 50+10*i, 500+10*i, 50+10*i
        # line.line_color.set(1.0, 0., 0., 1.0)
        # line.line_color.red = 1.0
        # line.line_color.green = 0.0
        # line.line_color.blue = 0.0
        # line.line_color.alpha = 1.0

    return None

Please kindly advice!

Please do not hange MAX_ELEMENTS_IN_DISPLAY_META in the header file nvdsmeta.h yourself. When you want to draw more that 16 lines, you can just acquire a new display meta. You can refer to our C/C++ sample deepstream_faciallandmark_app.cpp to learn how to draw more than 16 circles. The principle is the same.

1 Like

python example:

def draw_display_meta(batch_meta: pyds.NvDsBatchMeta, frame_meta: pyds.NvDsFrameMeta):
    # generate first 16 line
    display_meta: pyds.NvDsDisplayMeta = pyds.nvds_acquire_display_meta_from_pool(batch_meta)
    display_meta.num_lines = 16

    for i in range(16):
        line = display_meta.line_params[i]
        line.line_width = 3
        line.x1, line.y1, linex2, line.y2 = 50+10*i, 50+10*i, 500+10*i, 50+10*i
        line.line_color.set(1.0, 0., 0., 1.0)

    pyds.nvds_add_display_meta_to_frame(frame_meta, display_meta)

    # generate next 16 line
    display_meta_2: pyds.NvDsDisplayMeta = pyds.nvds_acquire_display_meta_from_pool(batch_meta)
    display_meta_2.num_lines = 16

    for i in range(16):
        line = display_meta_2.line_params[i]
        line.line_width = 3
        line.x1, line.y1, linex2, line.y2 = 50+10*(i+16), 50+10*(i+16), 50+10*(i+16), 500+10*(i+16)
        line.line_color.set(0.0, 1.0, 0., 1.0)

    pyds.nvds_add_display_meta_to_frame(frame_meta, display_meta_2)

    return None

Thank you for sharing this python example, which is convenient for others to refer to