nx_haar_cascade.nx
buildroot/runtime/nx_haar_cascade.nx
about
nx_haar_cascade.nx -- Viola-Jones attentional cascade EVALUATOR (R-FACE-2).
The detector engine: a weak classifier is a Haar feature + threshold +
polarity; a stage sums weighted weak votes vs a stage threshold; the cascade
runs stages in order and EARLY-REJECTS the moment any stage fails (so the
vast non-object majority is discarded after 1-2 cheap stages).
This evaluates a GIVEN cascade. The cascade PARAMETERS (thresholds/polarities/
alphas/stage thresholds) come from TRAINING (AdaBoost over a labeled face /
non-face set) -- a separate data-dependent rung. This rung is the machinery,
validated with a hand-built toy cascade.
Layout (caller-supplied flat i64 arrays):
weak row (8 i64): [kind, x, y, w, h, threshold, polarity(+1/-1), alpha]
stage row (3 i64): [weak_offset(in rows), weak_count, stage_threshold]
genealogy_id: viola_jones_2001_attentional_cascade + freund_schapire_adaboost_1997
lineage_id: weak_classifier + boosted_stage + early_reject_cascade
license_tier: ORIGINAL
dependencies 4 imports · 3 importers
imports: syscalls.nxnx_image.nxnx_integral.nxnx_haar.nx
imported by: nx_facefind_lib.nxnx_haar_cascade_gate.nxnx_haar_xml.nx
structs
| 68 | struct HaarCascade |
consts
| 24 | const NX_WEAK_FIELDS: i64 = 8 |
| 25 | const NX_STAGE_FIELDS: i64 = 3 |
| 76 | const HC_BYTES: i64 = 48 |
| 77 | const HC_HDR_N: i64 = 8 |
| 78 | const HC_H_WINW: i64 = 0 |
| 79 | const HC_H_WINH: i64 = 1 |
| 80 | const HC_H_NSTAGES: i64 = 2 |
| 81 | const HC_H_NWEAK: i64 = 3 |
| 82 | const HC_H_NNODES: i64 = 4 |
| 83 | const HC_H_NLEAVES: i64 = 5 |
| 84 | const HC_H_NFEATS: i64 = 6 |
| 85 | const HC_H_MAXRECTS: i64 = 7 |
| 86 | const HC_STAGE_FIELDS: i64 = 3 |
| 87 | const HC_S_FIRST: i64 = 0 |
| 88 | const HC_S_N: i64 = 1 |
| 89 | const HC_S_THR: i64 = 2 |
| 90 | const HC_WEAK_FIELDS: i64 = 4 |
| 91 | const HC_W_FIRST_NODE: i64 = 0 |
| 92 | const HC_W_N_NODES: i64 = 1 |
| 93 | const HC_W_FIRST_LEAF: i64 = 2 |
| 94 | const HC_W_N_LEAVES: i64 = 3 |
| 95 | const HC_NODE_FIELDS: i64 = 4 |
| 96 | const HC_N_LEFT: i64 = 0 |
| 97 | const HC_N_RIGHT: i64 = 1 |
| 98 | const HC_N_FEAT: i64 = 2 |
| 99 | const HC_N_THR: i64 = 3 |
| 100 | const HC_MAX_RECTS: i64 = 3 |
| 101 | const HC_RECT_FIELDS: i64 = 5 |
| 102 | const HC_R_X: i64 = 0 |
| 103 | const HC_R_Y: i64 = 1 |
| 104 | const HC_R_W: i64 = 2 |
| 105 | const HC_R_H: i64 = 3 |
| 106 | const HC_R_WEIGHT: i64 = 4 |
| 107 | const HC_F_N: i64 = 0 |
| 108 | const HC_F_RECTS: i64 = 1 |
| 109 | const HC_FEAT_FIELDS: i64 = 16 |
| 110 | const HC_Q16: i64 = 65536 |
| 111 | const HC_Q16_HALF: i64 = 32768 |
| 112 | const HC_Q24: i64 = 16777216 |
| 113 | const HC_NORM_INSET: i64 = 1 |
| 114 | const HC_PERMIL: i64 = 1000 |
| 115 | const HC_DET_FIELDS: i64 = 4 |
| 116 | const HC_GRP_FIELDS: i64 = 5 |
| 117 | const HC_G_X: i64 = 0 |
| 118 | const HC_G_Y: i64 = 1 |
| 119 | const HC_G_W: i64 = 2 |
| 120 | const HC_G_H: i64 = 3 |
| 121 | const HC_G_VOTES: i64 = 4 |
| 122 | const HC_I64: i64 = 8 |
functions
| 29 | func nx_weak_eval(ii: *IntegralImage, weak: *i64) -> i64 |
| 37 | func nx_stage_eval(ii: *IntegralImage, weaks: *i64, n: i64, stage_thresh: i64) -> i64 |
| 50 | func nx_haar_cascade_eval(ii: *IntegralImage, stages: *i64, n_stages: i64, weaks: *i64) -> i64 |
| 124 | func hc_abs(v: i64) -> i64 { if v < 0 { return 0 - v } return v } called by 1: hc_group |
| 125 | func hc_min(a: i64, b: i64) -> i64 { if a < b { return a } return b } called by 1: hc_group |
| 126 | func hc_round_q16(v: i64, s_q16: i64) -> i64 { return (v * s_q16 + HC_Q16_HALF) / HC_Q16 } |
| 127 | func hc_isqrt(v: i64) -> i64 called by 1: hc_window_norm |
| 135 | func hc_scale_features(c: *HaarCascade, s_q16: i64, out: *i64) -> i64 |
| 165 | func hc_feature(sf: *i64, f: i64, ii: *IntegralImage, x: i64, y: i64) -> i64 |
| 180 | func hc_window_norm(c: *HaarCascade, ii: *IntegralImage, sq: *IntegralImage, s_q16: i64, x: i64, y: i64) -> i64 |
| 196 | func hc_eval_window(c: *HaarCascade, sf: *i64, ii: *IntegralImage, sq: *IntegralImage, s_q16: i64, x: i64, y: i64) -> i64 |
| 225 | func hc_detect(c: *HaarCascade, ii: *IntegralImage, sq: *IntegralImage, rx0: i64, ry0: i64, rx1: i64, ry1: i64, |
| 270 | func hc_group(dets: *i64, n: i64, min_neighbors: i64, eps_permil: i64, groups: *i64, gcap: i64) -> i64 |
| 324 | func hc_best_group(groups: *i64, ng: i64) -> i64 |