Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Python by (170 points)
import cv2, glob

gimage = glob.glob('*.png')
detect = cv2.CascadeClassifier('haarcascade_frontalface_default.xml')

for timage in gimage:
    image = cv2.imread(timage)
    grayimg = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
    face = detect.detectMultiScale(grayimg, 1.25, 3)
    for (x, y, w, h) in face:
        cv2.rectangle(image, (x, y), (x + w, y + h), (0, 255, 0), 2)
    cv2.imshow('Detecting image', image)
    cv2.waitKey(2000)
    cv2.destroyAllWindows()

Please log in or register to answer this question.

Browse Categories

...