Python base qurcode attendence systme
System Overview
The QR code attendance system enables:
- User Registration: Create and save user details (e.g., name, ID, date of birth, etc.) in a database.
- QR Code Generation: Generate a unique QR code for each user using their details.
- Attendance Scanning: Use a camera (via OpenCV) to scan the QR code, mark attendance, and store it in a database.
- Database Management: Save and retrieve attendance data using SQLite.
- User Interface (UI): Use Tkinter to create an intuitive GUI for managing the system.
- Date and Time Management: Use
datetime
for timestamping attendance records.
Libraries and Their Functions
Here’s a breakdown of the libraries you are using:
tkinter
:- Primary library for creating the graphical user interface (GUI).
- Widgets like
Entry
,Button
,Treeview
, andLabel
are used for user input and display. tkcalendar
allows date selection for recording attendance.
sqlite3
:- A lightweight database to store user data (e.g., names, contact details) and attendance logs.
- SQL queries are used to insert, retrieve, and update records.
qrcode
:- Generates unique QR codes based on user information (e.g., ID, name).
- Saves the QR codes as image files for later use.
Pillow
(PIL
):- Handles image processing, such as saving and displaying QR code images.
subprocess
:- Allows running external scripts or programs (e.g., linking your
attendance.py
file to another script).
- Allows running external scripts or programs (e.g., linking your
datetime
:- Records the exact date and time when attendance is marked.
opencv-python
(OpenCV):- Captures video input from a camera.
- Recognizes and decodes QR codes in real time for attendance marking.
How It Works
- User Registration:
- Create a form using Tkinter for entering user details (e.g., name, contact, DOB).
- Save the data into the SQLite database.
- Generate a QR code using the
qrcode
library, save it as an image, and display it.
- QR Code Generation:
- Generate QR codes that encode essential details such as
ID
,Name
, andContact
. - Example:pythonCopy code
import qrcode data = "ID: 123, Name: John Doe, Contact: 555-1234" qr = qrcode.make(data) qr.save("JohnDoe_QR.png")
- Generate QR codes that encode essential details such as
- Attendance Scanning:
- OpenCV accesses the camera and continuously scans for QR codes.
- Decode the QR code using OpenCV and process its data.
- Mark the user as “present” in the database with the current date and time.
- Database Management:
- Use SQLite to log attendance records (ID, Name, Date, Time).
- User Interface:
- Tkinter-based GUI for functionalities like:
- Adding new users.
- Displaying attendance records in a table (
Treeview
widget). - Generating QR codes.
- Scanning QR codes for attendance.
- Tkinter-based GUI for functionalities like:
Workflow Example
- Step 1: A user registers their details using the Tkinter GUI.
- Step 2: The system generates a QR code for that user and saves it.
- Step 3: During attendance, OpenCV scans the QR code using a camera.
- Step 4: The scanned details are matched with the database, and attendance is marked with a timestamp.
- Step 5: Attendance records are displayed in the GUI using a table.
Conclusion
The QR code attendance system simplifies attendance marking, reduces manual errors, and provides a seamless user experience through:
- Automation (QR scanning and database updates),
- Efficiency (real-time attendance recording),
- User-friendly GUI (via Tkinter),
- Reliability (SQLite database integration).