Blocks
FlexiLayout blocks correspond to fields on the documents from which data must be captured. A block specifies the type of data that the field may contain and the coordinates of the image area where the field is likely to be found.
The blocks branch is marked with in the FlexiLayout tree.
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 which 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
The blocks for which at least in one layout alternative no image area is specified, have an empty square in the top right corner of the icon: . If only one FlexiLayout is selected (via the Select Layout item of the element's shortcut menu, or via the same item in the FlexiLayout section, or via the Select Alternative Layout item of the FlexiLayout's shortcut menu), the program will check for the image area only in this FlexiLayout.
Note.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 may 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 will consist of several instances. Select this property if, for example, all the instances of a Repeating Group element will be used as the block region.
- Instance sort order - sets the order in which group instances must be united into a block. The property is only available if Has repeating instances is selected. Possible values:
- Top to bottom - the instances are united into a block in accordance with their location on the image, top to bottom
- Left to right - the instances are united into a block in accordance with their location on the image, left to right
- Right to left - the instances are united into a block in accordance with 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 desired order by means of additional conditions.
The following properties specify the area on the image from which data must be extracted.
- For Layout selects the layout alternative where the search area is specified.
- Source element - specifies an area on the image which is identical to the region of the element that is used to find the block on the image. When the FlexiLayout is applied to the image, the program will search the object (or objects) described by the element. It is from these objects that the data will be captured. For a repeating group, you can select either one of the instances or use all the instances (AllInstances). For details, see Using instances of a Repeating Group as reference, excluded or source elements.
- Expression - sets an area on the image which 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.
Note.The region of a block is continuous. This means that if you create a region from rectangles which stand apart, the spaces between them will be filled by thin additional rectangles to make the region continuous.
However, a block may consist of multiple regions if all the instances of a repeating group are used as a reference element. The region of a group block is calculated based on the regions of the child blocks, just like the region of hypotheses. The resulting region is slightly expanded for better viewing.
A checkmark group and a common group of blocks have no other parameters than name and comments.
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 may 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 option Has repeating instances, this means that it can repeat inside each instance of the parent block.
Specifying a block region by means of instances of a repeating group
If a block is defined using several instances, the block region will consist of several separate regions. If you use a particular instance of a repeating group (e.g. LastFound), the block regions is defined just like for any other element. However, you can use all the detected instances (AllInstances). To use multiple instances, select the option Has repeating instances.
You can also write code for the block using the predefined OutputInstances variable. For example:
OutputInstances = SearchElements.PageHeader.AllInstances.UnionRect;
ABBYY FlexiCapture processes blocks with the Has repeating instances option enabled as follows:
- for non-tables blocks, the specified instances will be the instances of the corresponding field
- for a table block, the specified instances will be treated as one instance of the field, i.e. ABBYY FlexiCapture will process a block like this 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 at least several element instances. Therefore, one of the Ids must be AllInstances. Since the elements that are located below the element with AllInstances may not 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 may refer to the element RepGr1..RepGr2.Element only as follows:
SearchElements.RepGr1.Instance(1).RepGr2.AllInstances.Element.
If there is no HasRepeatingInstances attribute, you can only refer to subelements of the basic group which have no repeats inside it, and vice versa, if there is a HasRepeatingInstances attribute, you can refer to elements which have repeats inside the basic group (and you can only refer to all the instances at once).
Examples:
There is a HasRepeatingInstances attribute
SearchElements.RepGr1.Instance(1).RepGr2.AllInstances.RepGr3.AllInstaces.Element
SearchElements.RepGr1.Instance(1).RepGr2.AllInstances.RepGr3.AllInstaces.RepGr4.AllInstances.Element
There is no HasRepeatingInstances attribute
SearchElements.RepGr1.Instance(1).RepGr2.AllInstancess.Gr3.SubElement(where Gr3 is a simple group)
SearchElements.RepGr1.Instance(1).RepGr2.AllInstances.SubElement
Note.If references are created via Source element, the check will be performed when the FlexiLayout is built, and if references are created using Advanced code, an error will be detected when matching the FlexiLayout.
Using the FlexiLayout language to describe the location of a block
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 of type TableHypothesisInstances). For more about the predefined variable that can be used in the Expression field, see Predefined variables.
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; |
You can also use a pre-defined IsNull 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 that the region has been found, the value true means that the region has not been found.
The IsNull variable is initialized with the value false, i.e. the region of the block is considered to be found. However, sometimes you may wish to check certain conditions before making a conclusion.
Using the IsNull variable
12.04.2024 18:16:02