> For the complete documentation index, see [llms.txt](https://docs.augelab.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.augelab.com/function-blocks/blocks-reference/detections-shapes/roi-processing/check-area-polygon.md).

# Check Area (Polygon)

This function block lets you draw a polygon directly on an image and check whether given position coordinates fall inside that polygon. Use it to highlight a region of interest (ROI), count or mark objects inside the area, and export the polygon as a shape for downstream processing.

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

`Input Image (Binary Image)` This is the image on which you draw the polygon and see visual feedback.

`Position Coordinate List` A list of point coordinates (x, y) to test against the drawn polygon. Multiple positions are supported.

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

`Output Image` The image with the polygon area highlighted and detected positions marked.

`Polygon Coordinates` The polygon vertices as a shape that can be used by other blocks.

`Object In Area` Boolean that indicates if any provided positions lie inside the polygon.

`Detected Positions` The list of positions that are found to be inside the polygon.

## 🕹️ Controls (widgets & interactions) <a href="#controls" id="controls"></a>

`Image Canvas` Click on the image to add polygon points. The drawn polygon is displayed over the image in real time.

`U` Press this key to undo the last added point.

`C` Press this key to clear all polygon points and start over.

`Select Area` Use the drawing interaction to create the desired polygon region.

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

* Visual polygon drawing over the input image with persistent preview.
* Immediate visual highlighting of the selected area with a translucent overlay.
* Marking of detected positions inside the polygon with clear visual markers.
* Returns polygon coordinates as a reusable shape for other processing blocks.
* Supports multiple input positions and reports which are inside the drawn area.

## ⚙️ Running mechanism <a href="#how-it-works" id="how-it-works"></a>

* The image provided to the `Input Image (Binary Image)` socket is displayed on the canvas.
* You interactively add polygon vertices by clicking on the canvas. Each click becomes a vertex.
* The drawn polygon is visually highlighted on the image.
* When position coordinates are supplied to the `Position Coordinate List` socket, the block checks each point and marks those inside the polygon.
* Results (highlighted image, polygon coordinates, boolean flag and detected positions) are output so other blocks can consume them.

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

1. Connect an image to `Input Image (Binary Image)` to enable the drawing canvas.
2. Click on the image to add polygon vertices in clockwise or counterclockwise order.
3. Use `U` to undo a point or `C` to clear and redraw the polygon.
4. Feed a list of coordinates to `Position Coordinate List` to check which points are inside the polygon.
5. Use the `Polygon Coordinates` output to pass the drawn area to other blocks for further processing.

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

* To provide the points to test automatically, use `Find Object` or `Object Detection` (or `Object Detection - Custom`) upstream so detected object centers can be fed into the `Position Coordinate List` input.
* Visualize results in a larger window by connecting the `Output Image` to `Show Image` for an expanded preview.
* Save or log the highlighted images by connecting `Output Image` to `Image Logger` or `Image Write`.
* To create multiple ROI areas, combine this block with `Image ROI Polygon Multi` to manage several polygons and pass the selected polygon coordinates further.
* If you want to mark detections with rectangles instead of points, use `Draw Rectangle` or `Draw Point` downstream with the coordinates provided by this block.
* For tracking workflows, feed detections from `Object Detection` into an `Object_Detection_Tracker` and use this block to check entry/exit events inside a polygonal area.

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

* If clicks do not appear, ensure an image is connected to the `Input Image (Binary Image)` socket and the canvas is visible.
* If points are reported outside unexpectedly, verify that coordinate format matches (x, y) and that coordinates are in the same reference frame as the displayed image.
* If the polygon disappears between sessions, redraw it or store the polygon output to a persistent storage block (e.g., use outputs with file or logging blocks) and reapply when needed.
