OCR Recognize File
OCR Recognize File
Section titled “OCR Recognize File”Type: ocr-recognize · Package: OCR Activities v1.2.5 · Output: string
Recognizes and returns all the text of an image file (.png, .jpg, .bmp, .tiff). It is the core activity of the package: read the content of an image or a scanned document and then extract data with expressions.
How it works
Section titled “How it works”Runs the image through the Tesseract engine and returns the recognized text, in the reading order detected by the engine (line breaks between lines and blank lines between blocks). Set the text’s language to improve accuracy, and use preprocess to clean up low-quality images. See language and preprocessing.
Recognition runs on the robot’s machine and takes longer the larger the image is; the original file is not changed.
Required parameters
Section titled “Required parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
path | string | — | Path to the image file (.png, .jpg, .bmp, .tiff). |
Optional parameters
Section titled “Optional parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
language | string | "eng" | Text language: Tesseract code (eng, spa, eng+spa) or regional tag (es-CO, en-US). |
preprocess | string | "none" | Prior cleanup: none · auto · deskew · binarize. Since 1.2.0. |
Output
Section titled “Output”Returns a string with the recognized text. If the image has no readable text, it returns an empty or almost empty string (only line breaks); check it with isEmpty(trim(text)) or by validating the data you look for.
Example
Section titled “Example”Read a scanned invoice in Spanish and extract the total:
OCR Recognize File path = scanPath language = "spa" preprocess = "auto" → output: textSet Variable name = total value = regexFind(text, "(?<=Total:\s*\$?)[\d.,]+")Log message = "Total read: " + totalCommon errors
Section titled “Common errors”| Message | Cause and fix |
|---|---|
File not found. | The path does not exist on the robot’s machine. |
'path' is required. | path is missing or the expression returned nothing. |
Tesseract language '…' not found at '…'. Available: [eng, spa]. | The language code is not installed. Use one of the available ones. |
Could not read the image. | With preprocess, the file is not a valid image or is damaged. |
OpenCV native init failed: … | A native preprocessing component is missing on the machine. Reinstall the package or use preprocess = "none". |
Related activities
Section titled “Related activities”- OCR Extract Pattern — extract specific fields with regex in one step.
- OCR Find Text — locate where a text is.
- PDF Get Text — for PDFs with text (no OCR).