Attendance Made Easy

The problem

I realized one of the major problems in the online era was faced by the teachers. Online classes are just the tip of the iceberg. As I would personally supply teachers with the screenshots as attendance, I realized the effort the teacher needed to give into maintaining a proper register for the same on a daily basis.

The solution

Hence as I was learning opencv and the haarcascade library, I really wanted to do something for my teachers. The following code enables one to get the number of attendees in a big meeting for example. This will be particularly useful while compiling the attendance for an entire semester.

The code

import cv2
import sys

print(“Enter the path of the image”)
imagePath = input()
cascPath = “haarcascade_frontalface_default.xml”

faceCascade = cv2.CascadeClassifier(cascPath)

image = cv2.imread(imagePath)
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)

faces = faceCascade.detectMultiScale(
gray,
scaleFactor=1.1,
minNeighbors=5,
minSize=(1,1),
flags = cv2.CASCADE_SCALE_IMAGE
)

print(“{0} faces detectd!”.format(len(faces)))

for (x, y, w, h) in faces:
cv2.rectangle(image, (x, y), (x+w, y+h), (0, 255, 0), 2)

cv2.imshow(“Faces Detected”, image)
cv2.waitKey(0)

Please feel free to send in suggestions or collaborations on the project.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store