Created
June 25, 2020 07:12
-
-
Save risenW/559a7d7955bd1b5ebe8461e81a234a0b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function capture() { | |
capturing = true | |
while (capturing) { | |
const img = await webcam.capture(); | |
const predictions = await model.estimateFaces(img); | |
if (predictions.length > 0) { | |
let a = []; b = []; c = [] | |
for (let i = 0; i < predictions.length; i++) { | |
const keypoints = predictions[i].mesh; | |
// Log facial keypoints. | |
for (let i = 0; i < keypoints.length; i++) { | |
const [x, y, z] = keypoints[i]; | |
a.push(y) | |
b.push(x) | |
c.push(z) | |
} | |
} | |
// Plotting the mesh | |
var data = [ | |
{ | |
opacity: 0.8, | |
color: 'rgb(300,100,200)', | |
type: 'mesh3d', | |
x: a, | |
y: b, | |
z: c, | |
} | |
]; | |
Plotly.newPlot('plot', data); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment