{ name: "Entrada: Salada caprese ao pesto manjericão", image: "Salada caprese.png" },
{ name: "Entrada: Quiche Napolitana", image: "quiche napolitano.png" },
{ name: "Entrada: Profiteroles de Salmon", image: "profiteroles de salmão.png" },
{ name: "Prato Principal: Bobó de camarão", image: "Bobo de camarão.png" },
{ name: "Prato Principal: Bacalhau gratinado", image: "bacalhau gratinado.png" },
{ name: "Sobremesa: Tortinha Marquise", image: "Sobremesa tortinha.png" }
let currentDishIndex = -1;
let noivos = "Alice e João";
let options = { maxFaces: 1, refineLandmarks: false, flipped: false };
let selfieSegmentationResults;
weddingImage = loadImage("Post-Blog-Organize-5-1080x675.png");
menuImage = loadImage("Cardápio menu de casamento floral delicado creme e marrom_20241213_205204_0000.png");
faceMesh = ml5.faceMesh(options);
"profiteroles de salmão.png"
for(var i = 0; i < foodsNames.length; i++){
var img = loadImage(foodsNames[i]);
selfieSegmentation = new SelfieSegmentation({
return `https://cdn.jsdelivr.net/npm/@mediapipe/selfie_segmentation/${file}`;
selfieSegmentation.setOptions({
selfieSegmentation.onResults(onResults);
menuWidth = HEIGHT * menuImage.width / menuImage.height;
createCanvas(WIDTH + menuWidth, HEIGHT);
video = createCapture(VIDEO);
video.size(width, height);
const camera = new Camera(video.elt, {
await selfieSegmentation.send({
faceMesh.detectStart(video, gotFaces);
function gotFaces(results) {
if(selfieSegmentationResults){
image(video, menuWidth, 0, WIDTH, HEIGHT);
drawingContext.globalCompositeOperation="destination-atop";
drawingContext.drawImage(selfieSegmentationResults.segmentationMask, menuWidth, 0, WIDTH, HEIGHT);
image(weddingImage, menuWidth, 0, WIDTH, HEIGHT);
drawingContext.restore();
image(menuImage, 0, 0, menuWidth, height);
for (let i = 0; i < faces.length; i++) {
bocaAberta |= isMouthOpen(face.keypoints);
if (currentDishIndex === -1) {
if(mouthX && mouthY && current < 3){
var x = lerp(posisitions[current].x, mouthX, animPct);
var y = lerp(posisitions[current].y, mouthY, animPct);
image(foods[current], x, y, (foods[current].width/2)*animPct, (foods[current].height/2)*animPct);
function onResults(results) {
selfieSegmentationResults = results;
function isMouthOpen(keypoints) {
const topLip = keypoints[13];
const bottomLip = keypoints[14];
const leftEye = keypoints[33];
const rightEye = keypoints[133];
const mouthDistance = dist(topLip.x, topLip.y, bottomLip.x, bottomLip.y);
const faceWidth = dist(leftEye.x, leftEye.y, rightEye.x, rightEye.y);
const threshold = faceWidth * 0.5;
return mouthDistance > threshold;
function drawStartMenu() {
fill(255, 255, 255, 200);
rect(50, 50, width - 100, height - 100, 20);
textAlign(CENTER, CENTER);
text(`Bem-vindos ao menu degustação de ${noivos}`, width / 2, 100);
text("Clique para iniciar a degustação", width / 2, height / 2);
function mousePressed() {
if (currentDishIndex === -1) {