nx_doc_scan.nx
buildroot/runtime/nx_doc_scan.nx
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
imports: nx_syscalls.nx
imported by: nx_doc_scan_gate.nx
structs
| none |
consts
| 13 | const K_MAGIC_9999: i64 = 9999 |
functions
| 16 | func sp_pat(d: i64) -> *u8 |
| 31 | func sp_stamp(grid: *u8, gw: i64, x0: i64, d: i64) -> i64 |
| 46 | func sp_celldist(grid: *u8, gw: i64, x0: i64, y0: i64, d: i64) -> i64 |
| 65 | func sp_match(grid: *u8, gw: i64, x0: i64, y0: i64, out_dist: *i64) -> i64 |
| 80 | func sp_recognize_row(grid: *u8, gw: i64, x0: i64, cellw: i64, ndigits: i64, out: *u8, out_maxdist: *i64) -> i64 |
| 96 | func sp_readint(text: *u8, n: i64, pos: *i64) -> i64 called by 1: sp_pbm_decode |
| 115 | func sp_pbm_decode(text: *u8, n: i64, grid: *u8, dims: *i64, cap: i64) -> i64 |