Skip to content

RajasekharGuptha/facemask-detection-haar-cascade

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 

Repository files navigation

Facemask-Detection-Haar-Cascade

Face mask Detection Haar Cascade file

Used 102 positive images and 176 negative images

Reduce size of image before applying cascade for better results

For Testing we used 300x300 size for all images

import cv2 as cv

fmcascade=cv.CascadeClassifier("facemaskcascade.xml")
image = cv.imread("test_image.jpg")
image = cv.resize(image, (300, 300))
fm = fmcascade.detectMultiScale(image, 1.12,2,None,(120,120),(300,300)) # try with different values for better results

for (x, y, w, h) in fm:
    cv.rectangle(image, (x, y), (x + w, y + h), (0, 0, 0))

cv.imshow("Final Image",image)

If it did not work for any image , convert image to gray mode and then try again

gray_image = cv.cvtColor(image, cv.COLOR_BGR2GRAY)

Note:- Not 100% accurate

About

Face mask Detection Haar Cascade file

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published