App / utils.py
RICHERGIRL's picture
Create utils.py
2787dfd verified
Raw
History Blame
841 Bytes
import cv2
import mediapipe as mp
import numpy as np
mp_face_detection = mp.solutions.face_detection
def extract_features(image_path):
"""Extract face shape, skin tone, and size from an image."""
image = cv2.imread(image_path)
image_rgb = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
# Detect face (simplified example)
with mp_face_detection.FaceDetection(min_detection_confidence=0.5) as face_detector:
results = face_detector.process(image_rgb)
if not results.detections:
return None, None, None
# Mock logic (replace with actual calculations)
face_shape = "Oval" # Use landmarks to classify shape
skin_tone = "Medium" # Estimate from cheek region
face_size = "Medium" # Measure bounding box
return face_shape, skin_tone, face_size