Write Text On Image

This function block adds customizable text overlays onto images. It scales text relative to image size, lets you position the text using normalized coordinates, and optionally draws a semi-transparent background behind the text for better readability.

πŸ“₯ Inputs

Image Any Accepts the image to draw text on.

String Optional text input. If left empty the block will draw an empty string (no visible text).

πŸ“€ Outputs

Image Any The image with the applied text overlay.

πŸ•ΉοΈ Controls

Text Position Horizontal Move text left/right using a normalized value (0.0 = left, 1.0 = right).

Text Position Vertical Move text up/down using a normalized value (0.0 = top, 1.0 = bottom).

Font Scale Adjust overall text size relative to the image.

Font Thickness Adjust the stroke thickness of the text.

Font Choose the font style from available options.

Color Select the text color.

Background Enabled Toggle a semi-transparent background rectangle behind the text for improved contrast.

🎨 Features

  • Automatic scaling so text size adapts to image dimensions for consistent appearance across different resolutions.

  • Normalized positioning makes it easy to place text proportionally, independent of image size.

  • Semi-transparent background option improves legibility on busy images.

  • Works with dynamic text inputs so overlays can display variable content (e.g., IDs, labels, sensor readings).

πŸ“Š How it runs

When the block runs it reads the incoming image and the current control values, computes an appropriate font scale and position based on the image dimensions, draws the optional background rectangle (if enabled), renders the text with the selected font, color and thickness, and outputs the resulting image for downstream blocks.

πŸ“ Usage instructions

  1. Connect a source that provides the image to Image Any.

  2. Provide text to the String input or leave it empty to use the block’s internal text.

  3. Adjust Font, Color, Font Scale and Font Thickness for desired appearance.

  4. Use Text Position Horizontal and Text Position Vertical to place the text.

  5. Enable Background Enabled if you need higher contrast on complex images.

  6. Preview the output by connecting this block to a display block such as Show Image or save the result with Image Write / Image Logger.

πŸ’‘ Tips and Tricks

  • To stamp a running timestamp, feed the String input from the Date-Time or Date-Time List block and combine formatting in a String Merge block before feeding it in.

  • For live preview while tuning position and scale, connect the output to the Show Image block.

  • If you need to write labels only within a specific area, crop first with Image ROI or Image ROI Select and then apply this block.

  • Use Image Resize before writing text if you want consistent final text size across images that vary widely in resolution.

  • To save annotated frames, connect the output to Image Logger or Image Write.

  • To overlay detection results, combine with detection blocks like Find Object or Object Detection and feed detected labels or counts into the String input.

  • When drawing conditional status text (e.g., OK / NOK), use logical blocks (for example Logic Input or comparison blocks) and a String Merge to assemble the display text before sending it to this block.

πŸ› οΈ Troubleshooting

  • Text appears too small or too large: adjust Font Scale or resize the input image with Image Resize for consistent results.

  • Text is unreadable on busy backgrounds: enable Background Enabled or change Color to a high-contrast value.

  • Text position seems off on different images: use normalized Text Position Horizontal and Text Position Vertical and verify placement on a representative image using Show Image.

Last updated