This project is a face recognition-based attendance system that uses OpenCV, face_recognition, and Google Sheets for recording attendance. The system captures video from the webcam, recognizes faces, and marks attendance to a Google Sheet. In the absence of an internet connection, it print a message indicating the lack of connectivity.
- Real-Time Face Recognition : Captures video from the webcam and performs face recognition in real-time.
- Face Encoding : Encodes known faces from a specified directory.
- Marks Attendance Automatically : Logs the name and timestamp of recognized faces to a Google Sheet automatically.
- Access Attendance Sheet on Desktop and Smartphone : You can track real-time attendance in Google Sheet on
Desktop
as well as on yourSmartphone
. - Offline Handling : Detects if there is no internet connection and prints a message "No internet connection." and stop the program.
- Daily Logs : Creates a new sheet in the Google Sheets document for each day, organizing attendance records by date.
- Clone the Repository :
https://github.com/Param-Sahu/Face_Recognition_Based_Attendance_System.git
- Install Dependencies :
- OpenCV and Face_Recognition :
pip install opencv-python face-recognition
- Install Google Sheet API in Python
- For Windows
pip install google-api-python-client google-auth-httplib2 google-auth-oauthlib gspread
- For Mac
pip3 install google-api-python-client google-auth-httplib2 google-auth-oauthlib gspread
- Set Up Google Sheets API : Save the
credentials.json
file in the project directory (i.e. In the same folder wheremain.py
is saved). - Prepare Images : Make sure images of known individuals should be in the
attendance_project/images
directory. - Internet Connection : Make sure you are connected to internet to run this program smoothly.
- The script will open the webcam and start capturing frames.
- It will attempt to recognize faces from the frames.
- If a face is recognized and attendance for the day is not already marked, it will log the name and timestamp in the Google Sheets document.
- If there is no internet connection, it will print "No internet connection." and stop the program.
Loading and Encoding Faces :
- The
load_images_and_encode_faces
function loads face images from the specified directory and encodes them using theface_recognition
library.
Google Sheets Setup :
- The script uses the
gspread
library to connect to Google Sheets using the provided service account credentials. - It creates a new sheet for the current date if it doesn't already exist.
Face Recognition and Attendance Logging :
- The webcam captures frames which are processed to detect and recognize faces.
- Recognized faces are checked against the attendance log for the day.
- If a face is recognized and attendance is not already marked, the name and timestamp are logged in the Google Sheets document.
- Ensure the Google Sheets API is enabled for your Google Cloud project and the service account has edit access to the Google Sheets document.
- You can configure the script to run for a different duration or adjust other parameters as needed.