code wiki / (root) / nx_finger_count.nx

nx_finger_count.nx

buildroot/runtime/nx_finger_count.nx

9172 B267 linesdepth 3pulls 3 transitivereach 0 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

about

nx_finger_count.nx -- Tier 6 anatomical-coherence finger-counter. THE canonical generative-AI failure mode: six fingers per hand, or three, or seven, or two fingers fused into a paddle. Stable Diffusion / Flux / Midjourney / DALL-E all produce this with alarming frequency because they have no anatomical prior. Substrate's bits-up answer: count fingers DETERMINISTICALLY via horizontal scan-line crossings on a binary hand mask. Method: Input: binary hand mask (0 = bg, 1 = hand), w x h, plus a scan_y row index that cuts horizontally THROUGH the fingers (above the palm, below the fingertips). Caller determines scan_y from hand-orientation upstream. For x = 0..w-1: track run-length of consecutive 1 pixels along scan_y. Each contiguous run >= min_run_width is one finger. verdict by run count vs anatomical norm (5 per hand): 5 -> OK 6+ -> EXTRA (the famous AI failure) 4 -> MISSING (or fused) 3 or less -> FUSED / OCCLUSION NOISE detected (many tiny runs) -> NOISY Caller responsibility: provide a HAND-segmented binary mask + a VALID scan_y. Substrate provides the deterministic counter. Reference: Suk/Park 2010 "Hand gesture recognition based on digital image processing using MATLAB" -- scan-line approach for finger counting in segmented hand regions. Convex-hull-defect approach (Hawley/Eichmann 2014) is more robust to fingertip occlusion; queued for nx_finger_count_v2. genealogy_id: suk_park_2010_scanline lineage_id: substrate_anatomy_coherence_v1

dependencies 3 imports · 0 importers

nx_syscalls.nx nx_runtime.nx nx_tier.nx nx_finger_count.nx

imports: nx_syscalls.nxnx_runtime.nxnx_tier.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main sys_mmap _fc_zero_row _fc_set_run nx_finger_count_scanline sys_mmap ↻

structs

66struct NxFingerCountResult

consts

48const NX_FC_VERDICT_OK: nx_int = 0
49const NX_FC_VERDICT_EXTRA: nx_int = 1
50const NX_FC_VERDICT_MISSING: nx_int = 2
51const NX_FC_VERDICT_FUSED: nx_int = 3
52const NX_FC_VERDICT_NOISY: nx_int = 4
55const NX_FC_EXPECTED_FINGERS: nx_int = 5
58const NX_FC_DEFAULT_MIN_RUN: nx_int = 3
59const NX_FC_MAX_RUN_THR: nx_int = 1024
60const NX_FC_NOISE_RUN_LIMIT: nx_int = 16 // > this many tiny runs -> NOISY
62const NX_FC_MAX_DIM: nx_int = 16384
77const NX_FC_RESULT_BYTES: nx_size = 64

functions

81func nx_finger_count_scanline(
called by 1: main calls 1: sys_mmap
169func _fc_set_run(mask: *nx_int, x0: nx_int, n: nx_int) -> nx_int
called by 1: main
178func _fc_zero_row(mask: *nx_int, w: nx_int) -> nx_int
called by 1: main
187func main() -> nx_int