多張人臉
在這個練習中,你將在一張影像中偵測多張人臉,並把它們分別顯示出來。可以把這當作為自己的朋友建立人臉資料集的一種方法!
friends_image。feature 模組中的分類器 Cascade 類別已經匯入,show_detected_face() 函式也已匯入。後者用來在影像中標記人臉並將其裁切,以便單獨顯示。
本練習屬於課程
Python 影像處理
練習說明
- 從
data模組載入已訓練檔案.lbp_frontal_face_cascade_filename()。 - 使用已訓練檔案初始化偵測器的階層式分類器(cascade)。
- 在影像中偵測人臉,將
scale_factor設為 1.2、step_ratio設為 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)