<?xml version="1.0"?>
<!-- 
Copyright (c) 2012-2014, Smart Engines Ltd
All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

    * Redistributions of source code must retain the above copyright notice,
      this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
    * Neither the name of the Smart Engines Ltd nor the names of its
      contributors may be used to endorse or promote products derived from this
      software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE 
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-->

<mrzapi_engine xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:noNamespaceSchemaLocation="mrzapi_engine.xsd">

  <!-- NOTE: standard height for all document types must be equal,
       standard widths might differ. If several document types are
       enabled in session settings, maximal width will be used -->
  <supported_docsubtypes name="INOPASSPORT" line_length="44" lines_count="2"
      standard_height="200" standard_width="1200"/>
  <!-- NOTE: for TD1 standard aspect ratio is 4:1 -->
  <supported_docsubtypes name="TD_1" line_length="30" lines_count="3"
      standard_height="200" standard_width="800"/>
  <supported_docsubtypes name="TD_2" line_length="36" lines_count="2"
      standard_height="200" standard_width="1200"/>
  <supported_docsubtypes name="ID_FRANCE" line_length="36" lines_count="2"
      standard_height="200" standard_width="1200"/>
  <supported_docsubtypes name="MRV_A" line_length="44" lines_count="2"
      standard_height="200" standard_width="1200"/>
  <supported_docsubtypes name="MRV_B" line_length="36" lines_count="2"
      standard_height="200" standard_width="1200"/>

  <preprocessing_settings>
    <grayscaling_method>average</grayscaling_method>
    <roi_compatibility_tolerance>0.05</roi_compatibility_tolerance>
  </preprocessing_settings>

  <recognition_settings>
    <recognizer_path>mrzocr/network_6_packed.pb</recognizer_path>
    <should_use_aux_recognizer>false</should_use_aux_recognizer>
    <output_pins>0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ&lt;</output_pins>
    <max_focus_trust>1.0</max_focus_trust>
    <min_focus_trust>0.6</min_focus_trust>
    <should_oscillate>false</should_oscillate>
    <should_prescale>false</should_prescale>
    <should_autocontrast>false</should_autocontrast>
    <should_preshift>false</should_preshift>
  </recognition_settings>  

  <rejection_settings>
    <focus_threshold>65</focus_threshold>
    <garbage_filtering_enabled>true</garbage_filtering_enabled>
    <salient_fields_threshold>2</salient_fields_threshold>
    <enable_field_confidence_threshold>true</enable_field_confidence_threshold>
    <field_confidence_threshold>0.9</field_confidence_threshold>
  </rejection_settings>

  <image_check_settings>
    <focus_threshold>85</focus_threshold>
    <intensity_threshold>70</intensity_threshold>
  </image_check_settings>

  <segmentation_settings>
    <count_false>6</count_false>
    <img_zoom>4</img_zoom>
    <q_err>0.2</q_err>
    <segm_dev_thresh>0.052</segm_dev_thresh>
    <step>15</step>
    <thresh_gap>10</thresh_gap>
    <wd_char>5</wd_char>
    <wd_gap>3</wd_gap>
    <do_second_pass>true</do_second_pass>
    <sp_twolined_margin>0.03</sp_twolined_margin>
    <sp_threelined_margin>0.00</sp_threelined_margin>
    <doc_types name="INOPASSPORT" nLines="2" nGaps="45" htChar="7" 
        standard_width="1200"
        wdChar="5" wdGap="2" realHtCell="38" 
        gapLine="17" gapDelta="1" garbageTolerance="4" lambda1="1.2" lambda2="0.0"/>
    <!-- NOTE: for TD1 standard aspect ratio 4:1 -->
    <doc_types name="TD_1" nLines="3" nGaps="31" htChar="8" 
        standard_width="800"
        wdChar="5" wdGap="2" realHtCell="36" 
        gapLine="12" gapDelta="2" garbageTolerance="4" lambda1="1.2" lambda2="0.5"/>
    <!-- NORE: for TD1 standard aspect ratio 6:1 -->
    <doc_types name="TD_1" nLines="3" nGaps="31" htChar="9" 
        standard_width="1200" 
        wdChar="6" wdGap="3" realHtCell="48" 
        gapLine="15" gapDelta="2" garbageTolerance="4" lambda1="1.2" lambda2="0.5"/>

    <doc_types name="TD_2" nLines="2" nGaps="37" htChar="8" 
        standard_width="1200"
        wdChar="5" wdGap="3" realHtCell="44" 
        gapLine="20" gapDelta="2" garbageTolerance="4" lambda1="1.0" lambda2="1.0"/>
    <doc_types name="MRV_A" nLines="2" nGaps="45" htChar="7" 
        standard_width="1200"
        wdChar="5" wdGap="2" realHtCell="38" 
        gapLine="17" gapDelta="1" garbageTolerance="4" lambda1="1.2" lambda2="0.0"/>
    <doc_types name="MRV_B" nLines="2" nGaps="37" htChar="8" 
        standard_width="1200"
        wdChar="5" wdGap="3" realHtCell="44" 
        gapLine="20" gapDelta="2" garbageTolerance="4" lambda1="1.2" lambda2="0.0"/>
    <doc_types name="ID_FRANCE" nLines="2" nGaps="37" htChar="8" 
        standard_width="1200"
        wdChar="5" wdGap="3" realHtCell="44" 
        gapLine="20" gapDelta="2" garbageTolerance="4" lambda1="1.0" lambda2="1.0" />
  </segmentation_settings>

  <postprocessing_settings>
    <dictionaries load_time="at_once" path="dictionaries/surname.dict">
      <fields>NAME0</fields>

      <nations>USA</nations><nations>AUS</nations><nations>AUT</nations>
      <nations>BEL</nations><nations>GBR</nations><nations>GBD</nations>
      <nations>GBN</nations><nations>GBO</nations><nations>GBP</nations>
      <nations>GBS</nations><nations>D</nations><nations>IRL</nations>
      <nations>LIE</nations><nations>LUX</nations><nations>MCO</nations>
      <nations>NLD</nations><nations>FRA</nations><nations>CHE</nations>
      <nations>DNK</nations><nations>ISL</nations><nations>NOR</nations>
      <nations>FIN</nations><nations>SWE</nations><nations>AND</nations>
      <nations>VAT</nations><nations>GRC</nations><nations>ESP</nations>
      <nations>ITA</nations><nations>MLT</nations><nations>PRT</nations>
      <nations>SMR</nations>

      <total_aggression>0.2</total_aggression>
    </dictionaries>
    <dictionaries load_time="at_once" path="dictionaries/name.dict">
      <fields>NAME1</fields>

      <nations>USA</nations><nations>AUS</nations><nations>AUT</nations>
      <nations>BEL</nations><nations>GBR</nations><nations>GBD</nations>
      <nations>GBN</nations><nations>GBO</nations><nations>GBP</nations>
      <nations>GBS</nations><nations>D</nations><nations>IRL</nations>
      <nations>LIE</nations><nations>LUX</nations><nations>MCO</nations>
      <nations>NLD</nations><nations>FRA</nations><nations>CHE</nations>
      <nations>DNK</nations><nations>ISL</nations><nations>NOR</nations>
      <nations>FIN</nations><nations>SWE</nations><nations>AND</nations>
      <nations>VAT</nations><nations>GRC</nations><nations>ESP</nations>
      <nations>ITA</nations><nations>MLT</nations><nations>PRT</nations>
      <nations>SMR</nations>

      <total_aggression>0.2</total_aggression>
    </dictionaries>
    <!-- composite dictionary wildcard: united_dictionary -->
    <dictionaries load_time="at_once" path="united_dictionary"> 
      <fields>NAME2</fields>

      <nations>USA</nations><nations>AUS</nations><nations>AUT</nations>
      <nations>BEL</nations><nations>GBR</nations><nations>GBD</nations>
      <nations>GBN</nations><nations>GBO</nations><nations>GBP</nations>
      <nations>GBS</nations><nations>D</nations><nations>IRL</nations>
      <nations>LIE</nations><nations>LUX</nations><nations>MCO</nations>
      <nations>NLD</nations><nations>FRA</nations><nations>CHE</nations>
      <nations>DNK</nations><nations>ISL</nations><nations>NOR</nations>
      <nations>FIN</nations><nations>SWE</nations><nations>AND</nations>
      <nations>VAT</nations><nations>GRC</nations><nations>ESP</nations>
      <nations>ITA</nations><nations>MLT</nations><nations>PRT</nations>
      <nations>SMR</nations>

      <total_aggression>0.2</total_aggression>
    </dictionaries>

    <highlight path=""> <!-- empty path means that the highlight engine is turned off-->
      <allowed_bad_cell_ratio>0.1</allowed_bad_cell_ratio>
      <confidence_weight>0.7</confidence_weight>
      <integration_weight>0.4</integration_weight>
    </highlight>

    <field_reject_threshold field="DocType" threshold="0.8"/>
    <field_reject_threshold field="Sex" threshold="0.9"/>
    <field_reject_threshold field="Name" threshold="0.7"/>
    <field_reject_threshold field="Nation" threshold="0.8"/>
    <field_reject_threshold field="OptData" threshold="0.8"/>
    <field_reject_threshold field="Country" threshold="0.8"/>    
    <field_reject_threshold field="DocNum" threshold="0.8"/>
    <field_reject_threshold field="Birthdate" threshold="0.7"/>
    <field_reject_threshold field="Expidate" threshold="0.7"/>

    <frame_reject_threshold>0.13</frame_reject_threshold>
    <max_excess_letters_left>2</max_excess_letters_left>
    <max_excess_letters_right>5</max_excess_letters_right>
    <alphanumeric_zero_bonus>0.9</alphanumeric_zero_bonus>
    <field_syntax_restriction_file_path>mrzcontexts/field_syntax_restrictions.xml</field_syntax_restriction_file_path>
    <allow_long_name_separators>false</allow_long_name_separators>
  </postprocessing_settings>

  <integrations_count>4</integrations_count>

</mrzapi_engine>
