Skip to main content

Overview

OpenCV provides multiple approaches for face detection and recognition:
  • Haar Cascade Classifiers: Fast, CPU-friendly classical method
  • DNN-based Detection: Modern deep learning approach with YuNet
  • Face Recognition: Feature extraction and matching with SFace
  • Facial Landmarks: Detect eyes, nose, and mouth positions

Haar Cascade Face Detection

DNN-based Face Detection with YuNet

Modern deep learning approach using the YuNet model for accurate face detection with facial landmarks.

Face Recognition with SFace

Compare faces and determine if they belong to the same person.

Key Parameters

Haar Cascade Detection

ParameterDescriptionTypical Value
scaleFactorImage scale reduction between scans1.1 - 1.3
minNeighborsMinimum neighbors for detection3 - 6
minSizeMinimum object size(30, 30)
maxSizeMaximum object sizeImage size

YuNet Detection

ParameterDescriptionTypical Value
score_thresholdConfidence threshold0.6 - 0.9
nms_thresholdNon-maximum suppression0.3 - 0.5
top_kMax detections before NMS5000
Model Downloads: YuNet and SFace models can be downloaded from the OpenCV Zoo:

Performance Tips

1

Optimize Image Scale

Reduce input image size for faster processing:
2

Use Histogram Equalization

Improve detection under varying lighting:
3

Cascade Parameters

Tune minNeighbors to balance speed vs accuracy:
  • Lower values = faster, more false positives
  • Higher values = slower, fewer false positives
4

ROI Processing

Detect nested features only within face regions to improve performance
Privacy Considerations: Face recognition technology should be used responsibly. Always obtain consent when processing personal biometric data and comply with relevant privacy regulations.

Next Steps