Skip to content

Instantly share code, notes, and snippets.

@risenW
Created June 25, 2020 07:12
Show Gist options
  • Save risenW/559a7d7955bd1b5ebe8461e81a234a0b to your computer and use it in GitHub Desktop.
Save risenW/559a7d7955bd1b5ebe8461e81a234a0b to your computer and use it in GitHub Desktop.
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