Swift package · v0.1.0
KLReadingOrder
Order OCR candidates into horizontal or vertical reading lines.
A synchronous geometry engine for horizontal, vertical, automatic, and multipage reading order. It preserves caller-owned candidate identifiers and does not perform OCR.
Functions
- Horizontal rows and right-to-left vertical columns
- Automatic direction inference per page
- Adaptive median-based geometry tolerance
- Merged bounds, mean confidence, and source IDs
Not included
It reconstructs geometry; it does not run OCR, deskew pages, reject confidence, detect language, parse tables, or interpret document meaning.
Install with SwiftPM
.package(url: "https://github.com/KoenLee1023/KLReadingOrder.git", from: "0.1.0")Usage
let engine = ReadingOrderEngine()
let lines = engine.reconstruct(
candidates: observations,
preferredDirection: .unknown
)
for line in lines {
print(line.text)
}API documentation
Open the complete API documentation.ReadingOrderEngineFilters, groups, resolves direction, clusters, orders, and aggregates observations.
ReadingOrderPolicyNames every geometric threshold and supplies default values.
ReadingOrderLineReturns ordered IDs, merged bounds, joined text, confidence, page, and direction.
Demo apps
Reading Flow
Visualize shuffled boxes and their reconstructed lines and IDs.
Layout Comparator
Apply horizontal, vertical, and automatic modes to the same geometry.