0x307
0x307

Reputation: 77

How to detect the face shape of a person based on the face landmarks?

I am currently working on a project where I am using @tensorflow-models/face-landmarks-detection to detect facial landmarks. Here's a snippet of my code:

import * as faceLandmarksDetection from "@tensorflow-models/face-landmarks-detection";

export const runDetector = async (video, canvas) => {
  const model = faceLandmarksDetection.SupportedModels.MediaPipeFaceMesh;
  const detectorConfig = {
    runtime: "tfjs",
  };
  const detector = await faceLandmarksDetection.createDetector(
    model,
    detectorConfig
  );
  const detect = async (net) => {
    const estimationConfig = { flipHorizontal: false };
    const faces = await net.estimateFaces(video, estimationConfig);
    detect(detector);
  };
  detect(detector);
};

The faces variable in the code above returns a list containing the bounding box of the detected face and 468 keypoints. My goal is to use this information to determine the shape of the person's face, whether it's round, oval, or another shape.

Could someone provide guidance or sample code on how I can analyze the facial landmarks to classify the shape of the detected face?

Upvotes: 1

Views: 155

Answers (0)

Related Questions