UNPKG

mediapipe-pose-smooth

Version:

This will remove the jitter and smooth the landmarks given by Mediapipe

3 lines (2 loc) 824 B
var n=[],r=[],t=function(t,e){if(t.poseLandmarks&&n.push(t.poseLandmarks),8===n.length){for(var u=function(t){var e=n.map(function(n){return n[t].x}),u=n.map(function(n){return n[t].y}),i=n.map(function(n){return n[t].z}),o=n.map(function(n){return n[t].visibility});e=e.sort(function(n,r){return n-r}),u=u.sort(function(n,r){return n-r}),i=i.sort(function(n,r){return n-r}),o=o.sort(function(n,r){return n-r}),e=e.slice(2,6),u=u.slice(2,6),i=i.slice(2,6),o=o.slice(2,6),r[t]={x:e.reduce(function(n,r){return n+r},0)/e.length,y:u.reduce(function(n,r){return n+r},0)/u.length,z:i.reduce(function(n,r){return n+r},0)/i.length,visibility:o.reduce(function(n,r){return n+r},0)/o.length}},i=0;i<33;i++)u(i);n.shift()}return r.length>0&&(t.poseLandmarks=r),e?e(t):t};export{t as default}; //# sourceMappingURL=index.module.js.map