code wiki / (root) / nx_haar_cascade.nx

nx_haar_cascade.nx

buildroot/runtime/nx_haar_cascade.nx

13538 B330 linesdepth 7pulls 8 transitivereach 23 importersview sourcekind librarytopic haar
docsdependenciesstructsconstsfunctions

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

syscalls.nx nx_image.nx nx_integral.nx nx_haar.nx nx_haar_cascade.nx nx_facefind_lib.nx nx_haar_cascade_gate.nx nx_haar_xml.nx

imports: syscalls.nxnx_image.nxnx_integral.nxnx_haar.nx

imported by: nx_facefind_lib.nxnx_haar_cascade_gate.nxnx_haar_xml.nx

structs

68struct HaarCascade

consts

24const NX_WEAK_FIELDS: i64 = 8
25const NX_STAGE_FIELDS: i64 = 3
76const HC_BYTES: i64 = 48
77const HC_HDR_N: i64 = 8
78const HC_H_WINW: i64 = 0
79const HC_H_WINH: i64 = 1
80const HC_H_NSTAGES: i64 = 2
81const HC_H_NWEAK: i64 = 3
82const HC_H_NNODES: i64 = 4
83const HC_H_NLEAVES: i64 = 5
84const HC_H_NFEATS: i64 = 6
85const HC_H_MAXRECTS: i64 = 7
86const HC_STAGE_FIELDS: i64 = 3
87const HC_S_FIRST: i64 = 0
88const HC_S_N: i64 = 1
89const HC_S_THR: i64 = 2
90const HC_WEAK_FIELDS: i64 = 4
91const HC_W_FIRST_NODE: i64 = 0
92const HC_W_N_NODES: i64 = 1
93const HC_W_FIRST_LEAF: i64 = 2
94const HC_W_N_LEAVES: i64 = 3
95const HC_NODE_FIELDS: i64 = 4
96const HC_N_LEFT: i64 = 0
97const HC_N_RIGHT: i64 = 1
98const HC_N_FEAT: i64 = 2
99const HC_N_THR: i64 = 3
100const HC_MAX_RECTS: i64 = 3
101const HC_RECT_FIELDS: i64 = 5
102const HC_R_X: i64 = 0
103const HC_R_Y: i64 = 1
104const HC_R_W: i64 = 2
105const HC_R_H: i64 = 3
106const HC_R_WEIGHT: i64 = 4
107const HC_F_N: i64 = 0
108const HC_F_RECTS: i64 = 1
109const HC_FEAT_FIELDS: i64 = 16
110const HC_Q16: i64 = 65536
111const HC_Q16_HALF: i64 = 32768
112const HC_Q24: i64 = 16777216
113const HC_NORM_INSET: i64 = 1
114const HC_PERMIL: i64 = 1000
115const HC_DET_FIELDS: i64 = 4
116const HC_GRP_FIELDS: i64 = 5
117const HC_G_X: i64 = 0
118const HC_G_Y: i64 = 1
119const HC_G_W: i64 = 2
120const HC_G_H: i64 = 3
121const HC_G_VOTES: i64 = 4
122const HC_I64: i64 = 8

functions

29func nx_weak_eval(ii: *IntegralImage, weak: *i64) -> i64
called by 1: nx_stage_eval calls 1: nx_haar_eval
37func nx_stage_eval(ii: *IntegralImage, weaks: *i64, n: i64, stage_thresh: i64) -> i64
50func nx_haar_cascade_eval(ii: *IntegralImage, stages: *i64, n_stages: i64, weaks: *i64) -> i64
called by 1: main calls 1: nx_stage_eval
124func hc_abs(v: i64) -> i64 { if v < 0 { return 0 - v } return v }
called by 1: hc_group
125func hc_min(a: i64, b: i64) -> i64 { if a < b { return a } return b }
called by 1: hc_group
126func hc_round_q16(v: i64, s_q16: i64) -> i64 { return (v * s_q16 + HC_Q16_HALF) / HC_Q16 }
127func hc_isqrt(v: i64) -> i64
called by 1: hc_window_norm
135func hc_scale_features(c: *HaarCascade, s_q16: i64, out: *i64) -> i64
called by 1: hc_detect calls 1: hc_round_q16
165func hc_feature(sf: *i64, f: i64, ii: *IntegralImage, x: i64, y: i64) -> i64
called by 1: hc_eval_window calls 1: nx_integral_rect_sum
180func hc_window_norm(c: *HaarCascade, ii: *IntegralImage, sq: *IntegralImage, s_q16: i64, x: i64, y: i64) -> i64
196func hc_eval_window(c: *HaarCascade, sf: *i64, ii: *IntegralImage, sq: *IntegralImage, s_q16: i64, x: i64, y: i64) -> i64
called by 1: hc_detect calls 2: hc_window_normhc_feature
225func hc_detect(c: *HaarCascade, ii: *IntegralImage, sq: *IntegralImage, rx0: i64, ry0: i64, rx1: i64, ry1: i64,
270func hc_group(dets: *i64, n: i64, min_neighbors: i64, eps_permil: i64, groups: *i64, gcap: i64) -> i64
called by 2: ff_findff_eyes calls 2: hc_minhc_abs
324func hc_best_group(groups: *i64, ng: i64) -> i64