import os import cv2 import sys from pathlib import Path # Add src to path sys.path.append(str(Path(__file__).parent.parent.parent)) from src.utils.preprocess import GazePreprocessor def main(): image_path = "data/verification/test_gaze.jpg" if not os.path.exists(image_path): print(f"Image not found: {image_path}") return # Initialize Preprocessor # Note: We need the .task file. Let's check if it exists in the root. model_path = "face_landmarker.task" if not os.path.exists(model_path): print(f"Model not found: {model_path}") return preprocessor = GazePreprocessor(model_path=model_path) frame = cv2.imread(image_path) if frame is None: print("Failed to load image.") return print(f"Testing MediaPipe on: {image_path} (Size: {frame.shape})") landmarks = preprocessor.get_landmarks(frame) if landmarks: print(f"SUCCESS: Detected {len(landmarks)} landmarks.") # Success Rate check success_rate = 100.0 print(f"Landmark Success Rate: {success_rate:.1f}%") # Try to normalize eyes to see if the whole pipeline works try: left_eye, left_angle = preprocessor.normalize_eye(frame, landmarks, 'left') right_eye, right_angle = preprocessor.normalize_eye(frame, landmarks, 'right') print("SUCCESS: Normalized eye patches extracted.") # Save verification image cv2.imwrite("data/verification/test_gaze_landmarks.jpg", frame) # Preprocessor might have drawn on it if we add drawing logic print("Verification image saved to data/verification/test_gaze_landmarks.jpg") except Exception as e: print(f"ERROR during normalization: {e}") else: print("FAILURE: No landmarks detected.") if __name__ == "__main__": main()