0% found this document useful (0 votes)
7 views2 pages

Exlpained QR Code Priject

The document outlines a Python script that utilizes OpenCV to create a QR code attendance system for a class of students. It captures video from a camera, detects QR codes corresponding to student names, and marks their attendance as 'Present' or 'Absent' based on the QR code scanned. The program runs in a loop until the user presses the 'q' key, after which it displays the final attendance list.

Uploaded by

dhruvkuckian
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views2 pages

Exlpained QR Code Priject

The document outlines a Python script that utilizes OpenCV to create a QR code attendance system for a class of students. It captures video from a camera, detects QR codes corresponding to student names, and marks their attendance as 'Present' or 'Absent' based on the QR code scanned. The program runs in a loop until the user presses the 'q' key, after which it displays the final attendance list.

Uploaded by

dhruvkuckian
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

exlpain

import cv2

# List of students in the class

students = ["Jash", "Manyu", "Mehaan", "Dhruv", "Abhinava", "Tanish"]

# Dictionary to track attendance

attendance = {student: "Absent" for student in students}

# Open the video capture from your laptop's camera

cap = cv2.VideoCapture(0)

while True:

# Capture frame-by-frame

ret, frame = cap.read()

# Initialize QRCode detector

detector = cv2.QRCodeDetector()

# Detect and decode the QR code

data, bbox, _ = detector.detectAndDecode(frame)

# If there's a QR code detected and data is not empty

if bbox is not None and data:

if data in students:

# Mark the student as present if not already marked

if attendance[data] == "Absent":

attendance[data] = "Present"

print(f"{data} is marked as Present")

else:

print(f"{data} is already marked Present")

# Convert bounding box coordinates to integers

bbox = bbox.astype(int)

# Draw the bounding box

for i in range(len(bbox[0])):

cv2.line(frame, tuple(bbox[0][i]), tuple(bbox[0][(i + 1) % len(bbox[0])]), (0, 255, 0), 2)


# Display the decoded data on the video feed

cv2.putText(frame, f"Name: {data}", (10, 50), cv2.FONT_HERSHEY_SIMPLEX, 1, (255, 255, 255), 2)

else:

print("Invalid QR code")

cv2.putText(frame, "Invalid QR code", (10, 50), cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 0, 255), 2)

# Display the frame

cv2.imshow("QR Code Attendance System", frame)

# Use a breaking condition with 'q' key press to close the window

if cv2.waitKey(1) & 0xFF == ord('q'):

break

# Release the camera and close all OpenCV windows

cap.release()

cv2.destroyAllWindows()

# Display final attendance

print("\nFinal Attendance List:")

for student, status in attendance.items():

print(f"{student}: {status}")

You might also like