ML Face Detection Project
ML Face Detection Project
Narisetty Sumanth
Project Overview
• Objective:
• - Detect faces using Haar Cascade classifier
• - Validate faces using an SVM based on width &
height features
• Technologies Used:
• - Python
• - OpenCV
• - Machine Learning (SVM)
Face Detection - Haar Cascade
• Description:
• - Haar features are used to identify face patterns
• - Pre-trained XML model from OpenCV is loaded for
detection
• Code Snippet:
• face_cascade = cv2.CascadeClassifier(cv2.data.haarcascades
+ 'haarcascade_frontalface_default.xml')
• faces = face_cascade.detectMultiScale(gray,
scaleFactor=1.1, minNeighbors=7)
SVM for Face Validation
• Purpose:
• - Verify if detected face is valid using width and height
• - SVM is trained on synthetic data
• Code Snippet:
• train_data = np.array([[30, 30], ..., [200, 200]],
dtype=np.float32)
• train_labels = np.array([1, 1, ..., 0], dtype=np.int32)
• svm.train(train_data, cv2.ml.ROW_SAMPLE,
train_labels)
Real-Time Face Detection
• Pipeline:
• 1. Capture frame from webcam
• 2. Flip for mirror effect
• 3. Convert to grayscale
• 4. Detect and validate faces
• 5. Draw rectangles and labels
• Code Snippet:
• cap = cv2.VideoCapture(0)
• ret, frame = cap.read()
• gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
Display & User Interface
• Display Features:
• - Bounding box around valid faces
• - Total face count shown live
• - Exit on 'q' key press
• Code Snippet:
• cv2.putText(frame, f'Total Faces: {face_count}', ...)
• cv2.imshow('ML-Enhanced Face Detection', frame)
Challenges
• - Limited features for SVM (only width &
height)
• - Haar Cascade may miss some faces or detect
false positives
• - Real-time performance depends on system
speed
Future Enhancements
• - Use deep learning models like DNN or YOLO
for better accuracy
• - Train SVM on more robust features (e.g.,
HOG, LBP)
• - Add face recognition (identify individuals)
Demo & Results
• Live Demo: [Add screenshots or demo video link]