nx_eye_detect.nx
buildroot/runtime/nx_eye_detect.nx
about
nx_eye_detect.nx -- iris/eye-pair detection wrapping nx_geom_hough_circle_r.
This is the KEYSTONE primitive. Once eye_width_px is measured, every
other anatomical axis is a Q10 ratio from it via nx_canon_proportions.
Pipeline:
1. Caller crops to face bbox (already from nx_region_segment).
2. Caller computes sobel_x + sobel_y + edge mask.
3. nx_eye_detect_iris_pair() sweeps candidate iris radii,
collects circles, pairs the best two within upper-half of face.
4. Output: flat-array result (no struct pointer return -> avoids
nxc2 codegen bug).
Result layout (i64):
result[0] = eye_count (0, 1, or 2)
result[1] = eye_width_px (palpebral fissure ≈ 5 * iris_radius)
result[2] = iris_radius_px (the raw Hough measurement)
result[3] = left_eye_cx (in face-bbox coords)
result[4] = left_eye_cy
result[5] = left_eye_iris_r
result[6] = right_eye_cx
result[7] = right_eye_cy
result[8] = right_eye_iris_r
result[9] = pair_quality_q10 (1024 = perfect horizontal alignment + matched radius)
Constants:
- iris radius range tries 3..16 px (typical iris in face crop)
- palpebral fissure ≈ 5 × iris_radius_px (Loomis canon: eye width = unit)
nx_safety_envelope:
intended_use: "Eye detection / iris localization -- input
primitive for the anatomy-as-proportions
substrate per cardinal feedback-eye-as-
keystone-anatomy-as-proportions"
sil_target: SIL1
asil_target: QM
dal_target: NONE
evidence: [Loomis_anatomy_canon_basis,
integer_pixel_arithmetic,
sealed_verdict_enum]
dependencies 3 imports · 1 importers
imports: nx_syscalls.nxnx_image.nxnx_geom.nx
imported by: nx_eye_detect_test.nx
structs
| none |
consts
| 52 | const NX_MAGIC_1024: i64 = 1024 |
| 54 | const NX_EYE_RES_COUNT: i64 = 0 |
| 55 | const NX_EYE_RES_WIDTH_PX: i64 = 1 |
| 56 | const NX_EYE_RES_IRIS_R: i64 = 2 |
| 57 | const NX_EYE_RES_L_CX: i64 = 3 |
| 58 | const NX_EYE_RES_L_CY: i64 = 4 |
| 59 | const NX_EYE_RES_L_R: i64 = 5 |
| 60 | const NX_EYE_RES_R_CX: i64 = 6 |
| 61 | const NX_EYE_RES_R_CY: i64 = 7 |
| 62 | const NX_EYE_RES_R_R: i64 = 8 |
| 63 | const NX_EYE_RES_PAIR_QUALITY: i64 = 9 |
| 64 | const NX_EYE_RES_FIELDS: i64 = 10 |
| 67 | const NX_EYE_PALPEBRAL_MULT: i64 = 5 |
| 70 | const NX_EYE_Y_VERT_TOL_PX: i64 = 6 // two eyes within 6 vertical px |
| 71 | const NX_EYE_R_DELTA_TOL: i64 = 3 // iris radii must match within 3 px |
| 72 | const NX_EYE_MIN_X_SEP: i64 = 8 // eyes at least 8 px apart horizontally |
functions
| 75 | func nx_eye_pair_quality_q10(l_cx: i64, l_cy: i64, l_r: i64, called by 1: nx_eye_detect |
| 98 | func nx_eye_collect_radius(edge: *Image, gx: *ImageS64, gy: *ImageS64, |
| 130 | func nx_eye_filter_upper_half(candidates: *i64, count: i64, called by 1: nx_eye_detect |
| 165 | func nx_eye_detect(edge: *Image, gx: *ImageS64, gy: *ImageS64, |