English (English) - Change language

Sample 3. Step 25: Detecting the TotalQuantity and TotalAmount fields with a TotalQuantity and TotalAmount elements

Analysis of the test images reveals that the Total Quantity and Total Amount fields only occur together with the name Footer.kwTotal and are located on the same level. We will use elements of type Character String to detect the Total Quantity and the Total Amount fields. To specify the search constraints common to these elements, we need to create a Group element — grTotal.

To create the Group element grTotal:

  1. In the Footer element, create a Group element and name it grTotal.
  2. Select the Optional element because we decided to stop the search of the subelements in case of name absence.
    Note.For some details see Help article Tips and tricks\The "Optional" property of a Group element.
  3. Click the Advanced tab.
  4. Since the Total Quantity and the Total Amount fields only occur on the image together with the name Footer.kwTotal, set the following additional search constraint in the Advanced pre-search relations field:If the Footer.kwTotal element has not been detected, do not look for the object on the image. In the FlexiLayout language:
    If Footer.kwTotal.IsNull Then DontFind;

The Total Quantity field is located at the intersection of the Total row and the Quantity column. The first constraint was already specified at the Group element level. To specify the second constraint, we will use the previously detected column name as a reference element.

To create the TotalQuantity element:

  1. In the grTotal element, create an element of type Character String and name it TotalQuantity.
  2. Click the Character String tab.
  3. In the Character count field, specify this fuzzy interval: {-1, 1, 10, INF}. This is an estimation of the length of the character string. We assume that the possible values may range from 1 to 10. Any hypotheses outside this range will be penalized.
  4. Leave the default values for the other parameters of the element.
  5. Click the Relations tab.
  6. Since the Total Quantity field is always located on the same level with the keywords of the name Footer.kwTotal or slightly lower, set the following search constraints:
    • Above the element Footer.kwTotal, Offset = -200, Reference boundary = Bottom
    • Below the element Footer.kwTotal, Offset = -20, Reference boundary = Top
      Note.Prior to setting the values for the offsets, you may want to analyze the geometrical properties (i.e. size and boundaries) of the neighboring objects detected during pre-recognition. Offset values are selected by trial and error.
  7. Click the Advanced tab.
  8. Since the Total Quantity field is optional on the images but whenever it occurs it occurs together with the Quantity column and below its name, set the following additional search constraint in the Advanced pre-search relations field:Look for the object on the image only if the TableHeader.kwQuantity element has been detected; Look no farther than 50 dots to the left or to the right of the respective boundaries of the column name. In the FlexiLayout language:
    If Not (TableHeader.kwQuantity.IsNull) Then
    {
    LeftOf: TableHeader.kwQuantity.Right, -50 * dot;
    RightOf: TableHeader.kwQuantity.Left, -50 * dot;
    }
    Else DontFind;
  9. Try matching the FlexiLayout with the test images and make sure that the program successfully detects the element on all the images where applicable.
  10. To describe the location of the TotalQuantity block, select the Source element option, then click "" and select the TotalQuantity element as the source element.

The Total Amount field is located at the intersection of the Total row (the footer of the table) and the Total column. The first constraint was already specified at the Group element level. To specify the second constraint, we will use the previously detected column names as reference elements.

To create the TotalAmount element:

  1. In the grTotal element, crate an element of type Character String and name it TotalAmount.
  2. Click the Character String tab.
  3. In the Character count field, specify this fuzzy interval: [-1, 1, 20, 2147483647]. This is an estimation of the length of the character string. We assume that the possible values may range from 1 to 20. Any hypotheses outside this range will be penalized.
  4. Leave the default values for the other parameters of the element.
  5. Click the Relations tab.
  6. Since the Total Amount field is always located on the same level with the keywords of the name Footer.kwTotal, set the following search constraints:
    • Above the element Footer.kwTotal, Offset = -20, Reference boundary = Bottom.
    • Below the element Footer.kwTotal, Offset = -20, Reference boundary = Top.
  7. Click the Advanced tab.
  8. Since the Total Amount field can only be located immediately below (may be with a small shift) the name of the Total column and only between the Unit Price and Sales columns, set the following additional search constraint in the Advanced pre-search relations field:If the TableHeader.kwTotal element has been detected, look for the object no farther than 70 dots to the right of the right boundary of the TableHeader.kwTotal element and no farther than 50 dots to the left from the left boundary of the TableHeader.kwTotal element; or, if the TableHeader.kwUnitPrice and TableHeader.kwSales elements are detected, look for the object no farther than 40 dots to the right of the left boundary of the TableHeader.kwSales element and to the right of the right boundary of the TableHeader.kwUnitPrice element; otherwise do not look for the object.In the FlexiLayout language:
    If Not (TableHeader.kwTotal.IsNull) Then
    {
    LeftOf: TableHeader.kwTotal.Right, -70 * dot;
    RightOf: TableHeader.kwTotal.Left, -50 * dot;
    }
    Else
    If Not (TableHeader.kwUnitPrice.IsNull) and Not (TableHeader.kwSales.IsNull) Then
    {
    LeftOf: TableHeader.kwSales.Left, -40 * dot;
    RightOf: TableHeader.kwUnitPrice, 0 * dot;
    }
    Else DontFind;
    Note.Prior to setting the values for the offsets, you may want to analyze the geometrical properties (i.e. size and boundaries) of the neighboring objects detected during pre-recognition. Offset values are selected by trial and error.
  9. Try matching the FlexiLayout with the test images and make sure that the program successfully detects the element on all the images where applicable.
  10. To describe the location of the TotalAmount block, select the Source element option, then click and select the TotalAmount element as the source element.

09.10.2020 8:50:41


Please leave your feedback about this article