開始使用免費開始

有人在嗎?

在這個練習中,你要判斷一張夜間拍攝的影像中是否有人物出現。

LAndscape of starry night with a young man in the left bottom corner
影像已預先載入為 night_image

feature 模組中的分類器級聯 Cascade 類別已匯入。同樣地,用於在影像中標記並顯示人臉、以及裁切後另行顯示的人臉的 show_detected_face() 函式也已匯入。

本練習屬於課程

Python 影像處理

檢視課程

練習說明

  • data 模組載入訓練後的檔案。
  • 使用該訓練檔初始化偵測器級聯。
  • 在影像中偵測人臉,並將搜尋視窗的最小尺寸設為 10 像素、最大尺寸設為 200 像素。

動手互動練習

試著完成這個範例程式碼,體驗一下這個練習。

# 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)
編輯並執行程式碼