0
0
Computer Visionml~10 mins

Face recognition concept in Computer Vision - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to load an image for face recognition.

Computer Vision
import cv2
image = cv2.imread([1])
print(image.shape)
Drag options to blanks, or click blank then click option'
Aload('face.jpg')
B'face.jpg'
Cface.jpg
Dread('face.jpg')
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting quotes around the file name
Using a function that does not exist like load() or read()
2fill in blank
medium

Complete the code to convert the image to grayscale for face detection.

Computer Vision
gray_image = cv2.cvtColor(image, [1])
print(gray_image.shape)
Drag options to blanks, or click blank then click option'
Acv2.COLOR_BGR2GRAY
Bcv2.COLOR_BGR2RGB
Ccv2.COLOR_RGB2GRAY
Dcv2.COLOR_GRAY2BGR
Attempts:
3 left
💡 Hint
Common Mistakes
Using RGB instead of BGR conversion codes
Converting grayscale back to color by mistake
3fill in blank
hard

Fix the error in the face detection code by filling the correct method name.

Computer Vision
face_cascade = cv2.CascadeClassifier('haarcascade_frontalface_default.xml')
facedetect = face_cascade.[1](gray_image, scaleFactor=1.1, minNeighbors=5)
print(len(facedetect))
Drag options to blanks, or click blank then click option'
AdetectMultiScale
BdetectFaces
CfindFaces
Ddetect_face
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect method names that do not exist
Confusing method names with other libraries
4fill in blank
hard

Fill both blanks to create a dictionary of face locations with width and height.

Computer Vision
faces_info = {i: (x, y, [1], [2]) for i, (x, y, w, h) in enumerate(facedetect)}
print(faces_info)
Drag options to blanks, or click blank then click option'
Aw
Bh
Cx
Dy
Attempts:
3 left
💡 Hint
Common Mistakes
Using x or y instead of width and height
Mixing up the order of values
5fill in blank
hard

Fill all three blanks to draw rectangles around detected faces on the image.

Computer Vision
for (x, y, w, h) in facedetect:
    cv2.rectangle(image, ([1], [2]), (x + w, y + h), [3], 2)
cv2.imshow('Faces', image)
cv2.waitKey(0)
cv2.destroyAllWindows()
Drag options to blanks, or click blank then click option'
Ax
By
C(255, 0, 0)
D(0, 255, 0)
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping x and y coordinates
Using wrong color tuples