How to overlay text from right to left with nvosd

Hi,
I make a gstreamer plugin with nvosd lib to overlay text on the video. It works well when display text from left to right. What I want to know is how I can display the text from right to left. Would there are some way I can calculate the pixel width of the string (according to the font name & font size) and then set text_params.x_offset = video_width - str_pixel_len ?
I have tried gs -dQUIET -sDEVICE=nullpage 2>/dev/null - <<<'30 /Sans findfont exch scalefont setfont (hello) stringwidth pop ==', but the length mismatch with actual display.
Any help to correct this would be appreciated.

Hi,
Please share more information. Do you use DeepStream SDK in your use-case? And the request is to display HELLO like OLLEH on OSD?

Hi,

  1. Do you use DeepStream SDK in your use-case?
    No. I just link libnvosd.so and use int nvosd_put_text(void *nvosd_ctx, NvOSD_Mode mode, int fd, int num_strings, NvOSD_TextParams *text_params_list); API. In fact, I use the jetson multimedia api.
  2. The request is to display HELLO like OLLEH on OSD?
    No. nvosd_put_text provides text_params_list and x_offset holds horizontal offset w.r.t top left pixel of the frame. While I want to hold horizontal offset top right pixel of the frame. For example, I would like to overlay HELLO on the top right of the video frame. However, I donnot know the actual pixel length of the string with known font name and font size.
    Would there are some ways I can calculate the pixel width of the string (according to the font name & font size) and then set text_params.x_offset = video_width - str_pixel_len ?
    Thanks.

Hi,
This is not a use-case considered in implementing nvosd, so you would need to trial and error. To find out a proper setting.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.