여러 얼굴
이 연습에서는 한 이미지에서 여러 얼굴을 탐지하고, 각 얼굴을 개별적으로 표시해 볼 거예요. 나만의 친구 얼굴 데이터셋을 만드는 방법이라고 생각해 보세요!
friends_image로 미리 로드되어 있습니다.feature 모듈의 분류기 Cascade 클래스와, 이미지에서 표시된 얼굴을 보여 주고 잘라서 별도로 표시하는 데 사용하는 show_detected_face() 함수는 이미 임포트되어 있습니다.
이 연습은 강의의 일부입니다
Python으로 배우는 이미지 처리
연습 안내
data모듈에서 학습된 파일.lbp_frontal_face_cascade_filename()을 로드하세요.- 학습된 파일로 탐지기 캐스케이드를 초기화하세요.
- 이미지에서 얼굴을 탐지하되,
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)