<a id="easyocr2-setting-parameters"></a>

# Advanced Parameters

<a id="easyocr2-segmentation-parameters"></a>

## Segmentation Parameters

The following parameters are set and used in the process: [Detecting the Characters](using_easyocr2.html.md#easyocr2-detecting).

<a id="easyocr2-segmentation-method"></a>

### Select the Segmentation Method

* Use[`SetSegmentationMethod`](../../../doxygen_cpp/classeVision_1_1EOCR2.html#a2ef9ff612df43f5b9136ff35f6044ca6) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EOCR2.html#a784297acfef2409094f0efbb5ac9831e) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EOCR2.html#a8d286bb1e8e8add69b7d62046f9f1d1f) to select the algorithm used for segmentation:

* [`EOCR2SegmentationMethod_Local`](../../../doxygen_cpp/namespaceeVision.html#a4001d6f38abe184e9abaeeabff06fbbf) [<sub>.NET</sub>](../../../doxygen_cs/namespaceeVision.html#addba447a030810c8a5ed949bb18fa9da) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EOCR2SegmentationMethod.html) is more complex and best suited for a non uniform background.
* Use [`SetMaxVariation`](../../../doxygen_cpp/classeVision_1_1EOCR2.html#af8e0717ff12fcbc84fba0b4c1388e0b5) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EOCR2.html#a1121dada98463a6d0cbbce816e86769b) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EOCR2.html#afe307afb8c4105ad0989241b99b1631c) to define how sharp a blob in the image should be in order to be considered a potential character.
  * A region with clearly defined edges is generally considered stable while a blurry region is not.
  * Set this parameter between 0 and 1 (the default setting is 0.25).
  * A low setting allows only very stable blobs.
  * A high setting allows detection of blobs that are more unstable.
* Use [`SetDetectionDelta`](../../../doxygen_cpp/classeVision_1_1EOCR2.html#a9ce56cf5d8704de25c57eaf01a17e278) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EOCR2.html#af89f709878012e1ecc3bff7522056da3) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EOCR2.html#a87685e190fa0ce948db19c6d4a4700f2) to set the range of grayscale values used to determine the stability of a blob.
  * Set this parameter between 1 and 127 (the default setting is 12).
  * With a low setting, the algorithm is more sensitive to noise.
  * With a high setting, the algorithm is insensitive to blobs that have a low contrast with the background.

* [`EOCR2SegmentationMethod_Global`](../../../doxygen_cpp/namespaceeVision.html#a4001d6f38abe184e9abaeeabff06fbbf) [<sub>.NET</sub>](../../../doxygen_cs/namespaceeVision.html#addba447a030810c8a5ed949bb18fa9da) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EOCR2SegmentationMethod.html) is faster and best suited for a clear background.
* It uses a simple threshold.
* Use [`SetGlobalSegmentationThresholdMode`](../../../doxygen_cpp/classeVision_1_1EOCR2.html#a62837c4a205a7f4992e6d26603596469) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EOCR2.html#af0cac39e11faee277712f73af998e6aa) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EOCR2.html#a166bad6c27f048b12136ec1f9ccbed37) to set the threshold computation method.
  * This parameter is a [`EThresholdMode`](../../../doxygen_cpp/namespaceeVision.html#a7fdafd024ed604588f7a9792905f3e4b) [<sub>.NET</sub>](../../../doxygen_cs/namespaceeVision.html#a8e31721ead762012592893688fd19af4) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EThresholdMode.html).
  * Use [`SetGlobalSegmentationAbsoluteThreshold`](../../../doxygen_cpp/classeVision_1_1EOCR2.html#abc2fff4d306a4794bed8741c7b3938bc) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EOCR2.html#aa099e516b50a55ffc7ce711783a24425) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EOCR2.html#aed6ab2b8adcf60f1260d2a1cd6f962eb) to set the threshold value when required.
* Use [`SetEnableSecondPassGlobalSegmentation`](../../../doxygen_cpp/classeVision_1_1EOCR2.html#aa60e5da22dcd213e9f18e3d8f4aa3349) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EOCR2.html#a57a099944e7413173b43710f71535039) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EOCR2.html#aebe68dc404abe6c3a904ddcf088aafab) to perform the segmentation twice during the first pass.
  * It leads to more accurate results when the text background is not just plain.

  #### WARNING
  This functionality is only available when `GlobalSegmentationThresholdMode` is set to the minimum residue ([`EThresholdMode_MinResidue`](../../../doxygen_cpp/namespaceeVision.html#a7fdafd024ed604588f7a9792905f3e4b) [<sub>.NET</sub>](../../../doxygen_cs/namespaceeVision.html#a8e31721ead762012592893688fd19af4) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EThresholdMode.html)).

![](assets/images/easyocr2/local.jpg)![](assets/images/easyocr2/global_relative_02.jpg)

<a id="easyocr2-fragmentation"></a>

### Adjust the Fragmentation

* Use [`SetCharsMaxFragmentation`](../../../doxygen_cpp/classeVision_1_1EOCR2.html#a0e48501cc0b0512d937263c1b6b5729a) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EOCR2.html#a22caf4ab918a7a84634c919cb49240be) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EOCR2.html#afe70cfd0ad4009d23d53f38ad2ebee29) to set how small a blob can be for the segmentation algorithm to consider it as (part of) a character.
  * The minimum allowed area of a blob is given by:

  $$
  \text{minArea} = \text{CharsMaxFragmentation} × \text{CharsHeight} × min(\text{CharsWidthRange})
  $$

  * Set this parameter between 0 and 1 (the default setting is 0.1).

![image](assets/images/easyocr2/functional_detection_5.webp)![image](assets/images/easyocr2/functional_detection_6.webp)

<a id="easyocr2-detection-parameters"></a>

## Detection Parameters

The following parameters are set and used in the process: [Detecting the Characters](using_easyocr2.html.md#easyocr2-detecting).

<a id="easyocr2-detection-method"></a>

### Select the Detection Method

If the topology is required, use [`SetDetectionMethod`](../../../doxygen_cpp/classeVision_1_1EOCR2.html#a781e0d8b7010dc598f003183772c8481) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EOCR2.html#a03c2abf05e38b071289be183f724976d) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EOCR2.html#ad504b5e2daaa64c7cf84b478c7d4b013) to select the algorithm used for fitting:

![image](assets/images/easyocr2/functional_detection_1.webp)
* Use [`EOCR2DetectionMethod_FixedWidth`](../../../doxygen_cpp/namespaceeVision.html#a3c943de2179a4585330b882f41b181b9) [<sub>.NET</sub>](../../../doxygen_cs/namespaceeVision.html#aece025f7a661fe54edd9180ee48ac3d7) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EOCR2DetectionMethod.html).
* Supports dotted text.
* Use [`SetRelativeSpacesWidthRange`](../../../doxygen_cpp/classeVision_1_1EOCR2.html#a31053fcd4ac3b4e846310d51b86283e2) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EOCR2.html#aff18142ecf21f975a4fc476036014379) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EOCR2.html#ac6054e66984b4e193ce40018ecec633b) to specify how wide the spaces between the words may be.
  * The box-fitting method tests the following range of spaces:

  $$
  min(RelativeSpacesWidthRange) ×  min(charsWidthRange)

  ≤ space ≤

  max(RelativeSpacesWidthRange) × max(charsWidthRange)
  $$

  * The upper bound of this parameter is also used when the topology is not required.
* Use [`SetCharsWidthBias`](../../../doxygen_cpp/classeVision_1_1EOCR2.html#add73f17c267f6af2a08e120035d7ada1) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EOCR2.html#a22a553095c4bc4a106f4b672f276a18c) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EOCR2.html#a40df13ec46aead5abb81d20abd33a6f2) to add a bias towards wider or narrower character boxes.
* Use [`SetCharsSpacingBias`](../../../doxygen_cpp/classeVision_1_1EOCR2.html#a0e8924c05e9c46ca64f2076dad7ac9f0) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EOCR2.html#ab6f3f688556dd2a35b4cf3a8a13d1644) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EOCR2.html#ad82ad96f7af475a457d15416b250dc67) to add a bias towards a smaller or larger spacing between character boxes.

![image](assets/images/easyocr2/functional_detection_2.webp)
* Use [`EOCR2DetectionMethod_Proportional`](../../../doxygen_cpp/namespaceeVision.html#a3c943de2179a4585330b882f41b181b9) [<sub>.NET</sub>](../../../doxygen_cs/namespaceeVision.html#aece025f7a661fe54edd9180ee48ac3d7) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EOCR2DetectionMethod.html)
* Use [`SetEnableCutLargeCharacter`](../../../doxygen_cpp/classeVision_1_1EOCR2.html#a97f85a686fcc8468e0cb7373d298ca4b) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EOCR2.html#a44599246fdcfcd07a32237a5610258cd) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EOCR2.html#a7dbf246b83f047f56d9af9155e956e3d) so that the detection will try to cut wide segmented blobs into smaller boxes.
  * This parameter is also used when the topology is not required.

#### WARNING
* With the fixed-width method, all the character boxes have the same width and they do not necessarily fit tightly around the characters.
* With the proportional method, the character boxes fit tightly around the characters. If any character falls outside the range of allowed widths, the detection fails.

<a id="easyocr2-text-rotation"></a>

### Set the Text Rotation Angle

* Use [`SetTextAngleRange`](../../../doxygen_cpp/classeVision_1_1EOCR2.html#af0de38d85d26159836182d72b48b8eea) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EOCR2.html#a332d939cc51fd164b095f811f6b9adec) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EOCR2.html#a56fda30d61496b799dfa0e3e63b5169e) to specify how the text in the image may be oriented.
  The box-fitting method tests the following range of rotation angles:
  $$
      min(TextAngleRange) ≤ angle ≤ max(TextAngleRange)
  $$

  * The angles are defined with respect to the horizontal.
  * To set the unit for the angles (degrees, radians, revolutions or grades), use [`SetAngleUnit`](../../../doxygen_cpp/classeVision_1_1Easy.html#a3f16cccaa4404377fbd42bf435111020) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1Easy.html#ae0a5022bfad11d93725749f840a1fbf9) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1Easy.html#afd95f7439ea9d6b35f48399f10c77c4b).
  * The default setting is $[-20, 20]$ degrees.
  * This parameter is also used when the topology is not required.

<a id="easyocr2-second-detection-pass"></a>

### Set a Second Detection Pass

* Use [`SetNumDetectionPasses`](../../../doxygen_cpp/classeVision_1_1EOCR2.html#a955f20ce6dbd5188cc37e151646072e9) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EOCR2.html#ae5cd0f796cb8d22bd916e4af5e984f87) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EOCR2.html#a45ad1a8ab3c1c2de5240345c4e62a2f5) to configure a second pass for the textbox-fitting operation.
  * The first pass fits textboxes to all detected blobs.
  * The second pass selects only the blobs that are covered by the textboxes from the first pass. It fits textboxes to that subset of blobs, possibly resulting in a more optimal fit.
  * Set this parameter to either 1 or 2.
  * The default setting is 1.
  * This parameter is also used when the topology is not required.

![image](assets/images/easyocr2/functional_detection_3.webp)

The text angle estimate is slightly off.

![image](assets/images/easyocr2/functional_detection_4.webp)

The text angle estimate fits more closely.

<a id="easyocr2-no-topology-parameter"></a>

## No-Topology Mode Parameters

The following parameters are set and used in the process: [Detect the Characters](using_easyocr2.html.md#easyocr2-detecting).

There are other parameters you can set if you are not using a topology:

* Use [`SetEnableOffSizeCharacter`](../../../doxygen_cpp/classeVision_1_1EOCR2.html#a703adfe86239e034d80fb387f3678ed4) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EOCR2.html#a3ad6ba98cba03ae1f0dd3fb9e32c83e0) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EOCR2.html#a0e6cb8f482361b1557669032a1f109f1) to detect characters whose size (width and height) is out of the range but are in the vicinity of valid characters.

* Use [`SetRepasteObjects`](../../../doxygen_cpp/classeVision_1_1EOCR2.html#aa025fbca3649a61ab5c63ecce10401ad) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EOCR2.html#a5c4ad7855e6d1679b9c4b1120f524d13) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EOCR2.html#abf3b524b5dbe7e5a3e46e6d82528633e) to try and group blobs of the same character.
  * It can improve the detection of a clean segmentation with characters close to each other.
  * When true (default), the detection process tries to merge the blobs.
