Skip to content

About

I'm writing the python codes for face recognition using some libraries

Resources

Stars

0 stars

Watchers

1 watching

Forks

Latest commit

 

History

7 Commits

Folders and files

Repository files navigation

Face Recognition App

A real-time face recognition application that captures video from a webcam, detects faces in each frame, matches them against a directory of known reference images, and overlays the recognized name and confidence score on the live feed.

Architecture / Tech Stack

  • Language: Python 3.9+
  • Computer vision: OpenCV (opencv-python)
  • Face detection & encoding: face_recognition (dlib under the hood)
  • Numerical: NumPy
  • Packaging: pyproject.toml with a src/ layout

Project Structure

.
├── faces/                          # Reference images (one face per file, filename = label)
├── src/
│   └── face_recognition_app/
│       ├── __init__.py
│       ├── app.py                  # Entry point (main function)
│       ├── config.py               # Environment-driven settings
│       ├── helpers.py              # Confidence calculation utility
│       └── recognizer.py           # FaceRecognition class
├── main.py                         # Thin launcher for running without installation
├── pyproject.toml
├── requirements.txt
├── .env.example
├── .gitignore
└── README.md

Local Setup & Installation

  1. Clone the repository:

    git clone https://github.com/T0MYAMMM/learn-simple-face-recognition.git
    cd learn-simple-face-recognition
  2. Create and activate a virtual environment:

    python -m venv .venv
    source .venv/bin/activate     # Linux / macOS
    .venv\Scripts\activate        # Windows
  3. Install dependencies:

    pip install -r requirements.txt

    Or install the package itself (editable mode):

    pip install -e .
  4. (Optional) Copy the environment template and adjust values:

    cp .env.example .env
  5. Add reference photos to the faces/ directory. Each file should contain a single clear face. The filename (without extension) is used as the label.

Usage

Run the application directly:

python main.py

Or, after installing the package, use the console script:

face-recognition-app

A window will open showing the webcam feed with bounding boxes, recognized names, and confidence percentages. Press q to exit.

Configurable environment variables (see .env.example):

Variable Default Description
FACES_DIR faces Directory containing reference images
CAMERA_INDEX 0 Camera device index for cv2.VideoCapture
FACE_MATCH_THRESHOLD 0.6 Maximum distance considered a match (0.0 - 1.0)
FRAME_SCALE 0.25 Frame downscale factor used before encoding

Future Improvements

  • Add an automated test suite with sample images and CI integration.
  • Support multiple reference images per person and average their encodings.
  • Persist face encodings to disk to avoid re-encoding on every startup.
  • Provide a CLI subcommand to enroll new faces interactively from the webcam.
  • Add GPU acceleration via dlib CUDA builds for higher frame rates.
  • Replace the OpenCV window with a web UI (FastAPI + WebRTC) for remote use.
  • Add logging and metrics instead of print statements.
  • Containerize the application with Docker for reproducible deployments.

About

I'm writing the python codes for face recognition using some libraries

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages