FlexiLayout block types
ABBYY FlexiLayout™ Studio supports the following block types:- Text (marked with
icon) is used to extract text data.
Expanding the regions of text blocks can improve recognition quality. To expand a region, double-click the Blocks element to open its Properties dialog box and specify the vertical and horizontal values for the Blocks result region inflate property. - Barcode (marked with
icon) is used to read barcodes. - Checkmark (marked with
icon) is used to recognize checkmarks. - Picture (marked with
icon) is used to process objects that were not identified as text during pre-recognition. - Table (marked with
icon) is used to extract data from tables. - Group (marked with
icon) is used to logically group blocks. - Checkmark Group (marked with
icon) is used to create checkmark groups. Only checkmark blocks can be added to this type of group. You cannot create or move blocks of other types here. - Repeating Group (marked with
icon) is used to create a repeating group of blocks. - Non-Recognized (marked with
icon) is used to exclude an area from recognition.
Data from the blocks are extracted in a data capture application such as ABBYY FlexiCapture.
Block properties
- Name — The name of the block. The name of a block can contain letters (Roman characters, Roman characters with diacritics, Cyrillic characters), digits, and underscores. The name of a block must start with a letter or an underscore. Block names must not contain blank spaces or special symbols.
- Type — The type of the block (selected upon creation). The type of the block must correspond to the type of object(s) located in the area enclosed by the block.
- Comment — A comment provided by the user (optional).
- Has repeating instances — Shows that the block consists of several instances. Select this property if, for example, all the instances of a Repeating Group element are used as the block region.
- Instance sort order — Sets the order in which group instances are united into a block. This property is only available if Has repeating instances is selected. Possible values:
- Top to bottom — The instances are united into a block according to their location on the image, top to bottom.
- Left to right — The instances are united into a block according to their location on the image, left to right.
- Right to left — The instances are united into a block according to their location on the image, right to left.
- In order of finding — The instances are united into a block in the order in which hypotheses are generated. Hypotheses are generated in the order of decreasing quality. If the user specified additional conditions for instances, hypotheses are generated in the user-defined order. Thus, if you need an order different from the standard order used by the program, you can specify the order by means of additional conditions.
- For Layout — Selects the layout alternative where the search area is specified.
- Source element — Specifies an area on the image that is identical to the region of the element used to find the block on the image. When the FlexiLayout is applied to the image, the program searches for the object (or objects) described by the element. The data is captured from these objects. For a repeating group, you can select either one of the instances or use all the instances (AllInstances). For more information, see Using instances of a Repeating Group as reference, excluded or source elements.
- Expression — Sets an area on the image that does not coincide with any of the element regions. For example, you can merge the regions of some elements and the space among them into one block, expand the region of an element by a certain value, or specify the coordinates of the block without relying on any elements. In this case, the region of the block can be described in the FlexiLayout language.
The region of a block is continuous. This means that if you create a region from rectangles that stand apart, the spaces between them are filled by thin additional rectangles to make the region continuous.
Parameters of group and repeating group blocks
A checkmark group and a common group of blocks have no parameters other than name and comment. The parameters of a repeating group of blocks are the same as those of non-group blocks. The Has repeating instances option is always enabled for them. Child blocks can either have the Has repeating instances option or not, but an Output instances variable is always created for them. If a block inside a repeating group of blocks has the Has repeating instances option, this means that it can repeat inside each instance of the parent block.Specify a block region using instances of a repeating group
If a block is defined using several instances, the block region consists of several separate regions. If you use a particular instance of a repeating group (for example, LastFound), the block region is defined just like for any other element. However, you can use all the detected instances (AllInstances). To use multiple instances, select the Has repeating instances option. You can also write code for the block using the predefined OutputInstances variable. For example:- For non-table blocks, the specified instances are the instances of the corresponding field.
- For a table block, the specified instances are treated as one instance of the field. That is, ABBYY FlexiCapture processes such a block as a field of type Table with a discontinuous region.
Rules for creating references to elements for repeating groups of blocks
A repeating group of blocks refers to a repeating element. To create instances of a repeating group of blocks, you need several element instances. Therefore, one of the Ids must be AllInstances. Since the elements nested under the element with AllInstances cannot have other Ids, this condition also means that the lowermost repeating element has AllInstances. Child blocks of a repeating group of blocks refer to child elements of the repeating group of elements to which the parent block refers. The reference must have the same Id for instances. Example: If a repeating group block has the following reference: SearchElements..RepGr1.Instance(1).RepGr2.AllInstances, its child blocks can refer to the element RepGr1..RepGr2.Element only as follows:If references are created via Source element, the check is performed when the FlexiLayout is built. If references are created using Advanced code, an error is detected when matching the FlexiLayout.
Describe a block region with the FlexiLayout language
To specify the region of a block, use the Expression field. Depending on the type of the block and whether the Has repeating instances option is selected for it, one of the following predefined variables is used: OutputRegion (of type Region), OutputTable (of type TableHypothesis), and OutputInstances (of type HypothesisInstances or TableHypothesisInstances). For more information about the predefined variables that can be used in the Expression field, see Predefined variables.| Task | Example code |
|---|---|
| Getting and expanding the region of an element by 3mm in width and by 5mm in length | OutputRegion = SomeElement.Rect; OutputRegion.Inflate( 3*mm, 5*mm ); |
| Merging the region rectangles of two elements and getting the rectangle which circumscribes the merged rectangles | Rect outputRect; outputRect = Element1.Rect Or Element2.Rect; OutputRegion = outputRect; |
| Merging the rectangles circumscribing the regions of two elements into one region | RectArray outputRects; outputRects = RectArray( Element1.Rect ); outputRects.Add: Element2.Rect; OutputRegion = Region( outputRects ); |
| Merging the regions of the objects corresponding to two different elements into one region | RectArray outputRects; outputRects = Element1.Rects; outputRects.Add( Element2.Rects ); OutputRegion = outputRects.Region; |
| Merging the regions of the objects which belong to the region of Element1 and removing the regions of the objects which belong to the region of Element2 | OutputRegion = FormRegion( Element1.Rects, Element2.Rects ); |
| Using a Table element to specify a Table block | OutputTable = SearchElements.TableElement; |
| Using instances of hypotheses for a certain element to specify a Table block | OutputInstances = SearchElements.RepeatingGroup.AllInstances.TemplateElement; |
Use the IsNull variable
You can also use a predefinedIsNull variable to describe the region of a block. This variable signals whether the region of the block has been found when matching the FlexiLayout. The value false means the region has been found. The value true means it has not been found.
The IsNull variable is initialized with the value false, so the region of the block is considered to be found. However, sometimes you might need to check certain conditions before reaching a conclusion.
-
To tell the program to consider the region of the block found if the width of the region of the source element exceeds 50 dots, enter the following code in the Region Expression field:
-
To tell the program to consider the region of the block found only if Element1 has been found, enter the following code in the Region Expression field:
-
Suppose you need to use Element1 and Element2 to look for a block. If at least one of the elements has not been found, the block is considered not found.
This code will work correctly only if the search area of Element1 is above and to the left of the search area of Element2. In the preceding example, checking this condition is not included for the sake of simplicity. In actual code, this check is required and the values of the FieldLeft, FieldRight, FieldTop, and FieldBottom variables must be adjusted. Otherwise, calling the Rect function will return an error.
