diff --git a/dist/index.cjs b/dist/index.cjs index b83098b..e96eda6 100644 --- a/dist/index.cjs +++ b/dist/index.cjs @@ -1,2 +1,2 @@ -exports.awesomeFunction=function(){return"I am just an Awesome Function"},exports.default=function(e){return"I am the Default Awesome Function, fellow comrade! - "+e}; +var n=[],r=[];module.exports=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}; //# sourceMappingURL=index.cjs.map diff --git a/dist/index.cjs.map b/dist/index.cjs.map index 1f68860..282197d 100644 --- a/dist/index.cjs.map +++ b/dist/index.cjs.map @@ -1 +1 @@ -{"version":3,"file":"index.cjs","sources":["../src/index.js"],"sourcesContent":["const defaultAwesomeFunction = (name) => {\n const returnStr = `I am the Default Awesome Function, fellow comrade! - #[[\$]]#{name}`;\n return returnStr;\n};\n\nconst awesomeFunction = () => 'I am just an Awesome Function';\n\nexport default defaultAwesomeFunction;\n\nexport { awesomeFunction };\n"],"names":["name"],"mappings":"wBAKwB,WAAM,MAAA,+BAA+B,kBAL9B,SAACA,GAE9B,MAD0EA,wDAAAA,CAE5E"} \ No newline at end of file +{"version":3,"file":"index.cjs","sources":["../src/index.js"],"sourcesContent":["/**\n * This will remove the jitter and smooth the landmarks given by Mediapipe\n * @author Yousuf Kalim\n */\n\nlet frameSets = [];\nlet smoothFrame = [];\n\n/**\n * smoothLandmarks\n * @param {Object} results This should be coming directly from Mediapipe\n * @param {Function} onResults Optional: If you want to call other function instead of getting return\n * @returns {Void}\n */\nconst smoothLandmarks = (results, onResults) => {\n // Pushing frame at the end of frameSet array\n if (results.poseLandmarks) {\n frameSets.push(results.poseLandmarks);\n }\n\n if (frameSets.length === 8) {\n // This loop will run 33 time to make average of each joint\n for (let i = 0; i < 33; i++) {\n // Making an array of each joint coordinates\n let x = frameSets.map((a) => a[i].x);\n let y = frameSets.map((a) => a[i].y);\n let z = frameSets.map((a) => a[i].z);\n let visibility = frameSets.map((a) => a[i].visibility);\n\n // Sorting the array into ascending order\n x = x.sort((a, b) => a - b);\n y = y.sort((a, b) => a - b);\n z = z.sort((a, b) => a - b);\n visibility = visibility.sort((a, b) => a - b);\n\n // Dropping 2 min and 2 max coordinates\n x = x.slice(2, 6);\n y = y.slice(2, 6);\n z = z.slice(2, 6);\n visibility = visibility.slice(2, 6);\n\n // Making the average of 4 remaining coordinates\n smoothFrame[i] = {\n x: x.reduce((a, b) => a + b, 0) / x.length,\n y: y.reduce((a, b) => a + b, 0) / y.length,\n z: z.reduce((a, b) => a + b, 0) / z.length,\n visibility: visibility.reduce((a, b) => a + b, 0) / visibility.length,\n };\n }\n\n // Removing the first frame from frameSet\n frameSets.shift();\n }\n\n // after first 8 frames we have averaged coordinates, So now updating the poseLandmarks with averaged coordinates\n if (smoothFrame.length > 0) {\n results.poseLandmarks = smoothFrame;\n }\n\n return onResults ? onResults(results) : results;\n};\n\nexport default smoothLandmarks;\n"],"names":["smoothFrame","results","onResults","poseLandmarks","frameSets","push","length","i","map","a","x","y","z","visibility","sort","b","slice","reduce","_loop","shift"],"mappings":"AAKA,MAAgB,GACZA,EAAc,kBAQM,SAACC,EAASC,GAMhC,GAJID,EAAQE,eACVC,EAAUC,KAAKJ,EAAQE,eAGA,IAArBC,EAAUE,OAAc,CAE1B,IAASC,IAAAA,EAAAA,SAAAA,GAEP,MAAQH,EAAUI,IAAI,SAACC,GAAC,SAAOF,GAAGG,CAAC,KAC3BN,EAAUI,IAAI,SAACC,GAAC,SAAOF,GAAGI,CAAC,KAC3BP,EAAUI,IAAI,SAACC,GAAC,OAAMA,EAACF,GAAGK,CAAC,GACrBC,EAAGT,EAAUI,IAAI,SAACC,UAAOA,EAACF,GAAGM,UAAU,GAGrDH,EAAIA,EAAEI,KAAK,SAACL,EAAGM,GAAC,SAASA,CAAC,GAC1BJ,EAAIA,EAAEG,KAAK,SAACL,EAAGM,GAAMN,OAAAA,EAAIM,CAAC,GAC1BH,EAAIA,EAAEE,KAAK,SAACL,EAAGM,GAAC,SAASA,CAAC,GAC1BF,EAAaA,EAAWC,KAAK,SAACL,EAAGM,UAAON,EAAGM,CAAC,GAG5CL,EAAIA,EAAEM,MAAM,EAAG,GACfL,EAAIA,EAAEK,MAAM,EAAG,GACfJ,EAAIA,EAAEI,MAAM,EAAG,GACfH,EAAaA,EAAWG,MAAM,EAAG,GAGjChB,EAAYO,GAAK,CACfG,EAAGA,EAAEO,OAAO,SAACR,EAAGM,UAAON,EAAGM,CAAC,EAAE,GAAKL,EAAEJ,OACpCK,EAAGA,EAAEM,OAAO,SAACR,EAAGM,GAAMN,OAAAA,EAAIM,CAAC,EAAE,GAAKJ,EAAEL,OACpCM,EAAGA,EAAEK,OAAO,SAACR,EAAGM,UAAON,EAAGM,CAAC,EAAE,GAAKH,EAAEN,OACpCO,WAAYA,EAAWI,OAAO,SAACR,EAAGM,GAAC,SAASA,CAAC,EAAE,GAAKF,EAAWP,OAC/D,EAzBKC,EAAI,EAAGA,EAAI,GAAIA,IAAKW,EAApBX,GA6BTH,EAAUe,OACZ,CAOA,OAJInB,EAAYM,OAAS,IACvBL,EAAQE,cAAgBH,GAGnBE,EAAYA,EAAUD,GAAWA,CAC1C"} \ No newline at end of file diff --git a/dist/index.modern.js b/dist/index.modern.js index a1ded2f..2ca3137 100644 --- a/dist/index.modern.js +++ b/dist/index.modern.js @@ -1,2 +1,2 @@ -const e=e=>`I am the Default Awesome Function, fellow comrade! - ${e}`,o=()=>"I am just an Awesome Function";export{o as awesomeFunction,e as default}; +let e=[],s=[];const 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 diff --git a/dist/index.modern.js.map b/dist/index.modern.js.map index 21545ba..21de0db 100644 --- a/dist/index.modern.js.map +++ b/dist/index.modern.js.map @@ -1 +1 @@ -{"version":3,"file":"index.modern.js","sources":["../src/index.js"],"sourcesContent":["const defaultAwesomeFunction = (name) => {\n const returnStr = `I am the Default Awesome Function, fellow comrade! - ${name}`;\n return returnStr;\n};\n\nconst awesomeFunction = () => 'I am just an Awesome Function';\n\nexport default defaultAwesomeFunction;\n\nexport { awesomeFunction };\n"],"names":["defaultAwesomeFunction","name","awesomeFunction"],"mappings":"AAAMA,MAAAA,EAA0BC,GACX,wDAAuDA,IAItEC,EAAkB,IAAM"} \ No newline at end of file +{"version":3,"file":"index.modern.js","sources":["../src/index.js"],"sourcesContent":["/**\n * This will remove the jitter and smooth the landmarks given by Mediapipe\n * @author Yousuf Kalim\n */\n\nlet frameSets = [];\nlet smoothFrame = [];\n\n/**\n * smoothLandmarks\n * @param {Object} results This should be coming directly from Mediapipe\n * @param {Function} onResults Optional: If you want to call other function instead of getting return\n * @returns {Void}\n */\nconst smoothLandmarks = (results, onResults) => {\n // Pushing frame at the end of frameSet array\n if (results.poseLandmarks) {\n frameSets.push(results.poseLandmarks);\n }\n\n if (frameSets.length === 8) {\n // This loop will run 33 time to make average of each joint\n for (let i = 0; i < 33; i++) {\n // Making an array of each joint coordinates\n let x = frameSets.map((a) => a[i].x);\n let y = frameSets.map((a) => a[i].y);\n let z = frameSets.map((a) => a[i].z);\n let visibility = frameSets.map((a) => a[i].visibility);\n\n // Sorting the array into ascending order\n x = x.sort((a, b) => a - b);\n y = y.sort((a, b) => a - b);\n z = z.sort((a, b) => a - b);\n visibility = visibility.sort((a, b) => a - b);\n\n // Dropping 2 min and 2 max coordinates\n x = x.slice(2, 6);\n y = y.slice(2, 6);\n z = z.slice(2, 6);\n visibility = visibility.slice(2, 6);\n\n // Making the average of 4 remaining coordinates\n smoothFrame[i] = {\n x: x.reduce((a, b) => a + b, 0) / x.length,\n y: y.reduce((a, b) => a + b, 0) / y.length,\n z: z.reduce((a, b) => a + b, 0) / z.length,\n visibility: visibility.reduce((a, b) => a + b, 0) / visibility.length,\n };\n }\n\n // Removing the first frame from frameSet\n frameSets.shift();\n }\n\n // after first 8 frames we have averaged coordinates, So now updating the poseLandmarks with averaged coordinates\n if (smoothFrame.length > 0) {\n results.poseLandmarks = smoothFrame;\n }\n\n return onResults ? onResults(results) : results;\n};\n\nexport default smoothLandmarks;\n"],"names":["smoothFrame","smoothLandmarks","results","onResults","poseLandmarks","frameSets","push","length","i","map","a","x","y","z","visibility","sort","b","slice","reduce","shift"],"mappings":"AAKA,MAAgB,GACZA,EAAc,GAQZC,MAAAA,EAAkB,CAACC,EAASC,KAMhC,GAJID,EAAQE,eACVC,EAAUC,KAAKJ,EAAQE,eAGA,IAArBC,EAAUE,OAAc,CAE1B,IAAK,IAAKC,EAAG,EAAGA,EAAI,GAAIA,IAAK,CAE3B,MAAQH,EAAUI,IAAKC,GAAMA,EAAEF,GAAGG,KAC1BN,EAAUI,IAAKC,GAAMA,EAAEF,GAAGI,KAC1BP,EAAUI,IAAKC,GAAMA,EAAEF,GAAGK,KACjBR,EAAUI,IAAKC,GAAMA,EAAEF,GAAGM,YAG3CH,EAAIA,EAAEI,KAAK,CAACL,EAAGM,IAAMN,EAAIM,GACzBJ,EAAIA,EAAEG,KAAK,CAACL,EAAGM,IAAMN,EAAIM,GACzBH,EAAIA,EAAEE,KAAK,CAACL,EAAGM,IAAMN,EAAIM,GACzBF,EAAaA,EAAWC,KAAK,CAACL,EAAGM,IAAMN,EAAIM,GAG3CL,EAAIA,EAAEM,MAAM,EAAG,GACfL,EAAIA,EAAEK,MAAM,EAAG,GACfJ,EAAIA,EAAEI,MAAM,EAAG,GACfH,EAAaA,EAAWG,MAAM,EAAG,GAGjCjB,EAAYQ,GAAK,CACfG,EAAGA,EAAEO,OAAO,CAACR,EAAGM,IAAMN,EAAIM,EAAG,GAAKL,EAAEJ,OACpCK,EAAGA,EAAEM,OAAO,CAACR,EAAGM,IAAMN,EAAIM,EAAG,GAAKJ,EAAEL,OACpCM,EAAGA,EAAEK,OAAO,CAACR,EAAGM,IAAMN,EAAIM,EAAG,GAAKH,EAAEN,OACpCO,WAAYA,EAAWI,OAAO,CAACR,EAAGM,IAAMN,EAAIM,EAAG,GAAKF,EAAWP,OAEnE,CAGAF,EAAUc,OACZ,CAOA,OAJInB,EAAYO,OAAS,IACvBL,EAAQE,cAAgBJ,GAGnBG,EAAYA,EAAUD,GAAWA"} \ No newline at end of file diff --git a/dist/index.module.js b/dist/index.module.js index 59d0eca..c4f7000 100644 --- a/dist/index.module.js +++ b/dist/index.module.js @@ -1,2 +1,2 @@ -var e=function(e){return"I am the Default Awesome Function, fellow comrade! - "+e},n=function(){return"I am just an Awesome Function"};export{n as awesomeFunction,e as default}; +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 diff --git a/dist/index.module.js.map b/dist/index.module.js.map index c88cea6..4fa2ce8 100644 --- a/dist/index.module.js.map +++ b/dist/index.module.js.map @@ -1 +1 @@ -{"version":3,"file":"index.module.js","sources":["../src/index.js"],"sourcesContent":["const defaultAwesomeFunction = (name) => {\n const returnStr = `I am the Default Awesome Function, fellow comrade! - ${name}`;\n return returnStr;\n};\n\nconst awesomeFunction = () => 'I am just an Awesome Function';\n\nexport default defaultAwesomeFunction;\n\nexport { awesomeFunction };\n"],"names":["defaultAwesomeFunction","name","awesomeFunction"],"mappings":"AAAMA,IAAsBA,EAAG,SAACC,GAE9B,MAD0EA,wDAAAA,CAE5E,EAEqBC,EAAG,WAAM,MAAA,+BAA+B"} \ No newline at end of file +{"version":3,"file":"index.module.js","sources":["../src/index.js"],"sourcesContent":["/**\n * This will remove the jitter and smooth the landmarks given by Mediapipe\n * @author Yousuf Kalim\n */\n\nlet frameSets = [];\nlet smoothFrame = [];\n\n/**\n * smoothLandmarks\n * @param {Object} results This should be coming directly from Mediapipe\n * @param {Function} onResults Optional: If you want to call other function instead of getting return\n * @returns {Void}\n */\nconst smoothLandmarks = (results, onResults) => {\n // Pushing frame at the end of frameSet array\n if (results.poseLandmarks) {\n frameSets.push(results.poseLandmarks);\n }\n\n if (frameSets.length === 8) {\n // This loop will run 33 time to make average of each joint\n for (let i = 0; i < 33; i++) {\n // Making an array of each joint coordinates\n let x = frameSets.map((a) => a[i].x);\n let y = frameSets.map((a) => a[i].y);\n let z = frameSets.map((a) => a[i].z);\n let visibility = frameSets.map((a) => a[i].visibility);\n\n // Sorting the array into ascending order\n x = x.sort((a, b) => a - b);\n y = y.sort((a, b) => a - b);\n z = z.sort((a, b) => a - b);\n visibility = visibility.sort((a, b) => a - b);\n\n // Dropping 2 min and 2 max coordinates\n x = x.slice(2, 6);\n y = y.slice(2, 6);\n z = z.slice(2, 6);\n visibility = visibility.slice(2, 6);\n\n // Making the average of 4 remaining coordinates\n smoothFrame[i] = {\n x: x.reduce((a, b) => a + b, 0) / x.length,\n y: y.reduce((a, b) => a + b, 0) / y.length,\n z: z.reduce((a, b) => a + b, 0) / z.length,\n visibility: visibility.reduce((a, b) => a + b, 0) / visibility.length,\n };\n }\n\n // Removing the first frame from frameSet\n frameSets.shift();\n }\n\n // after first 8 frames we have averaged coordinates, So now updating the poseLandmarks with averaged coordinates\n if (smoothFrame.length > 0) {\n results.poseLandmarks = smoothFrame;\n }\n\n return onResults ? onResults(results) : results;\n};\n\nexport default smoothLandmarks;\n"],"names":["smoothFrame","smoothLandmarks","results","onResults","poseLandmarks","frameSets","push","length","i","map","a","x","y","z","visibility","sort","b","slice","reduce","_loop","shift"],"mappings":"AAKA,MAAgB,GACZA,EAAc,GAQGC,EAAG,SAACC,EAASC,GAMhC,GAJID,EAAQE,eACVC,EAAUC,KAAKJ,EAAQE,eAGA,IAArBC,EAAUE,OAAc,CAE1B,IAASC,IAAAA,EAAAA,SAAAA,GAEP,MAAQH,EAAUI,IAAI,SAACC,GAAC,SAAOF,GAAGG,CAAC,KAC3BN,EAAUI,IAAI,SAACC,GAAC,SAAOF,GAAGI,CAAC,KAC3BP,EAAUI,IAAI,SAACC,GAAC,OAAMA,EAACF,GAAGK,CAAC,GACrBC,EAAGT,EAAUI,IAAI,SAACC,UAAOA,EAACF,GAAGM,UAAU,GAGrDH,EAAIA,EAAEI,KAAK,SAACL,EAAGM,GAAC,SAASA,CAAC,GAC1BJ,EAAIA,EAAEG,KAAK,SAACL,EAAGM,GAAMN,OAAAA,EAAIM,CAAC,GAC1BH,EAAIA,EAAEE,KAAK,SAACL,EAAGM,GAAC,SAASA,CAAC,GAC1BF,EAAaA,EAAWC,KAAK,SAACL,EAAGM,UAAON,EAAGM,CAAC,GAG5CL,EAAIA,EAAEM,MAAM,EAAG,GACfL,EAAIA,EAAEK,MAAM,EAAG,GACfJ,EAAIA,EAAEI,MAAM,EAAG,GACfH,EAAaA,EAAWG,MAAM,EAAG,GAGjCjB,EAAYQ,GAAK,CACfG,EAAGA,EAAEO,OAAO,SAACR,EAAGM,UAAON,EAAGM,CAAC,EAAE,GAAKL,EAAEJ,OACpCK,EAAGA,EAAEM,OAAO,SAACR,EAAGM,GAAMN,OAAAA,EAAIM,CAAC,EAAE,GAAKJ,EAAEL,OACpCM,EAAGA,EAAEK,OAAO,SAACR,EAAGM,UAAON,EAAGM,CAAC,EAAE,GAAKH,EAAEN,OACpCO,WAAYA,EAAWI,OAAO,SAACR,EAAGM,GAAC,SAASA,CAAC,EAAE,GAAKF,EAAWP,OAC/D,EAzBKC,EAAI,EAAGA,EAAI,GAAIA,IAAKW,EAApBX,GA6BTH,EAAUe,OACZ,CAOA,OAJIpB,EAAYO,OAAS,IACvBL,EAAQE,cAAgBJ,GAGnBG,EAAYA,EAAUD,GAAWA,CAC1C"} \ No newline at end of file diff --git a/dist/index.umd.js b/dist/index.umd.js index 523636c..c9ee303 100644 --- a/dist/index.umd.js +++ b/dist/index.umd.js @@ -1,2 +1,2 @@ -!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e||self).npmBoilerplate={})}(this,function(e){e.awesomeFunction=function(){return"I am just an Awesome Function"},e.default=function(e){return"I am the Default Awesome Function, fellow comrade! - "+e}}); +!function(n,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(n||self).npmBoilerplate=e()}(this,function(){var n=[],e=[];return function(t,r){if(t.poseLandmarks&&n.push(t.poseLandmarks),8===n.length){for(var i=function(t){var r=n.map(function(n){return n[t].x}),i=n.map(function(n){return n[t].y}),u=n.map(function(n){return n[t].z}),o=n.map(function(n){return n[t].visibility});r=r.sort(function(n,e){return n-e}),i=i.sort(function(n,e){return n-e}),u=u.sort(function(n,e){return n-e}),o=o.sort(function(n,e){return n-e}),r=r.slice(2,6),i=i.slice(2,6),u=u.slice(2,6),o=o.slice(2,6),e[t]={x:r.reduce(function(n,e){return n+e},0)/r.length,y:i.reduce(function(n,e){return n+e},0)/i.length,z:u.reduce(function(n,e){return n+e},0)/u.length,visibility:o.reduce(function(n,e){return n+e},0)/o.length}},u=0;u<33;u++)i(u);n.shift()}return e.length>0&&(t.poseLandmarks=e),r?r(t):t}}); //# sourceMappingURL=index.umd.js.map diff --git a/dist/index.umd.js.map b/dist/index.umd.js.map index 4c51444..b0e9fe7 100644 --- a/dist/index.umd.js.map +++ b/dist/index.umd.js.map @@ -1 +1 @@ -{"version":3,"file":"index.umd.js","sources":["../src/index.js"],"sourcesContent":["const defaultAwesomeFunction = (name) => {\n const returnStr = `I am the Default Awesome Function, fellow comrade! - ${name}`;\n return returnStr;\n};\n\nconst awesomeFunction = () => 'I am just an Awesome Function';\n\nexport default defaultAwesomeFunction;\n\nexport { awesomeFunction };\n"],"names":["name"],"mappings":"0PAKwB,WAAM,MAAA,+BAA+B,YAL9B,SAACA,GAE9B,MAD0EA,wDAAAA,CAE5E"} \ No newline at end of file +{"version":3,"file":"index.umd.js","sources":["../src/index.js"],"sourcesContent":["/**\n * This will remove the jitter and smooth the landmarks given by Mediapipe\n * @author Yousuf Kalim\n */\n\nlet frameSets = [];\nlet smoothFrame = [];\n\n/**\n * smoothLandmarks\n * @param {Object} results This should be coming directly from Mediapipe\n * @param {Function} onResults Optional: If you want to call other function instead of getting return\n * @returns {Void}\n */\nconst smoothLandmarks = (results, onResults) => {\n // Pushing frame at the end of frameSet array\n if (results.poseLandmarks) {\n frameSets.push(results.poseLandmarks);\n }\n\n if (frameSets.length === 8) {\n // This loop will run 33 time to make average of each joint\n for (let i = 0; i < 33; i++) {\n // Making an array of each joint coordinates\n let x = frameSets.map((a) => a[i].x);\n let y = frameSets.map((a) => a[i].y);\n let z = frameSets.map((a) => a[i].z);\n let visibility = frameSets.map((a) => a[i].visibility);\n\n // Sorting the array into ascending order\n x = x.sort((a, b) => a - b);\n y = y.sort((a, b) => a - b);\n z = z.sort((a, b) => a - b);\n visibility = visibility.sort((a, b) => a - b);\n\n // Dropping 2 min and 2 max coordinates\n x = x.slice(2, 6);\n y = y.slice(2, 6);\n z = z.slice(2, 6);\n visibility = visibility.slice(2, 6);\n\n // Making the average of 4 remaining coordinates\n smoothFrame[i] = {\n x: x.reduce((a, b) => a + b, 0) / x.length,\n y: y.reduce((a, b) => a + b, 0) / y.length,\n z: z.reduce((a, b) => a + b, 0) / z.length,\n visibility: visibility.reduce((a, b) => a + b, 0) / visibility.length,\n };\n }\n\n // Removing the first frame from frameSet\n frameSets.shift();\n }\n\n // after first 8 frames we have averaged coordinates, So now updating the poseLandmarks with averaged coordinates\n if (smoothFrame.length > 0) {\n results.poseLandmarks = smoothFrame;\n }\n\n return onResults ? onResults(results) : results;\n};\n\nexport default smoothLandmarks;\n"],"names":["smoothFrame","results","onResults","poseLandmarks","frameSets","push","length","i","map","a","x","y","z","visibility","sort","b","slice","reduce","_loop","shift"],"mappings":"iOAKA,MAAgB,GACZA,EAAc,UAQM,SAACC,EAASC,GAMhC,GAJID,EAAQE,eACVC,EAAUC,KAAKJ,EAAQE,eAGA,IAArBC,EAAUE,OAAc,CAE1B,IAASC,IAAAA,EAAAA,SAAAA,GAEP,MAAQH,EAAUI,IAAI,SAACC,GAAC,SAAOF,GAAGG,CAAC,KAC3BN,EAAUI,IAAI,SAACC,GAAC,SAAOF,GAAGI,CAAC,KAC3BP,EAAUI,IAAI,SAACC,GAAC,OAAMA,EAACF,GAAGK,CAAC,GACrBC,EAAGT,EAAUI,IAAI,SAACC,UAAOA,EAACF,GAAGM,UAAU,GAGrDH,EAAIA,EAAEI,KAAK,SAACL,EAAGM,GAAC,SAASA,CAAC,GAC1BJ,EAAIA,EAAEG,KAAK,SAACL,EAAGM,GAAMN,OAAAA,EAAIM,CAAC,GAC1BH,EAAIA,EAAEE,KAAK,SAACL,EAAGM,GAAC,SAASA,CAAC,GAC1BF,EAAaA,EAAWC,KAAK,SAACL,EAAGM,UAAON,EAAGM,CAAC,GAG5CL,EAAIA,EAAEM,MAAM,EAAG,GACfL,EAAIA,EAAEK,MAAM,EAAG,GACfJ,EAAIA,EAAEI,MAAM,EAAG,GACfH,EAAaA,EAAWG,MAAM,EAAG,GAGjChB,EAAYO,GAAK,CACfG,EAAGA,EAAEO,OAAO,SAACR,EAAGM,UAAON,EAAGM,CAAC,EAAE,GAAKL,EAAEJ,OACpCK,EAAGA,EAAEM,OAAO,SAACR,EAAGM,GAAMN,OAAAA,EAAIM,CAAC,EAAE,GAAKJ,EAAEL,OACpCM,EAAGA,EAAEK,OAAO,SAACR,EAAGM,UAAON,EAAGM,CAAC,EAAE,GAAKH,EAAEN,OACpCO,WAAYA,EAAWI,OAAO,SAACR,EAAGM,GAAC,SAASA,CAAC,EAAE,GAAKF,EAAWP,OAC/D,EAzBKC,EAAI,EAAGA,EAAI,GAAIA,IAAKW,EAApBX,GA6BTH,EAAUe,OACZ,CAOA,OAJInB,EAAYM,OAAS,IACvBL,EAAQE,cAAgBH,GAGnBE,EAAYA,EAAUD,GAAWA,CAC1C"} \ No newline at end of file