nx_finger_count.nx
buildroot/runtime/nx_finger_count.nx
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
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
structs
| 66 | struct NxFingerCountResult |
consts
| 48 | const NX_FC_VERDICT_OK: nx_int = 0 |
| 49 | const NX_FC_VERDICT_EXTRA: nx_int = 1 |
| 50 | const NX_FC_VERDICT_MISSING: nx_int = 2 |
| 51 | const NX_FC_VERDICT_FUSED: nx_int = 3 |
| 52 | const NX_FC_VERDICT_NOISY: nx_int = 4 |
| 55 | const NX_FC_EXPECTED_FINGERS: nx_int = 5 |
| 58 | const NX_FC_DEFAULT_MIN_RUN: nx_int = 3 |
| 59 | const NX_FC_MAX_RUN_THR: nx_int = 1024 |
| 60 | const NX_FC_NOISE_RUN_LIMIT: nx_int = 16 // > this many tiny runs -> NOISY |
| 62 | const NX_FC_MAX_DIM: nx_int = 16384 |
| 77 | const NX_FC_RESULT_BYTES: nx_size = 64 |
functions
| 81 | func nx_finger_count_scanline( |
| 169 | func _fc_set_run(mask: *nx_int, x0: nx_int, n: nx_int) -> nx_int called by 1: main |
| 178 | func _fc_zero_row(mask: *nx_int, w: nx_int) -> nx_int called by 1: main |
| 187 | func main() -> nx_int |