File size: 650 Bytes
b3644a6
c09c610
a096f35
b3644a6
c09c610
 
b3644a6
c09c610
 
b3644a6
c09c610
 
b3644a6
c09c610
a096f35
c09c610
b3644a6
c09c610
a096f35
b3644a6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import computervision

# Load the cascade classifier for face detection
face_cascade = computervision.CascadeClassifier('haarcascade_frontalface_alt.xml')

# Load the input image
img = computervision.Image('input_image.jpg')

# Convert the image to grayscale
gray = img.convert_to_grayscale()

# Detect faces in the grayscale image using the Haar cascade
faces = face_cascade.detect_multi_scale(gray, scale_factor=1.1, min_neighbors=5, min_size=(30, 30))

# Draw rectangles around the detected faces
for (x, y, w, h) in faces:
    img.draw_rectangle((x, y), (x+w, y+h), fill=(0, 255, 0))

# Display the output image with the detected faces
img.show()