A simple and efficient face recognition attendance system using OpenCV and Python for windows,linux and mac. The system stores attendance records in CSV format, making it lightweight and easy to use. unknown faces are stored in the unknown_faces
folder.
- Real-time face detection and recognition
- Automated attendance marking
- CSV export functionality for attendance records
- Multiple face recognition support
- High accuracy using deep learning models
- Attendance history tracking
- Easy user registration system
- Unrecognized faces storage in
unknown_faces
folder - Detailed logging system
-
add the images of the people with their names as the image name in the
database1
folder. example:barack_obama.jpg
// not neccessary to save the images with the name of the person as the image name -
add the image name and the name of the person you want to associate with that image in the
store1.csv
file. // you can import a file with the formatname
image_name
if you want to import your own file ,change the file name or the file path in the attendance scripts example:barack_obama.jpg
,barack_obama
-
Install Python (preferably 3.7.6 since requirements_windows.txt is for 3.7.6, to do a maual installation use python 3.11.0 for latest dlib libraries):
- Download Python from python.org
- During installation, make sure to check "Add Python to PATH"
-
Install all required packages:
pip install -r requirements_windows.txt
Note: If you encounter any installation errors, refer to the Troubleshooting section below.
-
Install system dependencies:
sudo apt-get update sudo apt-get install -y make build-essential libssl-dev zlib1g-dev \ libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev \ libncursesw5-dev xz-utils tk-dev libffi-dev liblzma-dev python-openssl \ git libgtk2.0-dev pkg-config
-
Install pyenv:
curl https://pyenv.run | bash
-
Add pyenv to your PATH (add these to your ~/.bashrc or ~/.zshrc):
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bashrc echo 'command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc echo 'eval "$(pyenv init -)"' >> ~/.bashrc
-
Reload your shell configuration:
source ~/.bashrc
-
Install Python 3.7.6 using pyenv:
pyenv install 3.7.6 cd folder_you_want_to_install_in pyenv local 3.11.0
-
Create and activate a virtual environment:
python -m venv test3.11.0 source test3.11.0/bin/activate
-
Install required packages:
pip install -r requirements_linux.txt
OR
# Install CMake first pip install cmake # Install dlib with specific version pip install dlib==19.24.0 # Install face_recognition and opencv pip install face_recognition==1.3.0 pip install opencv-python
Note: If you encounter any installation errors, refer to the Troubleshooting section below.
-
Install Homebrew (if not already installed):
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
-
Install pyenv using Homebrew:
brew install pyenv
-
Add pyenv to your shell configuration. Add these lines to your ~/.zshrc or ~/.bash_profile:
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.zshrc echo 'command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.zshrc echo 'eval "$(pyenv init -)"' >> ~/.zshrc
-
Restart your terminal or reload the configuration:
source ~/.zshrc
-
Install Python using pyenv:
pyenv install 3.11.0 cd folder_you_want_to_install_in pyenv local 3.11.0
-
Create and activate a virtual environment:
python -m venv test3.11.0 source test3.11.0/bin/activate
-
Install dependencies:
# Install Xcode Command Line Tools if not already installed xcode-select --install # Install CMake using Homebrew brew install cmake # Install Python dependencies pip install -r requirements_mac.txt
-
Run the main application:
python attendance_opencv_2.0.py # On Windows python linux_attendance_opencv_2.0.py # On Linux python linux_attendance_opencv_2.0.py # On macOS
-
The system will:
- Detect faces through your camera/ you can choose one or more external cameras
- Recognize registered individuals
- Store attendance in CSV format
- Save unrecognized faces in the
unknown_faces
folder for later review
- Ensure good lighting conditions for better face recognition
- Keep the camera stable for accurate results
- Make sure to register faces before attempting recognition
- Check the
unknown_faces
folder periodically to review and potentially register new faces - The system automatically creates the
unknown_faces
folder if it doesn't exist
- Processor: Intel Core i3 or equivalent
- RAM: 4GB
- Storage: 1GB free space
- Camera: 720p webcam
- Processor: Intel Core i5 or better
- RAM: 8GB
- Storage: 2GB free space
- Camera: 1080p webcam(works on low resolution cameras but not that well)
- Face Detection Speed: <50ms per frame
- Recognition Accuracy: >95%
- False Positive Rate: <0.1%
- Maximum Simultaneous Faces: 10
If you encounter: RuntimeError: Unsupported image type, must be 8bit gray or RGB image
Solution:
- Verify you're using 24-bit RGB images
- Try different image files(sometimes a half face or a blurred image can cause this error)
- Ensure you're using Python 3.7:
python --version
This usually occurs due to missing CMake and dlib dependencies.
Solution:
pip install CMake
pip install dlib
If you can't install dlib through pip, follow these alternative steps:
-
Download dlib:
- Visit dlib GitHub repository or find the dlib.whl for py-3.7.6 in this repository
- Download the ZIP file
- Extract the downloaded file
-
Install the correct wheel file:
- Check your Python version:
python --version
- For Python 3.7: Use
dlib-19.22.99-cp37-cp37m-win_amd64.whl
- Copy the wheel file to your project directory
- Install using:
pip install dlib-19.22.99-cp37-cp37m-win_amd64.whl
Note: Use the appropriate wheel file version matching your Python version
- Check your Python version:
To avoid dependency conflicts, use a virtual environment:
-
In your code editor:
- Click on the Python version in the bottom right
- Choose "Create a Virtual Environment"
- Select Python 3.7.6
-
Activate the virtual environment:
# Windows .\venv\Scripts\activate # Linux/Mac source venv/bin/activate
-
Install required packages in the virtual environment:
pip install -r requirements.txt
If you encounter: cv2.error: OpenCV... The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Cocoa support
Solution:
sudo apt-get update
sudo apt-get install libgtk2.0-dev pkg-config
pip uninstall opencv-python
pip install opencv-python
If you see: Gtk-Message: Failed to load module "canberra-gtk-module"
Solution:
sudo apt-get install -y libglib2.0-0 libsm6 libxext6 libxrender-dev libgl1-mesa-glx
sudo apt-get install -y python3-opencv
pip uninstall opencv-python opencv-python-headless
pip install opencv-python --no-cache-dir
If you encounter: TypeError: compute_face_descriptor(): incompatible function arguments
Solution:
# First, install system dependencies
sudo apt-get install build-essential cmake
sudo apt-get install libopenblas-dev liblapack-dev
sudo apt-get install libx11-dev libgtk-3-dev
# Then install compatible versions of dlib and face_recognition
pip uninstall dlib face_recognition
pip install dlib==19.24.0
pip install face_recognition==1.3.0
-
Planned Features
- Mobile application integration
- Cloud synchronization
- Advanced analytics dashboard
- Multi-location support
- API integration capabilities
-
Under Development
- Automated reporting system
contributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch
- Commit changes
- Push to the branch
- Create a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
For support and queries:
- Create an issue in the repository
- Contact: neutralwritergithubdedicated@gmail.com
- Documentation: Wiki
- OpenCV community
- dlib developers
- v2.0 (Current): Added anti-spoofing, improved GUI
- v1.5: Multiple face recognition support
- v1.0: Initial release with basic features
Active development - Regular updates and maintenance ongoing.