|
1 | | -# NPM Module Boilerplate |
| 1 | +# Mediapipe Pose Smooth |
2 | 2 |
|
3 | | -**Start developing your NPM module in seconds** ✨ |
| 3 | +This library removes the jitter and smooth the landmarks coming from Mediapipe. |
4 | 4 |
|
5 | | -Readymade boilerplate setup with all the best practices to kick-start your npm/node module development. |
| 5 | +## How it works |
6 | 6 |
|
7 | | -Happy hacking =) |
| 7 | +The library creates the average of every 8 frames to smooth the landmarks. The library is initialized with the first landmark received and then wait for the 8 more frames to start creating the average, meanwhile it returns the landmarks as it is. After the 8 frames, the library drops the 2 frames with the max values and 2 with the min values and starts to create the average from the remaining 4 frames and returns the average. |
8 | 8 |
|
9 | | -# Features |
10 | 9 |
|
11 | | -- **Microbundle** for bundling |
12 | | -- **ES6/ESNext** - Write _ES6_ code and _Microbundle_ will make bundle of it to ES5 for backwards compatibility |
13 | | -- **Test** - _Jest_ with _Istanbul_ coverage |
14 | | -- **Lint** - Preconfigured _ESlint_ with best practices |
15 | | -- **CI** - _TravisCI_ configuration setup |
16 | | -- **Minify** - Built code will be minified for performance |
| 10 | +## Installation |
17 | 11 |
|
18 | | -# Commands |
| 12 | +Install mediapipe-pose-smooth with npm/yarn |
19 | 13 |
|
20 | | -- `npm run lint` - Run ESlint |
21 | | -- `npm run build` - Microbundle will transpile ES6 => ES5 and minify the code. |
22 | | -- `npm run dev` - Microbundle will watch and create build on change. |
23 | | -- `npm run test` - Run tests with jest. |
| 14 | +```bash |
| 15 | + npm install mediapipe-pose-smooth // npm |
| 16 | + yarn add mediapipe-pose-smooth // yarn |
| 17 | +``` |
24 | 18 |
|
25 | | -# Installation |
| 19 | +## Usage/Examples |
26 | 20 |
|
27 | | -Just clone this repo and remove `.git` folder. |
| 21 | +#### Import |
28 | 22 |
|
29 | | -# License |
| 23 | +```javascript |
| 24 | +import smoothLandmarks from 'mediapipe-pose-smooth'; // ES6 |
| 25 | +const smoothLandmarks = require('mediapipe-pose-smooth'); // CommonJS |
| 26 | +``` |
30 | 27 |
|
31 | | -MIT © Yousuf Kalim |
| 28 | +#### Example result data |
| 29 | + |
| 30 | +```javascript |
| 31 | +{ |
| 32 | + poseLandmarks: [ |
| 33 | + { x: 1, y: 1, z: 1, visibility: 1 }, |
| 34 | + { x: 2, y: 2, z: 2, visibility: 1 }, |
| 35 | + { x: 3, y: 3, z: 3, visibility: 1 }, |
| 36 | + { x: 4, y: 4, z: 4, visibility: 1 }, |
| 37 | + { x: 5, y: 5, z: 5, visibility: 1 }, |
| 38 | + { x: 6, y: 6, z: 6, visibility: 1 }, |
| 39 | + { x: 7, y: 7, z: 7, visibility: 1 }, |
| 40 | + { x: 8, y: 8, z: 8, visibility: 1 }, |
| 41 | + { x: 9, y: 9, z: 9, visibility: 1 }, |
| 42 | + { x: 10, y: 10, z: 10, visibility: 1 }, |
| 43 | + { x: 11, y: 11, z: 11, visibility: 1 }, |
| 44 | + { x: 12, y: 12, z: 12, visibility: 1 }, |
| 45 | + { x: 13, y: 13, z: 13, visibility: 1 }, |
| 46 | + { x: 14, y: 14, z: 14, visibility: 1 }, |
| 47 | + { x: 15, y: 15, z: 15, visibility: 1 }, |
| 48 | + { x: 16, y: 16, z: 16, visibility: 1 }, |
| 49 | + { x: 17, y: 17, z: 17, visibility: 1 }, |
| 50 | + { x: 18, y: 18, z: 18, visibility: 1 }, |
| 51 | + { x: 19, y: 19, z: 19, visibility: 1 }, |
| 52 | + { x: 20, y: 20, z: 20, visibility: 1 }, |
| 53 | + { x: 21, y: 21, z: 21, visibility: 1 }, |
| 54 | + { x: 22, y: 22, z: 22, visibility: 1 }, |
| 55 | + { x: 23, y: 23, z: 23, visibility: 1 }, |
| 56 | + { x: 24, y: 24, z: 24, visibility: 1 }, |
| 57 | + { x: 25, y: 25, z: 25, visibility: 1 }, |
| 58 | + { x: 26, y: 26, z: 26, visibility: 1 }, |
| 59 | + { x: 27, y: 27, z: 27, visibility: 1 }, |
| 60 | + { x: 28, y: 28, z: 28, visibility: 1 }, |
| 61 | + { x: 29, y: 29, z: 29, visibility: 1 }, |
| 62 | + { x: 30, y: 30, z: 30, visibility: 1 }, |
| 63 | + { x: 31, y: 31, z: 31, visibility: 1 }, |
| 64 | + { x: 32, y: 32, z: 32, visibility: 1 }, |
| 65 | + { x: 33, y: 33, z: 33, visibility: 1 } |
| 66 | + ] |
| 67 | +}; |
| 68 | +``` |
| 69 | + |
| 70 | +#### Usage |
| 71 | + |
| 72 | +```javascript |
| 73 | +const pose = new Pose({ |
| 74 | + locateFile: (file) => { |
| 75 | + return `https://cdn.jsdelivr.net/npm/@mediapipe/pose/${file}`; |
| 76 | + }, |
| 77 | +}); |
| 78 | + |
| 79 | +pose.setOptions({ |
| 80 | + // Options |
| 81 | +}); |
| 82 | + |
| 83 | +// Pass another function to receive the results |
| 84 | +pose.onResults((results) => smoothLandmarks(results, onResutls)); |
| 85 | + |
| 86 | +function onResutls(results) { |
| 87 | + // Do something with the results |
| 88 | +} |
| 89 | + |
| 90 | +// Or get the returned data from the library |
| 91 | +pose.onResults((results) => { |
| 92 | + // Smooth the landmarks |
| 93 | + const smoothResults = smoothLandmarks(results); |
| 94 | + |
| 95 | + // Do something with the smooth results |
| 96 | +}); |
| 97 | +``` |
| 98 | + |
| 99 | +## Contributing |
| 100 | + |
| 101 | +- Fork it! |
| 102 | +- Create your feature branch: `git checkout -b my-new-feature` |
| 103 | +- Commit your changes: `git commit -am 'Add some feature'` |
| 104 | +- Push to the branch: `git push origin my-new-feature` |
| 105 | +- Submit a pull request :D |
| 106 | + |
| 107 | +## Author |
| 108 | + |
| 109 | +**mediapipe-pose-smooth** © [Yousuf](https://github.com/yousufkalim) |
| 110 | +Authored and maintained by Yousuf Kalim. |
| 111 | + |
| 112 | +> GitHub [@yousufkalim](https://github.com/yousufkalim) · LinkedIn [@yousufkalim](https://www.linkedin.com/in/yousufkalim/) |
| 113 | +## License |
| 114 | +[MIT](https://choosealicense.com/licenses/mit/) |
0 commit comments