Skip to content

About

Real-time webcam face recognition (OpenCV Haar cascade + LBPH) packaged as double-click Windows apps — no dlib/CMake needed.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Face Recognition

Real-time face recognition using your webcam, built with OpenCV (Haar cascade for detection + LBPH for recognition). No dlib/CMake build required — this stack installs cleanly on Windows via pip.

Quick start: double-click apps

No Python needed — just double-click, in this order:

  1. CaptureFaces.exe — pops up a name box, then opens the webcam to capture face samples for that person.
  2. TrainModel.exe — retrains on everyone captured so far, shows a "done" popup.
  3. Recognize.exe — live webcam recognition window. Green box + name = match, red box + "Unknown" = no confident match.
  4. ManagePeople.exe — table of everyone enrolled (photo, name, registration date, sample count). Select a row and click Delete Selected to remove someone; it deletes their photos and automatically retrains the model so they stop being recognized.

These are self-contained builds (produced with PyInstaller from the .py files below) — rebuild them if you edit the source, see "Rebuilding the exes" below.

Setup (for running/editing the Python source)

python -m venv .venv
.venv\Scripts\activate
pip install -r requirements.txt

Usage (Python source)

  1. Capture samples for each person you want to recognize (repeat per person):

    python capture_faces.py "Alice" --samples 30

    This opens your webcam and saves cropped face images to dataset/Alice/. Move your head slightly during capture for better coverage.

  2. Train the model on everyone captured so far:

    python train_model.py

    Produces trainer.yml (the model) and labels.pickle (id -> name map).

  3. Run live recognition:

    python recognize.py

    Opens your webcam, draws a box around each detected face, and labels it with the closest known match (green) or "Unknown" (red) if the match isn't confident enough. Press q to quit.

    Tune matching strictness with --confidence-threshold (LBPH reports a distance — lower is a better match; default 70, lower it for stricter matching, raise it if known people are getting labeled "Unknown").

  4. Remove someone:

    python manage_people.py

    Opens the same table/delete GUI as ManagePeople.exe.

Adding or removing people later

  • Add: run capture_faces.py (or CaptureFaces.exe) with a new name, then retrain.
  • Remove: run manage_people.py (or ManagePeople.exe) and delete their row — retraining happens automatically.

Either way, no exe rebuild is required — trainer.yml/labels.pickle live next to the exes and are read fresh each run.

Rebuilding the exes

Only needed after editing the .py source:

.venv\Scripts\python.exe -m pip install pyinstaller
.venv\Scripts\python.exe -m PyInstaller --onefile --noconsole --name CaptureFaces --add-data "haarcascade_frontalface_default.xml;." --distpath . --workpath build --specpath build --collect-all cv2 capture_faces.py
.venv\Scripts\python.exe -m PyInstaller --onefile --noconsole --name TrainModel --distpath . --workpath build --specpath build --collect-all cv2 train_model.py
.venv\Scripts\python.exe -m PyInstaller --onefile --noconsole --name Recognize --add-data "haarcascade_frontalface_default.xml;." --distpath . --workpath build --specpath build --collect-all cv2 recognize.py
.venv\Scripts\python.exe -m PyInstaller --onefile --noconsole --name ManagePeople --distpath . --workpath build --specpath build --collect-all cv2 manage_people.py

Use an absolute path for haarcascade_frontalface_default.xml in --add-data if you run these from outside the project directory — a relative path resolves against --specpath, not your current directory.

Project layout

capture_faces.py   # webcam -> dataset/<name>/*.jpg
train_model.py      # dataset/ -> trainer.yml + labels.pickle
recognize.py         # webcam + trainer.yml -> live recognition
manage_people.py      # table view + delete a person (and their data)
face_utils.py          # shared helpers: low-light preprocessing, exe-safe paths, popups
dataset/                # captured face images (gitignored)
*.exe                    # compiled double-click apps (gitignored, rebuild from source)

About

Real-time webcam face recognition (OpenCV Haar cascade + LBPH) packaged as double-click Windows apps — no dlib/CMake needed.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages