Skip to content

API Reference parrot_loaders.ocr.models

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot_loaders.ocr.models

View source

OCR data models for the ImageLoader feature.

These dataclasses are internal data transfer objects used across all OCR backends and layout analyzers. They are intentionally plain dataclasses (not Pydantic models) for maximum performance and minimal overhead.

Class LayoutLine

A horizontal line of text blocks at approximately the same y-coordinate.

Parameter Type Default Description
blocks List[OCRBlock]
y_center float
is_header bool False

Fields:

Field Type Default Description
blocks List[OCRBlock] OCR blocks belonging to this line, sorted left-to-right.
y_center float The vertical center position of this line (in pixels).
is_header bool False True if this line was detected as a header (large text or ALL CAPS).

Class LayoutResult

Complete layout analysis result for a single image.

Parameter Type Default Description
lines List[LayoutLine]
tables List[List[List[str]]] list()
table_line_ranges List[Tuple[int, int]] list()
columns_detected int 1
avg_confidence float 0.0

Fields:

Field Type Default Description
lines List[LayoutLine] All detected text lines, sorted top-to-bottom.
tables List[List[List[str]]] field(default_factory=list) Detected tables, each represented as a list of rows, where each row is a list of cell strings.
table_line_ranges List[Tuple[int, int]] field(default_factory=list) For each table, the (start, end) line indices (inclusive start, exclusive end) mapping it back to lines.
columns_detected int 1 Number of visual columns detected (1 = single column).
avg_confidence float 0.0 Average OCR confidence across all blocks.

Class OCRBlock

A single text region detected by OCR.

Parameter Type Default Description
text str
bbox Tuple[int, int, int, int]
confidence float
font_size_estimate Optional[float] None

Fields:

Field Type Default Description
text str The extracted text content.
bbox Tuple[int, int, int, int] Bounding box as (x1, y1, x2, y2) pixel coordinates (top-left to bottom-right).
confidence float OCR confidence score, ranging from 0.0 to 1.0.
font_size_estimate Optional[float] None Estimated relative font size (in pixels), used for header detection. Derived from bbox height. None if not available.

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally