# Draw Rectangle

This function block draws one or multiple rectangles on an input image. Each rectangle can be drawn in green or red depending on an optional status input. It is useful for visualizing detection results, highlighting regions of interest, or annotating images for inspection and logging.

## 📥 Inputs <a href="#inputs" id="inputs"></a>

`Image Any` Source image where rectangles will be drawn (required).

`Rectangle` One rectangle or a list of rectangles. Each rectangle is defined by top-left and bottom-right points in ((x0, y0), (x1, y1)) format (required). Multiple rectangles are supported.

`Status` Optional boolean or list of booleans. `True` draws green, `False` draws red. If omitted, rectangles are drawn as green by default. When multiple rectangles are provided, you may supply a matching list of status values.

## 📤 Outputs <a href="#outputs" id="outputs"></a>

`Image Any` The source image with rectangles drawn on a copy (original image is not modified).

## 🕹️ Controls <a href="#controls" id="controls"></a>

This function block has no interactive widgets; behavior is driven entirely by the input sockets.

## 🎨 Features <a href="#features" id="features"></a>

* Draws single or multiple rectangles with clear green/ red color coding for status.
* Accepts either a single rectangle or a list of rectangles.
* Accepts either a single status or a list of statuses; when absent, status defaults to True (green).
* Outputs a copy of the input image annotated with the rectangles so upstream images remain unchanged.
* Uses a visible line thickness suitable for inspection on typical image sizes.

## 📝 Usage Instructions <a href="#usage" id="usage"></a>

1. Provide an image to `Image Any` input.
2. Provide a rectangle or a list of rectangles to `Rectangle` input in ((x0, y0), (x1, y1)) format.
3. Optionally provide a boolean or list of booleans to `Status` input to control rectangle colors.
4. Read the annotated image from the `Image Any` output and connect it to viewers, loggers, or further processing blocks.

## 📊 Evaluation <a href="#evaluation" id="evaluation"></a>

When executed, the block copies the incoming image, draws each provided rectangle in green for `True` and red for `False` (default is green), and returns the annotated image. Single inputs return a single annotated image; lists of rectangles return the same behavior applied to each rectangle.

## 💡 Tips and Tricks <a href="#tips-and-tricks" id="tips-and-tricks"></a>

* To visualize detection results: feed bounding boxes from `Find Object` or `Object Detection` into the `Rectangle` input and optionally color by condition using `Status`.
* For tracked objects, connect tracker outputs from `Object_Detection_Tracker` to draw persistent rectangles with IDs and statuses.
* Pre-filter regions using `Image ROI Select` before drawing to limit annotations to a crop area.
* Combine with `Rectangles in Rectangle` to filter unwanted detections and only draw rectangles that fall inside a reference area.
* Use `Draw Detections` or `Draw Result On Image` if you need textual labels or structured detection overlays in addition to rectangles.
* Send the annotated image to `Show Image` for quick inspection or to `Image Logger` / `Image Write` to save annotated frames for audits and reports.

## 🛠️ Troubleshooting <a href="#troubleshooting" id="troubleshooting"></a>

* Rectangles not visible: verify coordinate order and that coordinates are within image bounds ((x0, y0), (x1, y1)).
* Unexpected colors: ensure the `Status` input matches the number of rectangles or provide a single boolean to apply to all.
* Overlapping annotations look cluttered: try drawing on a cropped region or use fewer, larger rectangles produced by preprocessing such as `Find Object` with area filtering.
* If you need labels or counts alongside rectangles, add `Write Text On Image` or `Draw Result On Image` downstream.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.augelab.com/function-blocks/detections-shapes/draw/draw-rectangle.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
