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
Input value inCharacters list[OcrResult] Output of DL_ReadCharacters
Input value inMaxGap float 0.0 - 10.0 Maximum gap between adjacent characters along the reading direction, denoted as fraction of 'A' char height
Input value inMaxShift float 0.0 - 1.0 Maximum misalignment between adjacent characters perpendicular to the reading direction, denoted as fraction of 'A' char height
Input value inMargin float 0.0 - 10.0 Additional margin added to result, denoted as fraction of 'A' char height
Input value inMinLength int 1 - 200 Minimal number of chars to create line
Input value inFlatten bool If True, it concatenates the words on the line into a single result string, otherwise each word is a separate result string
Input value inPattern str Pattern used in Grammar rules filtering
Input value inCandidates list[ list[OcrCandidate] ] | None None Candidates - optional output of DL_ReadCharacters, Required when using grammar rules (when inPattern is not empty)
Input value inMinScore float 0.0 - 1.0 Minimum score for filtering the line of text
Input value inLineDirection LineDirection Expected text orientation direction
Output value outLines list[Rectangle2D] Minimal Box which cover all selected character boxes
Output value outStrings list[str] Text of merged characters
Output value 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
Output value outScores list[float] Calculated the score for the line
Output value 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.