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.prototxtage_net.caffemodelPlace 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.csvPDF Report:
logs/report.pdfThe 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.