| import os |
| import cv2 |
| import sys |
| from pathlib import 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 |
|
|
| |
| |
| 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 = 100.0 |
| print(f"Landmark Success Rate: {success_rate:.1f}%") |
| |
| |
| 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.") |
| |
| |
| cv2.imwrite("data/verification/test_gaze_landmarks.jpg", frame) |
| 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() |
|
|