OCR - Get line(s)

Declaration

<AMOCR ACTIVITY="get_lines" OCRENGINE="text (options)" PAGESEGMODE="text (options)" IMAGE="text" TOP="number" LEFT="number" WIDTH="number" HEIGHT="number" FILTER="text" MATCHCASE="YES/NO" RESULTDATASET="text" PAGE="number" ALLPAGE="YES/NO" ENGLISH="YES/NO" TURKISH="YES/NO" SPANISH="YES/NO" PORTUGUESE="YES/NO" FRENCH="YES/NO" RUSSIAN="YES/NO" DUTCH="YES/NO" GERMAN="YES/NO" ITALIAN="YES/NO" ICR="YES/NO" INVERT="YES/NO"    />

Related Topics   

Description

Retrieves one or more lines of text from an image or PDF file and then creates and populates a dataset with the results.

Practical Usage

Can be used along with the OCR - Get word(s), Image - Capture screen, and Input - Move mouse activities to find the X, Y position of one or more lines of text inside an object (for example, button or control) in a non-Windows API-type window (for example, Java Window) to automate moving your mouse to the correct location.

Parameters

General

Property Type Required Default Markup Description
OCR Engine Text (options) Yes Tesseract
  • OCRENGINE="tesseract"
  • OCRENGINE="legacy"
Specifies the OCR engine to use to retrieve one or more lines of text from an image or PDF file. The available options are:
  • Tesseract (default) - Images or PDF files are scanned using the Tesseract OCR engine, providing better accuracy than the Legacy option.
  • Legacy - Images or PDF files are scanned using the legacy OCR engine. This engine provides backwards compatibility with Automate versions 11.4.0 or earlier.
Page Segmentation Mode Text (options) Yes, if the OCR Engine parameter is set to Tesseract Single Block
  • PAGESEGMODE="auto_osd"
  • PAGESEGMODE="single_column"
  • PAGESEGMODE="sngle_block_vert_text"
  • PAGESEGMODE="single_block"
  • PAGESEGMODE="single_line"
  • PAGESEGMODE="single_word"
  • PAGESEGMODE="circle_word"
  • PAGESEGMODE="single_char"
  • PAGESEGMODE="sparse_text"
  • PAGESEGMODE="sparse_text_osd"
  • PAGESEGMODE="raw_line"
Specifies the page segmentation mode to use to scan the image or PDF file in a specific way. Select the option that best suits the image for a more accurate scan, based on the position of the lines of text to retrieve. This parameter is only available and required if the OCR Engine parameter is set to Tesseract. The available options are:
  • Auto Osd - Provides automatic page segmentation with orientation and script detection (OSD).
  • Single Column - Assumes the lines of text in the image or PDF file are in a single column of text, varying in size.
  • Single Block Vertical Text - Assumes the lines of text in the image or PDF file are in a single uniform block of vertically aligned text.
  • Single Block (default) - Assumes the lines of text in the image or PDF file are in a single uniform block of text.
  • Single Line - Assumes the image or PDF only contains a single line of text.
  • Single Word - Assumes the image or PDF file only contains a single word.
  • Circle Word - Assumes the image or PDF file only contains a single word contained within a circle.
  • Single Char - Assumes the image or PDF file only contains a single character.
  • Sparse Text - Scans the entire image to retrieve as much text as possible in no particular order.
  • Sparse Text Osd - Scans the entire image to retrieve as much text as possible using orientation and script detection (OSD).
  • Raw Line - Assumes the image only contains a single line of text, bypassing hacks that are Tesseract-specific.
Image Text Yes (Empty) IMAGE="C:\temp\Image.jpg" Specifies the path and file name of the image or PDF file to use with this activity. Supported image formats are JPG, PNG, TIFF, GIF, and BMP.
NOTE: Although a variety of formats are supported, image data with lossless compression such as TIFF are recommended.  
Entire image/page --- --- --- --- If selected (default), this activity searches the entire image/page in the file for lines of text.
NOTE: This parameter does not contain markup and is only displayed in visual mode for task construction and configuration purposes.
Specified region (improves accuracy) --- --- --- --- If selected, this activity only searches a specified region of the image or PDF file for lines of text. Click Pick Region to open a dialog box that allows you to select an image region. Depending on the OCR Engine parameter's current setting, see Pick Region Dialog Box (Tesseract OCR Engine) or Pick Region Dialog Box (Legacy OCR Engine) for more details. 
NOTE:
  • This parameter resets if the OCR Engine parameter is switched to a different engine.
  • This parameter does not contain markup and is only displayed in visual mode for task construction and configuration purposes.
