code wiki / (root) / nx_pck.nx

nx_pck.nx source

↩ module page · 23 lines · 1067 B

1// nx_pck.nx -- PCK (Percentage of Correct Keypoints): the "MEASURED" grading for build-2 -- our own sovereign pose 2// net vs the ViTPose reference (teacher). A predicted keypoint is CORRECT if within `thresh` pixels of the 3// reference; PCK@thresh = correct/N. Squared distance (no sqrt); integer pixel coords. This is what turns 4// "our net runs" into "our net scores X vs the reference" per the measured-exceed doctrine. license_tier: ORIGINAL 5import "nx_syscalls.nx" 6 7// count keypoints within sqrt(thresh_sq) pixels of the reference. 8func pck_count(px: *i64, py: *i64, gx: *i64, gy: *i64, n: i64, thresh_sq: i64) -> i64 { 9 var c: i64 = 0 10 var i: i64 = 0 11 while i < n { 12 let dx: i64 = px[i] - gx[i] 13 let dy: i64 = py[i] - gy[i] 14 if dx*dx + dy*dy <= thresh_sq { c = c + 1 } 15 i = i + 1 16 } 17 return c 18} 19// PCK in permille = correct*1000/N. 20func pck_permille(px: *i64, py: *i64, gx: *i64, gy: *i64, n: i64, thresh_sq: i64) -> i64 { 21 if n <= 0 { return 0 } 22 return (pck_count(px, py, gx, gy, n, thresh_sq) * 1000) / n 23}