얼굴 검출

Python으로 배우는 이미지 처리

Rebeca Gonzalez

Data Engineer

얼굴 검출 활용 사례

  • 필터
  • 자동 초점
  • 추천
  • 프라이버시 보호를 위한 블러
  • 이후 감정 인식을 위해

Python으로 배우는 이미지 처리

scikit-image로 얼굴 감지

Python으로 배우는 이미지 처리

scikit-image로 얼굴 감지

# Import the classifier class
from skimage.feature import Cascade

# Load the trained file from the module root. trained_file = data.lbp_frontal_face_cascade_filename()
# Initialize the detector cascade. detector = Cascade(trained_file)
Python으로 배우는 이미지 처리

시도해 봅시다

Python으로 배우는 이미지 처리

얼굴 감지

Python으로 배우는 이미지 처리

얼굴 감지

Python으로 배우는 이미지 처리

얼굴 감지

# Apply detector on the image
detected = detector.detect_multi_scale(img=image,

scale_factor=1.2,
step_ratio=1,
min_size=(10, 10), max_size=(200, 200))
Python으로 배우는 이미지 처리

감지된 얼굴

print(detected)

# Show image with detected face marked show_detected_face(image, detected)
Detected face: [{'r': 115, 'c': 210, 'width': 167, 'height': 167}]

Python으로 배우는 이미지 처리

감지된 얼굴 표시

def show_detected_face(result, detected, title="Face image"):
    plt.imshow(result)
    img_desc = plt.gca()
    plt.set_cmap('gray')
    plt.title(title)
    plt.axis('off')

    for patch in detected:
        img_desc.add_patch(
            patches.Rectangle(
                (patch['c'], patch['r']),
                patch['width'],
                patch['height'],
                fill=False,color='r',linewidth=2)
        )
    plt.show()
Python으로 배우는 이미지 처리

연습해 봅시다!

Python으로 배우는 이미지 처리

Preparing Video For Download...