This application detects faces in real-time using a webcam, recognizes known faces, estimates emotions and ages, and generates detailed reports (CSV and PDF) based on the detection logs. It uses advanced libraries like face_recognition
, dlib
, and OpenCV
for face detection, emotion recognition, and age estimation.
Real-Time Face Detection:
face_recognition
.Emotion Recognition:
Age Estimation:
Known Face Recognition:
known_faces
directory.Log Generation:
logs/detection_log.txt
).Report Generation:
Error Handling:
Install the required libraries using the following command:
pip install opencv-python dlib face_recognition pandas fpdf
Download the following pre-trained models and place them in the project directory:
deploy_age.prototxt
age_net.caffemodel
Place these files in the root directory of the project.
The project has the following structure:
project/
│
├── known_faces/ # Directory to store known face images
│ ├── Alice/
│ │ ├── Alice_20231005_143005.jpg
│ ├── Bob/
│ │ ├── Bob_20231005_143200.jpg
│
├── logs/ # Directory to store logs and reports
│ ├── detection_log.txt
│ ├── report.csv
│ ├── report.pdf
│
├── shape_predictor_68_face_landmarks.dat
├── deploy_age.prototxt
├── age_net.caffemodel
├── app.py # Main script
└── README.md # This file
Start the application by running the following command:
python app.py
The webcam will open, and the system will start detecting faces in real-time.
Key Commands:
q
to quit the application.r
to generate a CSV and PDF report.known_faces
directory under subfolders named after the person (e.g., known_faces/Alice/
).When you press r
, the system generates two reports:
CSV Report:
logs/report.csv
PDF Report:
logs/report.pdf
The log file (logs/detection_log.txt
) contains entries like this:
2023-10-05 14:30:00 - Name: Alice, Emotion: happy, Age: (25-32) (Est: 28)
2023-10-05 14:30:01 - Name: Bob, Emotion: angry, Age: (38-43) (Est: 40)
If the log file (logs/detection_log.txt
) is missing:
logs
directory exists. If not, create it manually:
mkdir logs
scaleFactor
and minNeighbors
parameters in the detectMultiScale
function if necessary.dlib
, ensure you have the required build tools installed:
cmake
and build-essential
.Contributions are welcome! If you find any bugs or want to add new features, feel free to submit a pull request.
There are no models linked
There are no datasets linked
There are no models linked
There are no datasets linked