code wiki / (root) / nx_haar_xml.nx

nx_haar_xml.nx

buildroot/runtime/nx_haar_xml.nx

16298 B346 linesdepth 8pulls 9 transitivereach 21 importersview sourcekind librarytopic haar
docsdependenciesstructsconstsfunctions

about

nx_haar_xml.nx -- LOADER for a boosted Haar cascade published in the OpenCV 3+ XML schema (aesthetictwin AT30, 2026-09-16). The trained data the field publishes (haarcascade_*.xml: 24x24 or 20x20 windows, stumps or depth-2 trees, rect features with integer weights) enters the estate as a DATA asset mirrored beside its licence (knowledge/fetched/ cmp_aesthetictwin_haar_*.xml + cmp_aesthetictwin_haar_LICENSE.txt, Intel/OpenCV BSD-style and Apache-2.0). It is a BETA-ONLY BOOTSTRAP ARM: the evaluator engine (nx_haar_cascade) is sovereign and stays; the data is replaced by a cascade the estate trains itself (the R-FACE training rung) before any product path carries it, because NishiOS and the browser ship no third-party bytes and no third-party licence. Every real number is fixed-point Q24 (one arithmetic for thresholds, leaf values and weights); a tilted feature, a tree deeper than the shipped data uses, or a file without the <cascade> root is REFUSED BY NAME, never evaluated wrong. Layout of the loaded cascade (flat i64 arrays, see HC_* in nx_haar_cascade): hdr [win_w, win_h, n_stages, n_weak, n_nodes, n_leaves, n_feats, max_rects] stage [first_weak, n_weak, threshold_q24] weak [first_node, n_nodes, first_leaf, n_leaves] node [left, right, feature_idx, threshold_q24] (left/right > 0: node index within the tree; <= 0: leaf index = -value) leaf [value_q24] feat [n_rects, (x, y, w, h, weight_q24) x 3] license_tier: ORIGINAL No hw writes (Rule 26).

dependencies 2 imports · 1 importers

nx_syscalls.nx nx_haar_cascade.nx nx_haar_xml.nx nx_facefind_lib.nx

imports: nx_syscalls.nxnx_haar_cascade.nx

imported by: nx_facefind_lib.nx

structs

none

consts

21const HX_SP: i64 = 32
22const HX_TAB: i64 = 9
23const HX_NL: i64 = 10
24const HX_CR: i64 = 13
25const HX_MINUS: i64 = 45
26const HX_PLUS: i64 = 43
27const HX_DOT: i64 = 46
28const HX_D0: i64 = 48
29const HX_D9: i64 = 57
30const HX_LC_E: i64 = 101
31const HX_UC_E: i64 = 69
32const HX_ONE: i64 = 49
33const HX_BYTE: i64 = 255
34const HX_TEN: i64 = 10
35const HX_Q24: i64 = 16777216
36const HX_MANT_DIGITS: i64 = 11
37const HX_I64: i64 = 8
38const HX_OUT_N: i64 = 2
39const HX_NUMS_B: i64 = 64
40const HX_MAX_TREE_NODES: i64 = 8
41const HX_OK: i64 = 0
42const HX_E_READ: i64 = 0 - 1
43const HX_E_NOT_CASCADE: i64 = 0 - 2
44const HX_E_TILTED: i64 = 0 - 3
45const HX_E_SHAPE: i64 = 0 - 4
46const HX_E_TREE: i64 = 0 - 5
47const HX_E_FEATURE: i64 = 0 - 6
48const HX_E_EMPTY: i64 = 0 - 7
49const HX_T_CASCADE: *u8 = "<cascade" // the root carries an attribute (type_id) in the published files, so the prefix is the key
50const HX_T_HEIGHT: *u8 = "<height>"
51const HX_T_WIDTH: *u8 = "<width>"
52const HX_T_STAGE_THR: *u8 = "<stageThreshold>"
53const HX_T_STAGE_END: *u8 = "</stageThreshold>"
54const HX_T_WEAKS: *u8 = "<weakClassifiers>"
55const HX_T_WEAKS_END: *u8 = "</weakClassifiers>"
56const HX_T_NODES: *u8 = "<internalNodes>"
57const HX_T_NODES_END: *u8 = "</internalNodes>"
58const HX_T_LEAVES: *u8 = "<leafValues>"
59const HX_T_LEAVES_END: *u8 = "</leafValues>"
60const HX_T_FEATURES: *u8 = "<features>"
61const HX_T_RECTS: *u8 = "<rects>"
62const HX_T_RECTS_END: *u8 = "</rects>"
63const HX_T_ENTRY: *u8 = "<_>"
64const HX_T_ENTRY_END: *u8 = "</_>"
65const HX_T_TILTED: *u8 = "<tilted>"

functions

67func hx_is_ws(c: i64) -> i64 { if c == HX_SP { return 1 } if c == HX_NL { return 1 } if c == HX_CR { return 1 } if c == HX_TAB { return 1 } return 0 }
called by 1: hx_skip_ws
68func hx_is_digit(c: i64) -> i64 { if c < HX_D0 { return 0 } if c > HX_D9 { return 0 } return 1 }
called by 2: hx_num_q24hx_int
69func hx_slen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n }
70func hx_skip_ws(b: *u8, n: i64, pos: i64) -> i64
called by 3: hx_num_q24hx_inthx_parse calls 1: hx_is_ws
77func hx_find(b: *u8, n: i64, pos: i64, tag: *u8) -> i64
called by 3: hx_counthx_tag_inthx_parse calls 1: hx_slen
90func hx_num_q24(b: *u8, n: i64, pos: i64, out: *i64) -> i64
150func hx_int(b: *u8, n: i64, pos: i64, out: *i64) -> i64
167func hx_count(b: *u8, n: i64, pos: i64, tag: *u8) -> i64
called by 1: hx_parse calls 1: hx_find
174func hx_tag_int(b: *u8, n: i64, pos: i64, tag: *u8, out: *i64) -> i64
called by 1: hx_parse calls 3: hx_findhx_inthx_slen
181func hx_load(path: *u8, rc_out: *i64) -> *HaarCascade
191func hx_parse(b: *u8, n: i64, rc_out: *i64) -> *HaarCascade