# OCR (EasyOCR)

This function block detects and extracts text from images using an OCR engine. It is designed for easy integration: provide an image, adjust a confidence threshold, and optionally allow automatic rotation to improve recognition of rotated text.

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

* `Image` Grayscale or color image that contains the text to be recognized.

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

* `Result` Image annotated with detected boxes and optional text labels (if visualization is enabled downstream).
* `Whole Text` Full recognized text as a single string (words joined).
* `Texts` Individual recognized text segments as a list.
* `Boxes` Bounding polygons (4 points) for each detected text area.

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

* `Auto Rotation` Toggle to try rotated versions of the input image when looking for text. Useful when text may appear rotated (e.g., phones, tilted signs).
* `Show Texts` Toggle to include recognized text labels on the annotated image output (when output visualization is active).
* `Threshold` Slider to set minimum confidence required for a detection to be accepted. Higher values reduce false positives but may miss faint text.

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

* Multi-angle recognition when `Auto Rotation` is enabled to improve detection on rotated text.
* Confidence-based filtering via `Threshold` to control detection strictness.
* Returns both textual results and exact bounding polygons for each detection, enabling downstream processing or logging.
* Will use available hardware acceleration when present to improve performance.

## 📊 How it runs <a href="#evaluation" id="evaluation"></a>

When an image is provided to `Image`, the block analyzes the image for text, applying the configured threshold and rotation behavior. Accepted detections are returned as text and bounding boxes. If visualization is connected, an annotated image with detected boxes (and optional labels) is produced on the `Result` output.

## 📝 Quick start <a href="#usage" id="usage"></a>

1. Connect an image-producing block (for example a camera or an image loader) to `Image`.
2. Toggle `Auto Rotation` if the text may be rotated.
3. Adjust `Threshold` to balance between sensitivity and false positives.
4. Use the `Boxes` output to draw or log detections, or connect the `Result` image to a display block to preview.

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

* Preprocess small or noisy text with `Image Resizer` or `Super Resolution` to improve readability before OCR.
* Crop to the region of interest using `Image ROI Select` or `Image ROI` so OCR only processes relevant areas (faster and more accurate).
* Improve contrast and reduce noise with `Contrast Optimization`, `Denoising`, or `Adjust Colors` before feeding the image.
* Remove distracting backgrounds with `Background Removal (RMBG-1.4)` or `Background Removal (BiRefNet)` when text overlays complex scenes.
* For quick visual checks, connect the annotated `Result` to `Show Image` to inspect box placement and text labels.
* To compare recognition quality or fallback strategies, try the alternative `OCR` block and compare results.
* Save recognized text and logs using `CSV Export` or assemble structured logs with `Data to JSON` for downstream systems.
* If many false positives appear, increase `Threshold` or apply targeted masking using `Apply Mask` to exclude irrelevant regions.

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

* No text detected: increase image size with `Image Resizer` or improve clarity with `Denoising` / `Contrast Optimization`.
* Low confidence detections: raise the `Threshold` slider and/or clean the background with background removal blocks.
* Text appears rotated or upside-down: enable `Auto Rotation`. If only one angle is problematic, crop with `Image ROI Select` and rotate externally.
* Many false positives on textured backgrounds: restrict processing area using `Image ROI Select` and use `Apply Mask` to block noisy regions.
* Want structured output: route `Texts` and `Boxes` into `Data to JSON` or `CSV Export` for saving or downstream processing.


---

# 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/ocr-easyocr.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.
