Phát hiện khuôn mặt

Xử lý ảnh bằng Python

Rebeca Gonzalez

Data Engineer

Ứng dụng phát hiện khuôn mặt

  • Bộ lọc
  • Lấy nét tự động
  • Gợi ý/đề xuất
  • Làm mờ để bảo vệ quyền riêng tư
  • Nhận diện cảm xúc về sau

Xử lý ảnh bằng Python

Phát hiện khuôn mặt với scikit-image

Xử lý ảnh bằng Python

Phát hiện khuôn mặt với 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)
Xử lý ảnh bằng Python

Hãy thử

Xử lý ảnh bằng Python

Phát hiện khuôn mặt

Xử lý ảnh bằng Python

Phát hiện khuôn mặt

Xử lý ảnh bằng Python

Phát hiện khuôn mặt

# 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))
Xử lý ảnh bằng Python

Khuôn mặt đã phát hiện

print(detected)

# Show image with detected face marked show_detected_face(image, detected)
Phát hiện khuôn mặt: [{'r': 115, 'c': 210, 'width': 167, 'height': 167}]

Xử lý ảnh bằng Python

Hiển thị khuôn mặt đã phát hiện

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()
Xử lý ảnh bằng Python

Vamos praticar!

Xử lý ảnh bằng Python

Preparing Video For Download...