├── .gitattributes
├── .github
└── FUNDING.yml
├── .gitignore
├── LICENSE
├── README.md
├── images
├── Donal_Thrump_White_House.jpg
├── arrow-left.png
├── arrow-right.png
├── full-mask-1.png
├── full-mask-2.png
├── full-mask-3.png
├── full-mask-4.png
├── half-mask-0.png
├── half-mask-1.png
├── half-mask-2.png
├── half-mask-3.png
├── half-mask-4.png
├── half-mask-5.png
├── half-mask-6.png
└── mesh_map.jpg
├── index.html
├── js
├── face-mask.js
└── webcam-ui-lib.js
└── style
└── face-mask.css
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
--------------------------------------------------------------------------------
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | ko_fi: bensonruan
2 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | images/benson.jpg
2 | images/face-mask-auto-detection-demo.jpg
3 | images/face-mask-demo.gif
4 | images/facemesh_mask_webcam_demo_short.gif
5 | images/facemesh_mask_webcam_demo.gif
6 | images/Mask_for_Donald_Trump.gif
7 | images/Mask_for_Trump.gif
8 | images/mesh_map_key_points.jpg
9 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2020 Benson Ruan
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Face-Mask
2 | Image and Real time webcam face detection, protect yourself from COVID19 with a virtual face mask.
3 |
4 | Utilize tensorflowjs facemesh model.
5 |
6 | ## Live Demo
7 | **[https://bensonruan.com/face-detection-javascript-real-time-mask-application/](https://bensonruan.com/face-detection-javascript-real-time-mask-application/)**
8 |
9 | 
10 |
11 |
12 | ## Installing
13 | Clone this repository to your local computer
14 | ``` bash
15 | git https://github.com/bensonruan/Face-Mask.git
16 | ```
17 | Point your localhost to the cloned root directory
18 |
19 | Browse to http://localhost/index.html
20 |
21 | ## Face Keypoints
22 | The facemesh detected keypoints that used for overlay the mask:
23 | * Forehead : 10
24 | * Left Cheek : 234
25 | * Chin : 152
26 | * Right Cheek : 454
27 |
28 | 
29 |
30 | ## Put Mask On
31 | * Click on 'Put Mask On' button to detect face on image and cover by mask
32 | * Turn on the Webcam switch and allowing the browser to access your webcam
33 | * Wait for a few seconds to Load Model for face landmark detection
34 | * Choose the face mask you would like to try on, watch yourself cover up
35 |
36 | 
37 |
38 | ## Notes
39 | * Please note that on iOS Safari, cameras can only be accessed via the https protocol
40 | * Facemesh model is designed for front-facing cameras on mobile devices, where faces in view tend to occupy a relatively large fraction of the canvas. MediaPipe Facemesh may struggle to identify far-away faces.
41 |
42 | ## Library
43 | * [jquery](https://code.jquery.com/jquery-3.3.1.min.js) - JQuery
44 | * [webcam-easy.js](https://github.com/bensonruan/webcam-easy) - javascript library for accessing webcam stream and taking photos
45 | * [facemesh](https://github.com/tensorflow/tfjs-models/tree/master/facemesh) - MediaPipe Facemesh is a lightweight machine learning pipeline predicting 486 3D facial landmarks to infer the approximate surface geometry of a human face
46 |
47 | ## Support me
48 | [](https://ko-fi.com/W7W6METMY)
49 |
--------------------------------------------------------------------------------
/images/Donal_Thrump_White_House.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bensonruan/Face-Mask/6703ecfc56bd3b0131cafb656b8532332690186c/images/Donal_Thrump_White_House.jpg
--------------------------------------------------------------------------------
/images/arrow-left.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bensonruan/Face-Mask/6703ecfc56bd3b0131cafb656b8532332690186c/images/arrow-left.png
--------------------------------------------------------------------------------
/images/arrow-right.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bensonruan/Face-Mask/6703ecfc56bd3b0131cafb656b8532332690186c/images/arrow-right.png
--------------------------------------------------------------------------------
/images/full-mask-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bensonruan/Face-Mask/6703ecfc56bd3b0131cafb656b8532332690186c/images/full-mask-1.png
--------------------------------------------------------------------------------
/images/full-mask-2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bensonruan/Face-Mask/6703ecfc56bd3b0131cafb656b8532332690186c/images/full-mask-2.png
--------------------------------------------------------------------------------
/images/full-mask-3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bensonruan/Face-Mask/6703ecfc56bd3b0131cafb656b8532332690186c/images/full-mask-3.png
--------------------------------------------------------------------------------
/images/full-mask-4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bensonruan/Face-Mask/6703ecfc56bd3b0131cafb656b8532332690186c/images/full-mask-4.png
--------------------------------------------------------------------------------
/images/half-mask-0.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bensonruan/Face-Mask/6703ecfc56bd3b0131cafb656b8532332690186c/images/half-mask-0.png
--------------------------------------------------------------------------------
/images/half-mask-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bensonruan/Face-Mask/6703ecfc56bd3b0131cafb656b8532332690186c/images/half-mask-1.png
--------------------------------------------------------------------------------
/images/half-mask-2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bensonruan/Face-Mask/6703ecfc56bd3b0131cafb656b8532332690186c/images/half-mask-2.png
--------------------------------------------------------------------------------
/images/half-mask-3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bensonruan/Face-Mask/6703ecfc56bd3b0131cafb656b8532332690186c/images/half-mask-3.png
--------------------------------------------------------------------------------
/images/half-mask-4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bensonruan/Face-Mask/6703ecfc56bd3b0131cafb656b8532332690186c/images/half-mask-4.png
--------------------------------------------------------------------------------
/images/half-mask-5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bensonruan/Face-Mask/6703ecfc56bd3b0131cafb656b8532332690186c/images/half-mask-5.png
--------------------------------------------------------------------------------
/images/half-mask-6.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bensonruan/Face-Mask/6703ecfc56bd3b0131cafb656b8532332690186c/images/half-mask-6.png
--------------------------------------------------------------------------------
/images/mesh_map.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bensonruan/Face-Mask/6703ecfc56bd3b0131cafb656b8532332690186c/images/mesh_map.jpg
--------------------------------------------------------------------------------
/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
65 | Fail to start camera, please allow permision to access camera.
66 | If you are browsing through social media built in browsers, you would need to open the page in Sarafi (iPhone)/ Chrome (Android)
67 |
68 |