Analytical face recognition built from inspectable, classical components. No downloaded model weights, no cloud API and no training step are required.
- Detection: Haar cascade face boxes, deterministic and CPU-only.
- Description: local binary pattern histograms plus a gradient orientation histogram, concatenated and L2-normalized into a 4,240-value vector.
- Verification: cosine similarity with a configurable threshold and an explicit explanation of the decision.
- Grouping: K-means over the descriptors, with a full similarity matrix.
- Privacy:
anonymize()blurs detected faces, with explicit boxes supported so a caller can avoid re-detection.
This is a baseline for auditing and teaching, not a state-of-the-art biometric system. Classical descriptors are weaker than learned embeddings. Do not use this for identification decisions about people without human review, consent and a documented legal basis.
pip install -e .faceanalytics detect photo.jpg
faceanalytics verify a.jpg b.jpg --threshold 0.85
faceanalytics cluster a.jpg b.jpg c.jpg --k 2
faceanalytics anonymize photo.jpg private.pngimport cv2
from faceanalytics import detect_faces, verify
a = cv2.imread("a.jpg")
b = cv2.imread("b.jpg")
result = verify(a, b, threshold=0.85)
print(result.as_dict())Every number in a descriptor can be traced to a pixel pattern. That makes it useful for explaining a match, building a small dataset baseline or checking how much a neural model actually adds. The package keeps the pieces separate so a learned backend can be dropped in later without changing the verification interface.
python -m pytest -qMIT licensed.