Skip to main content

Crate naina

Crate naina 

Source
Expand description

Read documents. OCR from naina’s C++ core.

Detect text, recognise it, work out the reading order, and get markdown back — all from one compiled core, with no Python and no OpenCV.

use naina::{Reader, Tier};

let reader = Reader::builder().tier(Tier::Small).build()?;
let page = reader.read_rgb(&rgb, width, height)?;

println!("{}", page.markdown());
for line in page.lines() {
    println!("{:.3}  {}", line.confidence, line.text);
}

§Scripts

Latin and CJK by default; Devanagari (Hindi, Marathi, Nepali, Sanskrit) on request:

let reader = Reader::builder().language("devanagari").build()?;

Reading Devanagari with the default alphabet does not fail — it returns plausible-looking Latin at high confidence. Confidence measures certainty within the model’s own alphabet and cannot express “wrong alphabet”, so choose deliberately. An unrecognised language is an error, never a fallback.

§Building

naina links ONNX Runtime. Point at it with ONNXRUNTIME_ROOT, or link an existing build of the core with NAINA_LIB_DIR.

Structs§

Line
One recognised line of text.
Page
The result of reading one image.
Reader
An open naina context.
ReaderBuilder
Builds a Reader.
Region
A layout region.

Enums§

Error
Anything the native core can refuse to do.
RegionKind
What kind of thing a layout region is.
Tier
Model size. Not a licence or capability axis — every model naina ships is Apache-2.0 and every tier does detection, recognition and layout.