Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
mochiron-desu authored Oct 13, 2024
1 parent 4cc8308 commit 316b07a
Showing 1 changed file with 94 additions and 2 deletions.
96 changes: 94 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,94 @@
# faceRecognitionAndSearcher

# Face Recognition and Search Application

## Overview
This repository contains a face recognition and search system built with Python. The application allows for the detection, encoding, and storage of facial data in a MongoDB database. It supports searching for similar faces based on the stored data and provides a graphical user interface (GUI) to manage the face search and display results.

## Features
- **Face detection and recognition:** Extract faces from images, encode them, and save unique faces to a database.
- **Database management:** Stores face encodings and image metadata using MongoDB.
- **Face search functionality:** Find similar faces from the database using face encoding comparison.
- **Graphical User Interface (GUI):** Built with Tkinter for managing face data and searching faces. (to be updated)
- **Logging:** Application logs all key actions and events to a log file and console.

## Project Structure

```
.
├── database.py # Handles MongoDB operations and face encoding storage/retrieval
├── face_detection.py # Processes images, detects faces, and manages face data storage
├── gui.py # GUI implementation for searching and displaying face data
├── main.py # Entry point for running the GUI application
├── search.py # Contains functions to search faces by ID
├── images/ # Folder where input images are stored
└── unique_faces/ # Folder where unique face images are saved
```

## Dependencies
Make sure you have the following libraries installed before running the code:
- `pymongo`: For database operations.
- `face_recognition`: For facial recognition and encoding.
- `opencv-python`: For image processing.
- `pillow`: For handling images in the GUI.
- `tkinter`: For GUI development (comes pre-installed with Python).
- `numpy`: For handling face encoding data.

Install all dependencies via `pip`:

```bash
pip install pymongo face_recognition opencv-python pillow numpy
```

or

```bash
pip install -r requirements.txt
```

## Usage

### 1. Setting Up MongoDB
Ensure that MongoDB is running on `localhost:27017` and the database `face_recognition_db` is created. The face encodings and metadata will be stored in the `faces_collection`.

### 2. Running the Face Processing Script
To extract and save unique faces from images:

1. Place your images in the `images/` folder.
2. Run the following script to detect faces and store them in MongoDB:

```bash
python face_detection.py
```

This will:
- Extract faces from the images.
- Store each unique face's encoding and associated metadata in MongoDB.
- Save each detected face as an image in the `unique_faces/` folder.

### 3. Running the GUI Application
To launch the face search interface:

```bash
python main.py
```

The GUI will display all unique faces. You can select a face and search for its occurrences in the images.

### 4. Searching Faces
- **Select a face**: Click on a face from the GUI.
- **Search for occurrences**: Click the "Search Selected Face" button to find where this face appears across the images.

## Logging
All key operations (face detection, saving, searching) are logged into `app.log`. You can change the logging level for more or less verbosity by modifying the `logging.basicConfig` configuration in each file.

## Customization

- **Face Similarity Tolerance**: Adjust the `FACE_SIMILARITY_TOLERANCE` constant in `database.py` to change how strict the face similarity comparison is.
- **Unique Faces Directory**: Change the folder where unique faces are saved by modifying the `unique_faces_folder` path in `face_detection.py`.

## Troubleshooting
- Ensure MongoDB is running and accessible at `localhost:27017`.
- Make sure the required Python dependencies are installed.
- Check `app.log` for detailed error logs.

## License
This project is licensed under the MIT License.

0 comments on commit 316b07a

Please sign in to comment.