# Text Detection

This function block finds text regions in an image and visualizes them. It is tuned for detecting oriented text areas (rotated or tilted) and returns both a preview image and structured location data for further processing.

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

`Image Any` Input image to be analyzed for text.

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

`Image Any` Annotated image with detected text regions drawn.

`Referance Point` List of reference points (corner points) for each detected text region.

`Referance Rectangles` List of bounding rectangles for each detected text region.

`Number of Detected Text` Total number of text regions found.

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

`Confidence` Adjusts the minimum confidence required for a detection to be accepted. Higher values reduce false positives but may miss faint text.

`NMS Threshold` Adjusts how overlapping detections are merged. Lower values make merging stricter, reducing duplicate boxes over the same text.

## ⚙️ Running mechanism <a href="#running-mechanism" id="running-mechanism"></a>

When executed, the block examines the provided image, searches for regions that look like text, filters results by confidence, merges overlapping detections, and scales found regions back to the input image size. The block then outputs an annotated preview image, a list of reference points and rectangles for each detection, and the total count of detected text regions.

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

* Detects rotated and angled text regions, not just horizontal lines.
* Provides both visual feedback (annotated image) and structured outputs (points, rectangles, count) for downstream processing.
* Adjustable sensitivity via `Confidence` and `NMS Threshold` controls to tune precision vs recall.

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

1. Provide an image to the `Image Any` input (from a camera, file loader or stream).
2. Adjust the `Confidence` slider to balance false positives vs missed text.
3. Adjust the `NMS Threshold` slider if multiple overlapping boxes appear over the same text area.
4. Use the annotated `Image Any` output to preview detections, and use `Referance Point` / `Referance Rectangles` for extraction, cropping, or passing to recognition blocks.

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

* If the image is very large, use `Image Resizer` to downscale for faster processing, then map rectangle coordinates back to the original if needed.
* For actual text recognition after detection, connect the detected crop areas to `OCR` or `OCR (EasyOCR)` blocks.
* To focus on a specific area, crop first with `Image ROI` or `Image ROI Select` and feed the cropped image into this block.
* Use `Show Image` to preview the annotated output, and `Draw Result On Image` to overlay custom status text based on detection results.
* Save results with `Image Write` or log examples with `Image Logger` for later review.

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

* No detections: Lower the `Confidence` value or provide a clearer.
* Too many small boxes or duplicates: Increase the `Confidence` value and lower the `NMS Threshold` to merge overlapping detections.
* Detections misplaced after resizing: Ensure any resizing steps are compensated when interpreting `Referance Rectangles` coordinates.
* If you only need recognized text (not locations), chain this block to `OCR` / `OCR (EasyOCR)` and use the count output to gate downstream logic.


---

# 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/ai-blocks/text-detection.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.
