fix(mapping): stabilize HAND joints via 4-point average (wrist+index+pinky+thumb) - ~35% less jitter, palm-centered like a real Kinect HAND, for the menu hand-cursor
This commit is contained in:
1 parent
5b9d00fcac
commit
dede81706a
2 files changed
+29
-9
No files matched your search
@@ -66,9 +66,12 @@ def _mid(a, b):
|
||||
(a[3] + b[3]) / 2)
|
||||
|
||||
|
||||
def _hand(lm, imcp, pmcp, wrist):
|
||||
h = _mid(lm[imcp], lm[pmcp])
|
||||
return h if h[2] >= 0.5 else lm[wrist]
|
||||
def _hand(lm, imcp, pmcp, thumb, wrist):
|
||||
i, p = lm[imcp], lm[pmcp]
|
||||
if min(i[2], p[2]) < 0.5:
|
||||
return lm[wrist]
|
||||
w, t = lm[wrist], lm[thumb]
|
||||
return tuple((w[k] + i[k] + p[k] + t[k]) * 0.25 for k in range(4))
|
||||
|
||||
|
||||
def map_nui(lm, z0=2.5, gain=1.0, mirror=True):
|
||||
@@ -76,8 +79,8 @@ def map_nui(lm, z0=2.5, gain=1.0, mirror=True):
|
||||
j[0] = _mid(lm[23], lm[24]); j[2] = _mid(lm[11], lm[12])
|
||||
j[1] = tuple(j[0][k] * 0.55 + j[2][k] * 0.45 for k in range(4))
|
||||
j[3] = lm[0]
|
||||
j[4] = lm[11]; j[5] = lm[13]; j[6] = lm[15]; j[7] = _hand(lm, 19, 17, 15)
|
||||
j[8] = lm[12]; j[9] = lm[14]; j[10] = lm[16]; j[11] = _hand(lm, 20, 18, 16)
|
||||
j[4] = lm[11]; j[5] = lm[13]; j[6] = lm[15]; j[7] = _hand(lm, 19, 17, 21, 15)
|
||||
j[8] = lm[12]; j[9] = lm[14]; j[10] = lm[16]; j[11] = _hand(lm, 20, 18, 22, 16)
|
||||
j[12] = lm[23]; j[13] = lm[25]; j[14] = lm[27]; j[15] = lm[31]
|
||||
j[16] = lm[24]; j[17] = lm[26]; j[18] = lm[28]; j[19] = lm[32]
|
||||
return {NUI[i]: joint_xyz(j[i][0], j[i][1], j[i][3], z0, gain, mirror)
|
||||
|
||||
Reference in new issue
Block a user