terryzg

KI-Bild mit amanda von terryzg
Bild

Bild generieren

KI-Bild mit amanda von terryzg

Qualität

Ultra 2K

Beschreibung

import cv2import mediapipe as mpimport numpy as npmp_face_mesh = mp.solutions.face_mesh# Índices de algunos landmarks relevantesLEFT_EYE = 33RIGHT_EYE = 263NOSE_TIP = 1LEFT_NOSTRIL = 98RIGHT_NOSTRIL = 327CHIN = 152LEFT_JAW = 172RIGHT_JAW = 397UPPER_LIP = 13LOWER_LIP = 14image = cv2.imread("rostro.jpg")rgb = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)with mp_face_mesh.FaceMesh( static_image_mode=True, max_num_faces=1, refine_landmarks=True) as face_mesh: results = face_mesh.process(rgb) if not results.multi_face_landmarks: print("No se detectó un rostro.") exit() h, w = image.shape[:2] lm = results.multi_face_landmarks[0].landmark pts = np.array([(p.x*w, p.y*h) for p in lm]) def dist(a, b): return np.linalg.norm(pts[a] - pts[b]) print("===== ANÁLISIS MORFOMÉTRICO =====") print(f"Distancia entre ojos: {dist(LEFT_EYE, RIGHT_EYE):.2f}px") print(f"Anchura de la nariz: {dist(LEFT_NOSTRIL, RIGHT_NOSTRIL):.2f}px") print(f"Anchura de la mandíbula: {dist(LEFT_JAW, RIGHT_JAW):.2f}px") print(f"Altura nariz-mentón: {dist(NOSE_TIP, CHIN):.2f}px") print(f"Altura labios: {dist(UPPER_LIP, LOWER_LIP):.2f}px") # Dibujar landmarks for x, y in pts.astype(int): cv2.circle(image, (x, y), 1, (0,255,0), -1) cv2.imshow("Face Mesh", image) cv2.waitKey(0) cv2.destroyAllWindows()