Attendance Made Easy

Abhiroop Bas
1 min readFeb 7, 2021
Python | Opencv | Haarcascades

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(

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)

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