0
0
Computer Visionml~10 mins

Why face analysis is a core CV application in Computer Vision - Test Your Understanding

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

Complete the code to load an image using OpenCV for face analysis.

Computer Vision
import cv2
image = cv2.imread([1])
Drag options to blanks, or click blank then click option'
Aimage.jpg
B'face.jpg'
Ccv2.imread
Dface.jpg
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting quotes around the filename
Passing a variable name instead of a string
2fill in blank
medium

Complete the code to convert the image to grayscale, which is common in face analysis.

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

Fix the error in the code to detect faces using a Haar cascade classifier.

Computer Vision
face_cascade = cv2.CascadeClassifier('haarcascade_frontalface_default.xml')
facedetected = face_cascade.[1](gray_image, scaleFactor=1.1, minNeighbors=5)
Drag options to blanks, or click blank then click option'
AdetectMultiScale
BdetectFaces
CdetectFace
DdetectScale
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect method names
Typo in method name
4fill in blank
hard

Fill both blanks to draw rectangles around detected faces and display the image.

Computer Vision
for (x, y, w, h) in facedetected:
    cv2.rectangle(image, (x, y), ([1], [2]), (255, 0, 0), 2)
cv2.imshow('Faces', image)
cv2.waitKey(0)
cv2.destroyAllWindows()
Drag options to blanks, or click blank then click option'
Ax + w
By + h
Cx - w
Dy - h
Attempts:
3 left
💡 Hint
Common Mistakes
Subtracting width or height instead of adding
Swapping x and y coordinates
5fill in blank
hard

Fill all three blanks to create a dictionary of face bounding boxes with keys as face IDs.

Computer Vision
faces_dict = {f'face_[1]': (x, y, [2], [3]) for [1], (x, y, w, h) in enumerate(facedetected)}
Drag options to blanks, or click blank then click option'
Ai
Bw
Ch
Dindex
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong variable names
Mixing up width and height