UNPKG

mediapipe-pose-smooth

Version:

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

3 lines (2 loc) 613 B
const e=[],s=[],t=(t,l)=>{if(t.poseLandmarks&&e.push(t.poseLandmarks),8===e.length){for(let t=0;t<33;t++){let l=e.map(e=>e[t].x),r=e.map(e=>e[t].y),i=e.map(e=>e[t].z),a=e.map(e=>e[t].visibility);l=l.sort((e,s)=>e-s),r=r.sort((e,s)=>e-s),i=i.sort((e,s)=>e-s),a=a.sort((e,s)=>e-s),l=l.slice(2,6),r=r.slice(2,6),i=i.slice(2,6),a=a.slice(2,6),s[t]={x:l.reduce((e,s)=>e+s,0)/l.length,y:r.reduce((e,s)=>e+s,0)/r.length,z:i.reduce((e,s)=>e+s,0)/i.length,visibility:a.reduce((e,s)=>e+s,0)/a.length}}e.shift()}return s.length>0&&(t.poseLandmarks=s),l?l(t):t};export{t as default}; //# sourceMappingURL=index.modern.js.map