https://github.com/lasithaamarasinghe/face-recognition
This project demonstrates a basic face recognition system using Python, OpenCV, and the face_recognition library.
https://github.com/lasithaamarasinghe/face-recognition
cmake computer-vision dlib face-recognition numpy opencv python visualstudiocode
Last synced: 2 months ago
JSON representation
This project demonstrates a basic face recognition system using Python, OpenCV, and the face_recognition library.
- Host: GitHub
- URL: https://github.com/lasithaamarasinghe/face-recognition
- Owner: LasithaAmarasinghe
- License: mit
- Created: 2024-06-13T16:56:24.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2025-02-07T01:51:17.000Z (3 months ago)
- Last Synced: 2025-02-07T02:31:09.225Z (3 months ago)
- Topics: cmake, computer-vision, dlib, face-recognition, numpy, opencv, python, visualstudiocode
- Language: Python
- Homepage:
- Size: 5.66 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: MIT-LICENSE.txt
Awesome Lists containing this project
README
# Face-Recognition
## Overview
- This project demonstrates a basic face recognition system using **[Python](https://www.python.org/)**, **[OpenCV](https://opencv.org/)**, and the **[face_recognition](https://pypi.org/project/face-recognition/)** library.
- The system can encode known faces from images in a directory, recognize faces in an input image, and label the recognized faces.
- This repository contains all the codes and resources of this project.## Steps
- Encoding faces from images stored in a directory.
- Recognizing and label faces in an input image.
- Displaying the input image with labeled faces.## Code
You can find the code for this project here.
* [face_rec.py](https://github.com/LasithaAmarasinghe/Face-Recognition/blob/main/face_rec.py).## Technologies/Tools
* Python 3.10.12
* OpenCV `pip install opencv-python`
* Python packages
* numpy `pip install numpy`
* cmake `pip install cmake`
* dlib `pip install dlib`
* face_recognition `pip install face_recognition`






* C++ compiler - install [Visual Studio](https://visualstudio.microsoft.com/downloads/)## Installation
1. **Clone the repository:**
```bash
git clone https://github.com/LasithaAmarasinghe/Face-Recognition.git
cd Face-Recognition
```
2. **Create and activate a virtual environment (optional but recommended):**```bash
python -m venv venv
source venv/bin/activate # On Windows use `venv\Scripts\activate`
```
3. **Install the required packages:**
```bash
pip install -r requirements.txt
```
## Usage
1. **Prepare the Faces Directory:**
- Create a directory named `faces` in the root of your project.
- Add images of known faces to the `faces` directory. Ensure the images are named with the format `name.jpg` or `name.png`
where `name` is the label you want to assign to the face.
2. **Run the Face Recognition Script:**- Place the image you want to test in the root of your project directory and name it `test.jpg`.
- Run the script:
```bash
python face_rec.py
```
3. **Interact with the Display:**
- The script will display the `test.jpg` image with labeled faces.
- Press 'q' to close the display window.
## Code Explanation- **`get_encoded_faces()`:** This function scans the `faces` directory, encodes each face, and stores the encodings in a dictionary.
- **`unknown_image_encoded(img)`:** This function encodes an unknown face from a given image file.
- **`classify_face(im)`:** This function reads an image, detects faces in it, compares them to the known face encodings, labels the faces,
and displays the image with labeled faces.## Results

## License
* This project is licensed under the MIT License. See the [LICENSE](MIT-LICENSE.txt) file for details.