Skip to content

OCR Activities

Version: 1.2.5  ·  ID: zoan-packages-ocr  ·  Author: Zoan Software

The OCR package (Optical Character Recognition) reads the text that appears inside an image: a scanned document, a photo of a document, a screenshot. It complements the PDF package: when a document is an image (it has no selectable text), the PDF activities cannot read it — but OCR can.

It uses the Tesseract 5 engine in LSTM mode, a widely used open-source text recognizer, with OpenCV-based image preprocessing. Spanish and English come bundled with the package: there is nothing else to install. Recognition runs on the robot’s machine (images are not sent anywhere) and the package works on Windows robots.

The activities that read files accept .png, .jpg, .bmp and .tiff images. For a scanned PDF, first convert its pages to images with PDF to Images and pass each image to OCR.

Almost every activity accepts a language parameter with the code of the language to recognize:

ValueLanguage
engEnglish (default)
spaSpanish
eng+spaSeveral languages at once

It also accepts regional tags such as es-CO or en-US, which are mapped to the Tesseract code (es → spa, en → eng; also pt, fr, de, it and ca). An unrecognized tag is treated as English. A code that is not installed raises the error Tesseract language '…' not found, with the list of available ones.

Setting the right language greatly improves accuracy (accents, ñ, etc.). For Spanish text, always use language = "spa". To see which languages are available, use OCR Get Available Languages.

The preprocess parameter cleans up the image before recognizing it, which improves results on poor-quality scans. It is available in OCR Recognize File and the three structured-extraction activities:

ValueWhat it does
noneNo preprocessing (default, except in OCR Extract Table, which uses auto)
autoFull cleanup: grayscale, noise removal, binarization and deskew
deskewOnly straightens a skewed image (rotates it if the skew exceeds about 0.3°)
binarizeConverts to black and white with an adaptive threshold (improves contrast)

The original image is not changed: the cleanup happens in memory.

The activities that return positions (OCR Find Text, OCR Get Lines) use pixels with the origin at the top-left corner of the analyzed image: the file’s, or on screen, the captured region’s. To get screen coordinates, add the region’s x/y.

ActivityTypeOutputWhat it does
OCR Recognize Fileocr-recognizestringReads the text of an image file
OCR Recognize Screen Regionocr-recognize-regionstringReads the text of a screen area
OCR Screenshotocr-screenshotstringReads all the text of a screen
ActivityTypeOutputWhat it does
OCR Find Textocr-find-textobjectFinds the position of a text
OCR Get Linesocr-get-linesList<object>Structured list of lines and words with coordinates
ActivityTypeOutputWhat it does
OCR Extract Patternocr-extract-patternDictionary<string, string>Extracts fields with regular expressions
OCR Extract Form Fieldsocr-extract-formDictionary<string, string>Extracts text from named regions
OCR Extract Tableocr-extract-tableDataTableExtracts a table from an image into a DataTable
ActivityTypeOutputWhat it does
OCR Get Available Languagesocr-get-languagesList<string>Available languages

Read a scanned invoice and extract its number:

OCR Recognize File path = imagePath language = "spa" preprocess = "auto" → output: text
Set Variable name = number value = regexFind(text, "INV-\d+")