Top Number Yes, if Specified region is selected (Empty) TOP="223" The top most pixel coordinate of the specified region in the image or PDF file. This parameter is only available if the Specified region parameter is selected.
Left Number Yes, if Specified region is selected (Empty) LEFT="115" The left most pixel coordinate of the specified region in the image or PDF file. This parameter is only available if the Specified region parameter is selected.
Width Number Yes, if Specified region is selected (Empty) WIDTH="647" The total pixel width of the specified region in the image or PDF file. This parameter is only available if the Specified region parameter is selected.
Height Number Yes, if Specified region is selected (Empty) HEIGHT="647" The total pixel height of the specified region in the image or PDF file. This parameter is only available if the Specified region parameter is selected.
Filter (optional) Text No (Empty) FILTER="text" Applies a filter that only populates the dataset with information regarding the text specified in this parameter. If the text appears multiple times in the image, each instance will be recorded.
Match case Yes/No No No MATCHCASE="YES" If selected, the Filter parameter is case sensitive. This parameter is disabled by default.
Create and populate dataset with word(s) information Text Yes (Empty) RESULTVARIABLE="theText" The name of the dataset to create and populate with information about the retrieved lines of text. See Datasets below for more details.

Advanced

Property Type Required Default Markup Description
Page range: All Yes/No No Yes ALLPAGE="YES" If selected (default), lines of text are retrieved from all pages in a range, and the Pages parameter is disabled.
NOTE: Only GIF images support multiple pages.
Page range: Page(s) Number No No
  • PAGE="1-3"
  • PAGE="2,4,6"
  • PAGE="3"
If selected, lines of text are retrieved from specific pages in a range, and the All parameter is disabled. This parameter is disabled by default. Supports specification of a single page, specific pages, or a sequence of pages in a range (see the Markup column for examples).
NOTE: Only GIF images support multiple pages.
Languages Yes/No No English
  • DUTCH="YES"
  • ENGLISH="NO"
  • FRENCH="YES"
  • GERMAN="YES"
  • HEBREW="YES"
  • ITALIAN="YES"
  • JAPANESE="YES"
  • PORTUGUESE="YES"
  • RUSSIAN="YES"
  • SPANISH="YES"
  • TURKISH="YES"
Specifies which languages are found in the image file selected for the Image parameter. The available languages are:
  • Dutch
  • English
  • French
  • German
  • Hebrew
  • Italian
  • Japanese
  • Portuguese
  • Russian
  • Spanish
  • Turkish
NOTE: This parameter resets if the OCR Engine parameter is switched to a different engine.
Use ICR (digits only)

Yes/No

No No ICR="YES" If selected, ICR (Intelligent Character Recognition), a more advanced handwriting recognition system, is used to recognize numbers or digits. This parameter is disabled by default. This parameter is only available if the OCR Engine parameter is set to Legacy.
Invert image colors Yes/No No No INVERT="YES" If selected, image colors are transformed from light to dark and dark to light. If this activity has trouble recognizing lines of text, inverting can add more contrast to the text and assist in more accurate results. This parameter is only available if the OCR Engine parameter is set to Legacy.

Description

Error Causes

On Error

Additional Notes

Datasets

A dataset is a multiple column, multiple row container object. This activity creates and populates a dataset containing a specific set of fields. The table below describes these fields (assuming the dataset name assigned was theDataset).

Name Type Return Value
theDataset.PageIndex Number Returns the page index.
theDataset.LineIndex Number Returns the line index.
theDataset.Text Text Returns the retrieved text.
theDataset.Top Number Returns the top most pixel coordinate of the specified region in the image or PDF file.
theDataset.Left Number Returns the left most pixel coordinate of the specified region in the image or PDF file.
theDataset.Width Number Returns the total pixel width of the specified region in the image or PDF file.
theDataset.Height Number Returns the total pixel height of the specified region in the image or PDF file.

Example

NOTE:
  • The sample AML code below can be copied and pasted directly into the Steps Panel of the Task Builder.
  • Parameters containing user credentials, files, file paths, and/or other information specific to the task must be customized before the sample code can run successfully.

Description

This sample task retrieves English and Spanish lines of text from an image and then creates and populates a dataset with the results.

Copy
<AMOCR ACTIVITY="get_lines" SPANISH="YES" ALLPAGE="YES" IMAGE="C:\temp\document_scan.png" OCRENGINE="tesseract" RESULTDATASET="Results" />