MergeCharactersIntoLines
Converts a output of Deep Learning filter DL_ReadCharacters to lines of text.
Syntax
C++
Python
def MergeCharactersIntoLines( inCharacters: list[OcrResult], inMaxGap: float, inMaxShift: float, inMargin: float, inMinLength: int, inFlatten: bool, inPattern: str, inMinScore: float, inLineDirection: LineDirection, /, *, inCandidates: list[ list[OcrCandidate] ] | None = None ) -> ( outLines: list[Rectangle2D], outStrings: list[str], outMapping: list[int | None], outScores: list[float], outProcessedCharacters: list[OcrResult] )
Parameters
| Name | Type | Range | Default | Description | |
|---|---|---|---|---|---|
![]() |
inCharacters | list[OcrResult] | Output of DL_ReadCharacters | ||
![]() |
inMaxGap | float | 0.0 - 10.0 | Maximum gap between adjacent characters along the reading direction, denoted as fraction of 'A' char height | |
![]() |
inMaxShift | float | 0.0 - 1.0 | Maximum misalignment between adjacent characters perpendicular to the reading direction, denoted as fraction of 'A' char height | |
![]() |
inMargin | float | 0.0 - 10.0 | Additional margin added to result, denoted as fraction of 'A' char height | |
![]() |
inMinLength | int | 1 - 200 | Minimal number of chars to create line | |
![]() |
inFlatten | bool | If True, it concatenates the words on the line into a single result string, otherwise each word is a separate result string | ||
![]() |
inPattern | str | Pattern used in Grammar rules filtering | ||
![]() |
inCandidates | list[ list[OcrCandidate] ] | None | None | Candidates - optional output of DL_ReadCharacters, Required when using grammar rules (when inPattern is not empty) | |
![]() |
inMinScore | float | 0.0 - 1.0 | Minimum score for filtering the line of text | |
![]() |
inLineDirection | LineDirection | Expected text orientation direction | ||
![]() |
outLines | list[Rectangle2D] | Minimal Box which cover all selected character boxes | ||
![]() |
outStrings | list[str] | Text of merged characters | ||
![]() |
outMapping | list[int | None] | Mapping between input characters and output lines, outMapping[i] stores the index line to which inCharacters[i] belongs. If outMapping[i] is NIL it means that inCharacters[i] has not been added to any line | ||
![]() |
outScores | list[float] | Calculated the score for the line | ||
![]() |
outProcessedCharacters | list[OcrResult] | Contains the full set of character results after grammar rule processing. Maintains a one-to-one correspondence with inCharacters, preserving original positions but possibly with modified values, scores, or other attributes based on grammar rule application. |


