MulaiMulai sekarang secara gratis

Is someone there?

In this exercise, you will check whether or not there is a person present in an image taken at night.

LAndscape of starry night with a young man in the left bottom corner
Image preloaded as night_image.

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

Latihan ini adalah bagian dari kursus

Image Processing in Python

Lihat Kursus

Petunjuk latihan

  • Load the trained file from the data module.
  • Initialize the detector cascade with the trained file.
  • Detect the faces in the image, setting the minimum size of the searching window to 10 pixels and 200 pixels for the maximum.

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

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

# Initialize the detector cascade
detector = ____(____)

# Detect faces with min and max size of searching window
detected = detector.detect_multi_scale(img = night_image,
                                       scale_factor=1.2,
                                       step_ratio=1,
                                       min_size=(____),
                                       max_size=(____))

# Show the detected faces
show_detected_face(night_image, detected)
Edit dan Jalankan Kode