Draw Rectangle
This function block overlays one or more rectangles on an input image based on provided rectangle coordinates. Each rectangle can be colored to indicate a status (e.g., OK vs NOK). Use it to visualize detection results, highlight regions of interest, or annotate images before saving or display.
π₯ Inputs
Image Any - Source image that will be annotated.
Rectangle - Single rectangle or a list of rectangles. Accepts coordinates in pair format ((y0, x0), (y1, x1)) or equivalent bounding-pair form. Multiple rectangles are supported.
Status - Optional boolean or list of booleans to control rectangle color. When provided, TRUE draws a green rectangle and FALSE draws a red rectangle. If multiple rectangles are provided, supply a matching list of statuses to color individually.
π€ Outputs
Image Any - The annotated image with rectangles drawn on a copy of the input image.
πΉοΈ Controls
No Controls - This block has no additional UI widgets. All behavior is controlled via its inputs.
βοΈ How it runs
The block takes the current image and makes a copy to preserve the original.
It reads the provided
Rectangleinput. If a list is provided, each rectangle is processed in order.For each rectangle, the block reads the corresponding
Status(single or list). A TRUE status results in a green rectangle; FALSE results in a red rectangle.Rectangles are drawn with a visible border thickness so they are easy to spot on the result image.
The resulting annotated image is returned via the
Image Anyoutput.
β¨ Features
Supports single or multiple rectangle inputs.
Optional per-rectangle status coloring (green for TRUE, red for FALSE).
Works on any image format accepted by the system.
Non-destructive: original image is preserved; annotations are applied to a copy.
π Usage suggestions
Provide rectangle coordinates as bounding pairs ((y0, x0), (y1, x1)) for correct placement.
When drawing multiple rectangles, supply a list of matching statuses to color each rectangle independently.
Combine with preview and export blocks to review and save annotated images.
π‘ Tips and Tricks
Combine with
Find ObjectorObject Detectionto draw detection boxes returned by those blocks and visualize detected items.Use
Rectangles in Rectangleto filter or validate rectangles before drawing (for example, ignore boxes outside a region of interest).Crop the image first with
Image ROI SelectorImage ROIto reduce clutter and focus annotations on a specific area.After annotating, preview the result with
Show Imageand save usingImage WriteorImage Logger.If you need side-by-side comparisons (original vs annotated), use
Image ConcatenateorCollage Images.If coordinates come from other logic or data operations, use
Parse Data Dictionary,Get Element, orReplace Noneto prepare inputs robustly.
π οΈ Troubleshooting
Incorrect coordinate format or ordering may place rectangles in unexpected positions. Verify coordinates are provided as top-left and bottom-right pairs.
If rectangles are not visible, check image resolution and rectangle coordinates with
Image Resolution and Channel ValueorGet Dimension.For multiple rectangles, ensure the
Statuslist length matches the number of rectangles to avoid mismatched coloring.If you want text overlays alongside rectangles, use
Draw Result On Imageafter this block to place condition text near drawn boxes.
Last updated
Was this helpful?