0
0
Computer Visionml~12 mins

Haar cascade face detection in Computer Vision - Model Pipeline Trace

Choose your learning style9 modes available
Model Pipeline - Haar cascade face detection

This pipeline detects faces in images using Haar cascade classifiers. It scans the image with a sliding window, checking for face-like patterns using simple features. The process quickly finds faces by combining many small decisions.

Data Flow - 7 Stages
1Input Image
1 image x 480 height x 640 width x 3 color channelsLoad color image from camera or file1 image x 480 x 640 x 3
A photo of a person with a visible face
2Convert to Grayscale
1 image x 480 x 640 x 3Convert color image to single channel grayscale1 image x 480 x 640
Grayscale version of the photo with brightness values
3Image Scaling (Pyramid)
1 image x 480 x 640Create smaller versions of the image to detect faces at different sizesMultiple images at scales: 480x640, 360x480, 240x320, ...
Scaled images to find small and large faces
4Sliding Window Scan
Each scaled imageMove a fixed-size window over the image to check for face featuresMany windows of size 24x24 pixels scanned
Window at position (100, 150) in 240x320 image
5Feature Extraction with Haar-like Features
Window of 24x24 pixels grayscaleCalculate simple features like edges and lines using sums of pixel areasFeature vector of fixed length (e.g., 100 features)
Feature vector showing presence of edges in window
6Cascade Classifier Decision
Feature vectorPass features through a series of simple classifiers that quickly reject non-facesDecision: face or no face for each window
Window classified as face with confidence score
7Face Detection Output
Decisions for all windows across scalesCombine overlapping detections to finalize face bounding boxesList of bounding boxes with coordinates and sizes
Detected face at (x=120, y=130, width=60, height=60)
Training Trace - Epoch by Epoch
Loss
0.5 |****
0.4 |*** 
0.3 |**  
0.2 |*   
0.1 |    
    +-----
     1 2 3 4 Epoch
EpochLoss ↓Accuracy ↑Observation
10.450.75Initial training with many false positives
20.300.85Cascade stages start rejecting non-faces better
30.200.92Good balance between detection and false alarms
40.150.95Final cascade stages fine-tuned for accuracy
Prediction Trace - 7 Layers
Layer 1: Input Image
Layer 2: Convert to Grayscale
Layer 3: Image Scaling
Layer 4: Sliding Window Scan
Layer 5: Feature Extraction
Layer 6: Cascade Classifier
Layer 7: Combine Detections
Model Quiz - 3 Questions
Test your understanding
Why do we convert the input image to grayscale before detection?
ATo add color information for better detection
BTo simplify data and reduce computation
CTo increase image size for better accuracy
DTo remove faces from the image
Key Insight
Haar cascade face detection uses simple features and a fast decision process to find faces efficiently. The cascade structure helps reject non-face areas quickly, making it suitable for real-time applications.