#!/usr/bin/env python3
"""
Configuration constants and settings for PunimTag
"""

import os
import warnings

# Suppress TensorFlow warnings (must be before DeepFace import)
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
warnings.filterwarnings('ignore')

# Default file paths
DEFAULT_DB_PATH = "data/photos.db"
DEFAULT_CONFIG_FILE = "gui_config.json"
DEFAULT_WINDOW_SIZE = "600x500"

# DeepFace Settings
DEEPFACE_DETECTOR_BACKEND = "retinaface"  # Options: retinaface, mtcnn, opencv, ssd
DEEPFACE_MODEL_NAME = "ArcFace"  # Best accuracy model
DEEPFACE_DISTANCE_METRIC = "cosine"  # For similarity calculation
DEEPFACE_ENFORCE_DETECTION = False  # Don't fail if no faces found
DEEPFACE_ALIGN_FACES = True  # Face alignment for better accuracy

# DeepFace Options for GUI
DEEPFACE_DETECTOR_OPTIONS = ["retinaface", "mtcnn", "opencv", "ssd"]
DEEPFACE_MODEL_OPTIONS = ["ArcFace", "Facenet", "Facenet512", "VGG-Face"]

# Face tolerance/threshold settings (adjusted for DeepFace)
DEFAULT_FACE_TOLERANCE = 0.6  # Default tolerance for face matching
DEEPFACE_SIMILARITY_THRESHOLD = 60  # Minimum similarity percentage (0-100)

# Confidence calibration settings
USE_CALIBRATED_CONFIDENCE = True  # Use calibrated confidence instead of linear transformation
CONFIDENCE_CALIBRATION_METHOD = "empirical"  # Method: "empirical", "linear", "sigmoid"

# Legacy settings (kept for compatibility until Phase 3 migration)
DEFAULT_FACE_DETECTION_MODEL = "hog"  # Legacy - will be replaced by DEEPFACE_DETECTOR_BACKEND
DEFAULT_BATCH_SIZE = 20
DEFAULT_PROCESSING_LIMIT = 50

# Face quality settings
MIN_FACE_QUALITY = 0.3
DEFAULT_CONFIDENCE_THRESHOLD = 0.5

# Face detection filtering settings
MIN_FACE_CONFIDENCE = 0.4  # Minimum confidence from detector to accept face (lowered to allow more low-quality faces)
MIN_FACE_SIZE = 40  # Minimum face size in pixels (width or height) - lowered to allow smaller faces
MAX_FACE_SIZE = 1500  # Maximum face size in pixels (to avoid full-image false positives)

# GUI settings
FACE_CROP_SIZE = 100
ICON_SIZE = 20
MAX_SUGGESTIONS = 10

# Database settings
DB_TIMEOUT = 30.0

# Supported image formats
SUPPORTED_IMAGE_FORMATS = {'.jpg', '.jpeg', '.png', '.bmp', '.tiff', '.tif'}

# Face crop temporary directory
TEMP_FACE_CROP_DIR = "temp_face_crops"
