nx_lower_anatomy_test.nx source
↩ module page · 123 lines · 5161 B
1import "nx_syscalls.nx"
2import "nx_image.nx"
3import "nx_perineum_distance.nx"
4import "nx_thigh_proportion.nx"
5import "nx_vulva_innie_outie.nx"
6
7func paint_rect(rgb: *Image, x0: i64, y0: i64, x1: i64, y1: i64,
8 r: i64, g: i64, b: i64) -> i64 {
9 var y: i64 = y0
10 while y < y1 {
11 var x: i64 = x0
12 while x < x1 {
13 if x >= 0 { if x < rgb.width { if y >= 0 { if y < rgb.height {
14 nx_image_set(rgb, x, y, 0, r)
15 nx_image_set(rgb, x, y, 1, g)
16 nx_image_set(rgb, x, y, 2, b)
17 } } } }
18 x = x + 1
19 }
20 y = y + 1
21 }
22 return 0
23}
24
25func paint_mask_rect(mask: *Image, x0: i64, y0: i64, x1: i64, y1: i64) -> i64 {
26 var y: i64 = y0
27 while y < y1 {
28 var x: i64 = x0
29 while x < x1 {
30 if x >= 0 { if x < mask.width { if y >= 0 { if y < mask.height {
31 nx_image_set(mask, x, y, 0, 255)
32 } } } }
33 x = x + 1
34 }
35 y = y + 1
36 }
37 return 0
38}
39
40func main() -> i64 {
41 let result: *i64 = (sys_mmap(8 * 8 + 16)) as *i64
42
43 // ==========================================================
44 // T1: nx_perineum_distance — canon perineum (0.4 face_w).
45 // face_width=100 → expected perineum_px ~40. Test 35.
46 // ==========================================================
47 nx_perineum_distance(200, 235, 100, result)
48 let v1: i64 = result[NX_PERIN_RES_VERDICT]
49 let r1: i64 = result[NX_PERIN_RES_RATIO_Q10]
50 if v1 != NX_PERIN_V_IN_CANON { return 1 }
51 if r1 < 256 { return 2 }
52 if r1 > 410 { return 3 }
53
54 // T2: TOO_SHORT perineum (15 px = 0.15 face_w).
55 nx_perineum_distance(200, 215, 100, result)
56 let v2: i64 = result[NX_PERIN_RES_VERDICT]
57 if v2 != NX_PERIN_V_TOO_SHORT { return 10 }
58
59 // T3: TOO_LONG perineum (90 px = 0.9 face_w).
60 nx_perineum_distance(200, 290, 100, result)
61 let v3: i64 = result[NX_PERIN_RES_VERDICT]
62 if v3 != NX_PERIN_V_TOO_LONG { return 20 }
63
64 // ==========================================================
65 // T4: nx_thigh_proportion — ATHLETIC + small gap.
66 // hip width 100, mid-thigh = 60 each, top gap = 3 px.
67 // ==========================================================
68 let mask: *Image = nx_image_alloc(300, 400, 1)
69 let bbox: *i64 = (sys_mmap(8 * 8 + 16)) as *i64
70 // Two thighs at mid-thigh (y=250): left 60 wide, right 60 wide,
71 // touching at midline.
72 paint_mask_rect(mask, 90, 250, 150, 251) // left thigh row at mid_y (width 60)
73 paint_mask_rect(mask, 150, 250, 210, 251) // right thigh row at mid_y (width 60)
74 // Top row (y=212) with small 3-px gap: left thigh 90..148, right 152..210.
75 paint_mask_rect(mask, 90, 212, 149, 213)
76 paint_mask_rect(mask, 152, 212, 210, 213)
77 // bbox layout: hip band, thigh band
78 bbox[0] = 90; bbox[1] = 190; bbox[2] = 210; bbox[3] = 200
79 bbox[4] = 90; bbox[5] = 200; bbox[6] = 210; bbox[7] = 300 // thigh band 100 tall, mid=250
80 nx_thigh_proportion(mask, bbox, 120, result)
81 let tv: i64 = result[NX_THIGH_RES_THICK_VRDT]
82 let tg: i64 = result[NX_THIGH_RES_GAP_VRDT]
83 let tw: i64 = result[NX_THIGH_RES_THICK_PX]
84 if tw < 50 { return 30 } // should be ~60
85 if tw > 70 { return 31 }
86 // Thickness 60 / hip 120 = 0.5 (slim)
87 if tv != NX_THIGH_V_SLIM { return 32 }
88 // Gap 3 px / hip 120 = 0.025 (small_gap)
89 if tg != NX_THIGH_GAP_SMALL { return 33 }
90
91 // ==========================================================
92 // T5: nx_vulva_innie_outie — INNIE (minora tucked, low protrusion).
93 // Vulva bbox 100x60 centered. Inner labia near midline only.
94 // ==========================================================
95 let rgb: *Image = nx_image_alloc(200, 200, 3)
96 // Outer perimeter R=180 (lighter pink).
97 paint_rect(rgb, 80, 70, 180, 130, 180, 130, 120)
98 // Inner labia: small dark-pink central strip (R=210) from midline ±5.
99 paint_rect(rgb, 125, 80, 135, 120, 210, 130, 120)
100 let vbbox: *i64 = (sys_mmap(4 * 8 + 16)) as *i64
101 vbbox[0] = 80; vbbox[1] = 70; vbbox[2] = 179; vbbox[3] = 129
102 nx_vulva_innie_outie(rgb, vbbox, result)
103 let iv: i64 = result[NX_INNIE_RES_VERDICT]
104 let pq: i64 = result[NX_INNIE_RES_PROT_Q10]
105 // half_w = 50, extent ~5 → q10 ~102. Should be DEEP_INNIE or INNIE.
106 if iv != NX_INNIE_V_DEEP_INNIE { if iv != NX_INNIE_V_INNIE { return 40 } }
107 if pq > 256 { return 41 }
108
109 // ==========================================================
110 // T6: nx_vulva_innie_outie — PROMINENT_OUTIE (minora extends widely).
111 // ==========================================================
112 paint_rect(rgb, 80, 70, 180, 130, 180, 130, 120)
113 // Inner labia extends nearly to outer edge.
114 paint_rect(rgb, 95, 80, 165, 120, 210, 130, 120)
115 nx_vulva_innie_outie(rgb, vbbox, result)
116 let iv2: i64 = result[NX_INNIE_RES_VERDICT]
117 let pq2: i64 = result[NX_INNIE_RES_PROT_Q10]
118 // Extent ~30, half_w ~50 → q10 ~614. Should be OUTIE or PROMINENT_OUTIE.
119 if iv2 != NX_INNIE_V_OUTIE { if iv2 != NX_INNIE_V_PROMINENT_OUTIE { return 50 } }
120 if pq2 < 410 { return 51 }
121
122 return 0
123}