LBPH Face Recognition

- AI Developer
- February 2022
- Completed
In numbers
- Face crops captured per person
- 300
- Square grayscale crops for training
- 150px
- Distance under which a face counts as known
- 70
About the Project
LBPH Face Recognition recognizes people from a webcam in three steps, each a small script. The first asks for a name, finds faces in the camera feed with a Haar cascade, and saves 300 grayscale crops of 150×150 pixels into that person's folder. The second trains an LBPH model with one label per person and saves it to a file. The third opens the camera, finds each face and asks the model who it is.
LBPH, Local Binary Patterns Histograms, describes a face by the texture around each pixel instead of learning features with a deep network, so it trains in seconds on a laptop with a few hundred photos. The model returns a label and a distance; a face counts as recognized only when the distance is under 70, and anything else is drawn in red as an unknown face, so the system says it does not know rather than guessing a name.
I built it in February 2022, at university, to understand classical face recognition before moving on to neural networks.
How it works
The path a request takes, step by step.
- PersonSits in front of the webcam
- Haar cascadeFinds faces in each frame
- Capture300 grayscale crops per person
- LBPHOne label per person, saved to a file
- Live resultA name, or an unknown face
Decisions
The choices that shaped it, and what each one cost.
LBPH instead of a deep network
- It describes faces by local texture, so it trains in seconds on a laptop from a few hundred photos.
- It handles pose and angle worse than learned embeddings, and every new person means training again.
Prefer unknown over a wrong name
- A face only gets a name when the distance is under 70; everything else is drawn in red as unknown.
- The threshold is fixed by hand, so a known person in different light can show up as unknown.