code wiki / (root) / nx_doc_scan.nx

nx_doc_scan.nx

buildroot/runtime/nx_doc_scan.nx

5473 B139 linesdepth 2pulls 2 transitivereach 1 importersview sourcekind librarytopic doc
docsdependenciesstructsconstsfunctions

about

nx_doc_scan.nx -- R4 of THE NISHI DOCUMENT-INTELLIGENCE arc: the SCAN / CAPTURE leg (paper/image -> characters). The honest first rung of OCR, built sovereign rung-up (NOT a waved "general OCR"): (1) DECODE a standard scanned-image format -- NetPBM P1 (ASCII bitmap, "P1\n<w> <h>\n<0/1 grid>") -> a pixel grid. A real image-file decoder. (2) RECOGNIZE digits by TEMPLATE MATCHING (the classic fixed-font OCR technique): each glyph cell is compared against a sovereign 3x5 reference font (DATA), nearest by Hamming distance wins; the distance IS the confidence (a blank/garbage cell matches at a large distance = low confidence). This turns a scanned bitmap (e.g. an account number / amount) into a structured digit string. Honest scope: fixed 3x5 digit font + fixed-pitch cells; variable fonts / proportional layout / full alphabets are later rungs grounded on the doc_scan_* / doc_read_layout corpus. No hardware writes, no floats. license_tier: ORIGINAL

dependencies 1 imports · 1 importers

nx_syscalls.nx nx_doc_scan.nx nx_doc_scan_gate.nx

imports: nx_syscalls.nx

imported by: nx_doc_scan_gate.nx

structs

none

consts

13const K_MAGIC_9999: i64 = 9999

functions

16func sp_pat(d: i64) -> *u8
called by 2: sp_stampsp_celldist
31func sp_stamp(grid: *u8, gw: i64, x0: i64, d: i64) -> i64
called by 1: main calls 1: sp_pat
46func sp_celldist(grid: *u8, gw: i64, x0: i64, y0: i64, d: i64) -> i64
called by 1: sp_match calls 1: sp_pat
65func sp_match(grid: *u8, gw: i64, x0: i64, y0: i64, out_dist: *i64) -> i64
called by 2: sp_recognize_rowmain calls 1: sp_celldist
80func sp_recognize_row(grid: *u8, gw: i64, x0: i64, cellw: i64, ndigits: i64, out: *u8, out_maxdist: *i64) -> i64
called by 1: main calls 2: sys_mmapsp_match
96func sp_readint(text: *u8, n: i64, pos: *i64) -> i64
called by 1: sp_pbm_decode
115func sp_pbm_decode(text: *u8, n: i64, grid: *u8, dims: *i64, cap: i64) -> i64
called by 1: main calls 2: sys_mmapsp_readint