marcoslucianops / DeepStream-Yolo

NVIDIA DeepStream SDK 7.0 / 6.4 / 6.3 / 6.2 / 6.1.1 / 6.1 / 6.0.1 / 6.0 / 5.1 implementation for YOLO models
MIT License
1.39k stars 344 forks source link

Draw lines on the output display. #440

Open emad555 opened 10 months ago

emad555 commented 10 months ago

This is not an issue related to the repo implementation. I am trying to draw lines on perpendicular lines on the display.

I wrote this function inside deepstream_app_main.c:

void draw_perpendicular_lines(Display *display, Window window) {
    XGCValues gc_values;
    GC gc;

    gc_values.foreground = BlackPixel(display, DefaultScreen(display));
    gc = XCreateGC(display, window, GCForeground, &gc_values);

    int width, height;
    XWindowAttributes attr;
    XGetWindowAttributes(display, window, &attr);
    width = attr.width;
    height = attr.height;

    // Draw a horizontal line in the middle
    XDrawLine(display, window, gc, 0, height / 2, width, height / 2);

    // Draw a vertical line in the middle
    XDrawLine(display, window, gc, width / 2, 0, width / 2, height);

    XFreeGC(display, gc);
}

And I call it as:

for (i = 0; i < num_instances; i++) {
draw_perpendicular_lines(display, windows[i]);
}

The code runs successfully with the perpendicular lines but I get the following error after few seconds of running the pipeline:

deepstream-app: ../../src/hb-object-private.hh:154: Type* hb_object_reference(Type*) [with Type = hb_unicode_funcs_t]: Assertionhb_object_is_valid (obj)' failed.`

Is there a better implementation of drawing the lines, and if no, what should I edit in m code to run probably?

marcoslucianops commented 10 months ago

You need to draw the line using the display_meta. Check about the nvds_add_display_meta_to_frame function in the NVIDIA forums.

emad555 commented 10 months ago

You need to draw the line using the display_meta. Check about the nvds_add_display_meta_to_frame function in the NVIDIA forums.

Can you show this in example?

marcoslucianops commented 10 months ago

https://github.com/marcoslucianops/DeepStream-Yolo-Pose/blob/master/deepstream.c#L77C1-L139C4