nx_photomark_gate.nx
buildroot/runtime/nx_photomark_gate.nx
about
nx_photomark_gate.nx -- the referee for nx_photomark_lib (aesthetictwin AT4 / AT23, 2026-09-16). In-process on a synthetic
frontal face (no network, no decoder, no real card): a skin ellipse on a non-skin non-dark field, two dark lens-shaped eyes
whose canthi are PLANTED with ASYMMETRIC tilts (right 85, left 57 deg10), a red mouth with a dark stomion line splitting it
10 over 14. The ruler must find the face box, both eye pairs of canthi within pixels, both tilts within tolerance with the
asymmetry preserved, the two canon ratios the planted geometry implies, the stomion row and the lip ratio; a field with no
face is UNMEASURED, a face without eyes is UNMEASURED, and a MIRRORED fixture swaps the sides while each tilt keeps its
sign. The card write appends five measured rows once and refuses the second time. The file door (AT33): the same fixture
encoded through the sovereign PNG writer and read back through pm_landmarks_file_auto must reproduce the in-process
numbers exactly and announce the PNG codec; a non-image file is a named decode refusal and an absent file is unreadable.
AT44 (2026-09-18): the mouth's five landmarks on the planted lines; DECOYS that must not move them (a black chin fold wider and
darker than the seam, a shadow redder than the lip between them); a mouth with no seam and a seam shorter than a lip refused by
name; a one-pixel lash wing followed to its tip past the blob with a decoy dot one pixel beyond the fissure's bridge left alone;
a fissure run onto its window's side refused as PINNED; the referee scoring the planted mouth (ruler and anchored) FOUND and a
mouth shifted 40 px PLACED-OFF. Each of these teeth was bitten by a mutant of the lib (see the board's AT44 log).
Values are printed with gv_kv.
license_tier: ORIGINAL No hw writes (Rule 26).
dependencies 4 imports · 0 importers
imports: nx_syscalls.nxnx_gate_verdict.nxnx_photomark_lib.nxnx_png.nx
imported by: nobody (leaf or entry point)
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| 22 | const PG_W: i64 = 240 |
| 23 | const PG_H: i64 = 300 |
| 24 | const PG_BG_R: i64 = 120 |
| 25 | const PG_BG_G: i64 = 140 |
| 26 | const PG_BG_B: i64 = 200 |
| 27 | const PG_SKIN_R: i64 = 200 |
| 28 | const PG_SKIN_G: i64 = 150 |
| 29 | const PG_SKIN_B: i64 = 120 |
| 30 | const PG_FACE_CX: i64 = 120 |
| 31 | const PG_FACE_CY: i64 = 150 |
| 32 | const PG_FACE_RX: i64 = 80 |
| 33 | const PG_FACE_RY: i64 = 110 |
| 34 | const PG_EYE_DARK: i64 = 20 |
| 35 | const PG_RLAT_X: i64 = 65 |
| 36 | const PG_RLAT_Y: i64 = 116 |
| 37 | const PG_RMED_X: i64 = 105 |
| 38 | const PG_RMED_Y: i64 = 122 |
| 39 | const PG_LMED_X: i64 = 135 |
| 40 | const PG_LMED_Y: i64 = 122 |
| 41 | const PG_LLAT_X: i64 = 175 |
| 42 | const PG_LLAT_Y: i64 = 118 |
| 43 | const PG_EYE_HALF_H: i64 = 7 |
| 44 | const PG_EXP_TILT_R: i64 = 85 |
| 45 | const PG_EXP_TILT_L: i64 = 57 |
| 46 | const PG_TOL_TILT: i64 = 20 |
| 47 | const PG_TOL_PX: i64 = 4 |
| 48 | const PG_TOL_BOX: i64 = 6 |
| 49 | const PG_MOUTH_CX: i64 = 120 |
| 50 | const PG_MOUTH_CY: i64 = 205 |
| 51 | const PG_MOUTH_RX: i64 = 28 |
| 52 | const PG_MOUTH_RY: i64 = 12 |
| 53 | const PG_LIP_R: i64 = 190 |
| 54 | const PG_LIP_G: i64 = 80 |
| 55 | const PG_LIP_B: i64 = 90 |
| 56 | const PG_STOMION_Y: i64 = 203 |
| 57 | const PG_STOMION_ROWS: i64 = 2 |
| 58 | const PG_TOL_STOMION: i64 = 2 |
| 59 | const PG_EXP_LIP: i64 = 714 // 10 over 14 to the stomion row; since AT44 each lip runs to its own inner edge (10 over 13 = 769, within tolerance) |
| 60 | const PG_TOL_LIP: i64 = 120 |
| 61 | const PG_EXP_ICI: i64 = 272 |
| 62 | const PG_TOL_ICI: i64 = 40 |
| 63 | const PG_EXP_ICF: i64 = 744 |
| 64 | const PG_TOL_ICF: i64 = 70 |
| 65 | const PG_BPP: i64 = 3 |
| 66 | const PG_I64: i64 = 8 |
| 67 | const PG_PERMIL: i64 = 1000 |
| 68 | const PG_CARD_ROWS: i64 = 5 |
| 69 | const PG_DIR: *u8 = "/tmp/photomark_gate" |
| 70 | const PG_KDIR: *u8 = "/tmp/photomark_gate/knowledge" |
| 71 | const PG_CARD_DIR: *u8 = "/tmp/photomark_gate/knowledge/twincard" |
| 72 | const PG_CARD_BARE: *u8 = "/tmp/photomark_gate/knowledge/twincard/fy.card" |
| 73 | const PG_PNG_PATH: *u8 = "/tmp/photomark_gate/fixture_face.png" |
| 74 | const PG_JUNK_PATH: *u8 = "/tmp/photomark_gate/not_an_image.txt" |
| 75 | const PG_JUNK_TEXT: *u8 = "this is prose, not a still: neither the PNG signature nor a JPEG marker opens it\n" |
| 76 | const PG_ABSENT_PATH: *u8 = "/tmp/photomark_gate/absent/nothing.png" |
| 77 | const PG_SHIFT_G: i64 = 8 |
| 78 | const PG_SHIFT_B: i64 = 16 |
| 81 | const PG_DIR_SLASH: *u8 = "/tmp/photomark_gate/" |
| 82 | const PG_ORACLE_PATH: *u8 = "/tmp/photomark_gate/fixture.oracle" |
| 83 | const PG_ORACLE_SHIFT_PATH: *u8 = "/tmp/photomark_gate/fixture_shifted.oracle" |
| 84 | const PG_ORACLE_ABSENT_PATH: *u8 = "/tmp/photomark_gate/absent/none.oracle" |
| 85 | const PG_ROW_CAP: i64 = 512 |
| 86 | const PG_X10: i64 = 10 |
| 87 | const PG_ORACLE_ZERO_XY: i64 = 11 |
| 88 | const PG_LIP_DECOY_X: i64 = 3 |
| 89 | const PG_ORACLE_SHIFT_PX: i64 = 30 |
| 90 | const PG_DIAG_PERMIL_OF_TOL: i64 = 1500 |
| 91 | const PG_CARD_BARE_TEXT: *u8 = "card|fy|Fixture Bare|2026-09-16|fixture\n" |
| 92 | const PG_MODE644: i64 = 420 |
| 93 | const PG_MODE755: i64 = 493 |
| 96 | const PG_LS_Y: i64 = 193 // PG_MOUTH_CY - PG_MOUTH_RY |
| 97 | const PG_LI_Y: i64 = 217 // PG_MOUTH_CY + PG_MOUTH_RY |
| 98 | const PG_CHR_X: i64 = 94 // PG_MOUTH_CX - PG_MOUTH_RX + 2: where the planted seam band starts |
| 99 | const PG_CHL_X: i64 = 146 // PG_MOUTH_CX + PG_MOUTH_RX - 2 |
| 100 | const PG_TOL_LIPLINE: i64 = 2 |
| 103 | const PG_FOLD_Y: i64 = 224 |
| 104 | const PG_FOLD_ROWS: i64 = 2 |
| 105 | const PG_FOLD_X0: i64 = 90 // wider than the seam (94..146), narrower than half the mouth window (1.8 eye spans), as a real fold |
| 106 | const PG_FOLD_X1: i64 = 150 |
| 107 | const PG_SHADOW_Y: i64 = 218 |
| 108 | const PG_SHADOW_ROWS: i64 = 4 |
| 109 | const PG_SHADOW_R: i64 = 150 |
| 110 | const PG_SHADOW_G: i64 = 40 |
| 111 | const PG_SHADOW_B: i64 = 60 |
| 112 | const PG_DARKEST: i64 = 0 |
| 114 | const PG_DASH_HALF: i64 = 5 |
| 118 | const PG_WING_LEN: i64 = 14 |
| 119 | const PG_WING_TIP_X: i64 = 51 // PG_RLAT_X - PG_WING_LEN |
| 120 | const PG_DOT_GAP: i64 = 3 |
| 121 | const PG_DOT_HALF: i64 = 1 |
| 122 | const PG_TOL_WING: i64 = 1 |
| 125 | const PG_WING_DARK: i64 = 60 |
| 127 | const PG_BAR_X0: i64 = 0 |
| 128 | const PG_REF_LIP_ORACLE_PATH: *u8 = "/tmp/photomark_gate/fixture_lips.oracle" |
| 129 | const PG_REF_LIP_SHIFT_PATH: *u8 = "/tmp/photomark_gate/fixture_lips_shifted.oracle" |
| 130 | const PG_LIP_SHIFT_PX: i64 = 40 |
| 131 | const PG_EXP_LIP_ORACLE: i64 = 769 // the planted mouth to each lip's own inner edge: (203 - 193) over (217 - 204) |
| 132 | const PG_ORACLE_LIP_XY: i64 = 6 // the lip points an oracle row carries before its iris, nose, chin and brow points |
| 135 | const PG_TOL_LIP_BORDERS: i64 = 136 |
functions
| 137 | func pg_abs(v: i64) -> i64 { if v < 0 { return 0 - v } return v } |
| 138 | func pg_set(rgb: *u8, w: i64, x: i64, y: i64, r: i64, g: i64, b: i64) -> i64 |
| 145 | func pg_fill(rgb: *u8, w: i64, h: i64, r: i64, g: i64, b: i64) -> i64 |
| 150 | func pg_ellipse(rgb: *u8, w: i64, h: i64, cx: i64, cy: i64, rx: i64, ry: i64, r: i64, g: i64, b: i64) -> i64 |
| 167 | func pg_lens(rgb: *u8, w: i64, h: i64, x0: i64, y0: i64, x1: i64, y1: i64, halfh: i64, r: i64, g: i64, b: i64) -> i64 |
| 197 | func pg_hband(rgb: *u8, w: i64, x0: i64, x1: i64, y0: i64, rows: i64, r: i64, g: i64, b: i64) -> i64 |
| 202 | func pg_mirror(src: *u8, dst: *u8, w: i64, h: i64) -> i64 called by 1: main |
| 216 | func pg_face(rgb: *u8, eyes: i64, mouth: i64) -> i64 |
| 229 | func pg_write(path: *u8, text: *u8) -> i64 |
| 236 | func pg_near(a: i64, b: i64, tol: i64) -> i64 { if pg_abs(a - b) <= tol { return 1 } return 0 } |
| 238 | func pg_xy10(out: *u8, o: i64, x: i64, y: i64) -> i64 |
| 245 | func pg_oracle_row(out: *u8, shift: i64, exo: i64) -> i64 |
| 259 | func pg_rect(rgb: *u8, x0: i64, x1: i64, y0: i64, y1: i64, r: i64, g: i64, b: i64) -> i64 |
| 265 | func pg_mouth_decoys(rgb: *u8) -> i64 |
| 272 | func pg_seamless(rgb: *u8, dash: i64) -> i64 |
| 279 | func pg_wing(rgb: *u8) -> i64 |
| 288 | func pg_bar(rgb: *u8) -> i64 |
| 295 | func pg_oracle_row_lips(out: *u8, lshift: i64, exo: i64) -> i64 |
| 315 | func pg_pack_fb(rgb: *u8, w: i64, h: i64, fb: *i64) -> i64 called by 1: main |
| 326 | func main(argc: i64, argv: *i64) -> i64 |