DEV Community

Cover image for Real-Time Face Recognition Attendance β€” QR Access & Google Sheets Integration
Akshaya Reddy Annareddy
Akshaya Reddy Annareddy

Posted on

Real-Time Face Recognition Attendance β€” QR Access & Google Sheets Integration

πŸš€ This project automates classroom attendance using Face Recognition (MTCNN + FaceNet) integrated with Flask and Google Sheets.

It captures student faces in real-time, marks attendance automatically, and even generates a QR link to access the system from mobile devices.


🧭 Introduction

Attendance tracking is one of the most time-consuming classroom tasks.

Traditional methods β€” roll calls or manual entries β€” are inefficient and error-prone.

To make attendance seamless and contactless, I built a Real-Time Face Recognition Attendance System using MTCNN for face detection, FaceNet for feature extraction, and Flask for the web interface.

The project connects directly with Google Sheets to store attendance records automatically, and a QR link allows mobile access for real-time participation.


🧰 Tools & Technologies Used

Component Technology
Programming Language Python
Framework Flask
Face Detection MTCNN
Face Embedding FaceNet
Model Classifier SVM
Data Storage Google Sheets API
QR Code Generation qrcode library
Deployment Ngrok (for temporary public access)

πŸ§‘β€πŸ’» How I Built It (Step-by-Step)

🧩 1. Dataset Preparation

  • Collected 20–40 images of 7 different students.
  • Stored them in Google Drive as the training dataset.
  • Each student had a separate folder (named by student name or ID).
  • Used these images to train the recognition model.

🧠 2. Face Detection & Feature Extraction

  • Used MTCNN to detect faces in each image.
  • Extracted 128-dimensional embeddings using FaceNet.
  • Trained an SVM (Support Vector Machine) classifier on the embeddings to identify each student.

☁️ 3. Integration with Google Sheets

  • Created a Google Cloud Project and enabled the Google Sheets API.
  • Generated a credentials.json file for authorization.
  • Every time a recognized face is detected, the app automatically logs:
    • Student Name
    • Date
    • Time into a Google Sheet.

🌐 4. Flask Web Application

  • Built a simple Flask app with routes:
    • /capture β€” to start the webcam and capture the face.
    • /submit β€” to log attendance and show confirmation.
  • Used Ngrok to get a temporary public URL, enabling mobile access and testing on different devices.

πŸ”³ 5. QR Code Integration

  • Integrated the qrcode Python library to generate a scannable QR that links directly to the Flask web interface.
  • This allows lecturers and students to access the app instantly on their mobile devices β€” no manual typing needed!

πŸ“Š Results & Observations

The system successfully recognized faces in real-time and logged attendance to Google Sheets.

βœ… For recognized students β€” attendance was marked automatically.

❌ For unrecognized faces β€” the system displayed β€œFace not matched.”

⚠️ For multiple detected faces β€” the system warned β€œMultiple faces detected.”


🌟 Key Features

  • Real-time face recognition
  • Google Sheets API integration
  • QR access for mobile users
  • Automatic attendance logging
  • Handles unknown or multiple faces gracefully

🚧 Limitations

  • Requires proper lighting for accurate face recognition
  • Performance may reduce if multiple students appear simultaneously
  • Ngrok provides only a temporary public link (not permanent hosting)

πŸš€ Future Enhancements

In future versions, I plan to:

  • Replace Google Sheets with a dedicated database for student records.
  • Implement dynamic QR codes that refresh every 10–15 seconds for secure attendance sessions.
  • Allow lecturers to log in and:
    • Create QR codes for each class session.
    • Edit attendance records manually (for excused absences or missed scans).

πŸ“š Learnings

This project helped me understand:

  • How to integrate ML models into web applications.
  • Working with Google Cloud APIs for automation.
  • Using Flask + Ngrok for real-time deployment and testing.
  • Managing end-to-end data flow from detection to cloud logging.

πŸ“‚ GitHub Repository

πŸ”— View Full Project on GitHub


🧠 Conclusion

This project demonstrates how AI can automate an everyday classroom task β€” attendance marking β€” in an efficient, contactless, and scalable way.

It’s a simple yet powerful example of how deep learning and web development can combine to solve real-world problems.


πŸ’¬ If you found this post helpful, don’t forget to leave a like or comment β€” I’d love to connect with you!

Top comments (0)

Some comments may only be visible to logged-in visitors. Sign in to view all comments.