img = loadImage("image.jpg");
createCanvas(windowWidth, windowHeight);
img.resize(height, height);
faceapi = ml5.faceApi(modelLoaded);
bounds = boundingbox(parts.leftEye);
leimg = img.get(bounds[0], bounds[1], bounds[2], bounds[3]);
image(leimg, bounds[0], bounds[1]);
bounds = boundingbox(parts.rightEye);
reimg = img.get(bounds[0], bounds[1], bounds[2], bounds[3]);
image(reimg, bounds[0], bounds[1]);
bounds = boundingbox(parts.nose);
nimg = img.get(bounds[0], bounds[1], bounds[2], bounds[3]);
image(nimg, bounds[0], bounds[1]);
bounds = boundingbox(parts.mouth);
mimg = img.get(bounds[0]-50, bounds[1]-50, bounds[2]+50, bounds[3]+50);
for (i = 0; i < parts.nose.length; i++)
text(i, parts.nose[i]._x, parts.nose[i]._y);
pg = createGraphics(mimg.width, mimg.height);
for (i = 0; i < parts.mouth.length; i++)
pg.ellipse(parts.mouth[i]._x-bounds[0], parts.mouth[i]._y-bounds[1], 50, 50);
image(masked, bounds[0], bounds[1]);
faceapi.detect(img, (err, results) => {
parts = results[0].parts;
print(boundingbox(parts.mouth));
function boundingbox(coords) {
for (i = 0; i < coords.length; i++) {
if (coords[i]._x <= xmin)
if (coords[i]._y <= ymin)
return ([xmin, ymin, xmax - xmin, ymax - ymin]);