เริ่มต้นใช้งานเริ่มต้นใช้งานได้ฟรี

Multiple faces

In this exercise, you will detect multiple faces in an image and show them individually. Think of this as a way to create a dataset of your own friends' faces!

A group of 7 friends
Image preloaded as friends_image.

The Cascade of classifiers class from feature module has already been imported, as well as the show_detected_face() function which is used to display the face marked in the image and crop it so it can be shown separately.

แบบฝึกหัดนี้เป็นส่วนหนึ่งของหลักสูตร

Image Processing in Python

ดูคอร์ส

คำแนะนำการฝึกหัด

  • Load the trained file .lbp_frontal_face_cascade_filename(). from the data module.
  • Initialize the detector cascade with trained file.
  • Detect the faces in the image, setting a scale_factor of 1.2 and step_ratio of 1.

แบบฝึกหัดเชิงโต้ตอบแบบลงมือทำ

ลองทำแบบฝึกหัดนี้โดยเติมโค้ดตัวอย่างนี้ให้สมบูรณ์

# Load the trained file from data
trained_file = ____.___()

# Initialize the detector cascade
detector = ____

# Detect faces with scale factor to 1.2 and step ratio to 1
detected = detector.____(img=friends_image,
                                       scale_factor=____,
                                       step_ratio=____,
                                       min_size=(10, 10),
                                       max_size=(200, 200))
# Show the detected faces
show_detected_face(friends_image, detected)
แก้ไขและรันโค้ด