dlib

Simba_bΒ·2022λ…„ 10μ›” 28일
0
post-thumbnail

πŸš€ dlib μ‚¬μš©κΈ°

πŸ”—dlib github

colabμ—μ„œ dlib μ‚¬μš©

#git clone
!git clone https://github.com/davisking/dlib.git

# 라이브러리 install
!pip install cmake
!pip install dlib
!pip install imutils
!pip install opencv-python

# shape_predictor_68_face_landmarks κ°€μ Έμ˜€κΈ°
!wget http://dlib.net/files/shape_predictor_68_face_landmarks.dat.bz2
!bzip2 -dk shape_predictor_68_face_landmarks.dat.bz2

λžœλ“œλ§ˆν¬μ°κΈ°

#μ΅œμƒλ‹¨μ— import λ₯Ό μΆ”κ°€ν•œλ‹€.
from google.colab.patches import cv2_imshow

# import the necessary packages
from imutils import face_utils
import numpy as np
import imutils
import dlib
import cv2


def show_raw_detection(image, detector, predictor):
    gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)

    # detect faces in the grayscale image
    rects = detector(gray, 1)

    # loop over the face detections
    for (i, rect) in enumerate(rects):
        # determine the facial landmarks for the face region, then
        # convert the facial landmark (x, y)-coordinates to a NumPy
        # array
        shape = predictor(gray, rect)
        shape = face_utils.shape_to_np(shape)

        # convert dlib's rectangle to a OpenCV-style bounding box
        # [i.e., (x, y, w, h)], then draw the face bounding box
        (x, y, w, h) = face_utils.rect_to_bb(rect)
        cv2.rectangle(image, (x, y), (x + w, y + h), (0, 255, 0), 3)

        # show the face number
        cv2.putText(image, "Face #{}".format(i + 1), (x - 10, y - 10),
                    cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 255, 0), 2)

        # loop over the (x, y)-coordinates for the facial landmarks
        # and draw them on the image
        for (x, y) in shape:
            cv2.circle(image, (x, y), 2, (0, 255, 255), -1)

    # show the output image with the face detections + facial landmarks
    cv2_imshow(image)
    cv2.waitKey(0)

dlib μ‚¬μš©ν•΄μ„œ 68개의 λžœλ“œλ§ˆν¬ 찍기



❓ 강아지가 인식이 μ•ˆλ˜λŠ” 것은 λžœλ“œλ§ˆν¬ 쀑 ν•˜λ‚˜μΈ 눈썹이 μ—†μ–΄μ„œμΌκΉŒ?
강아지 얼꡴에 λžœλ“œλ§ˆν¬μ˜ 일뢀인 λˆˆμΉμ„ κ·Έλ €μ£Όμ—ˆλ”λ‹ˆ 인식 κ°€λŠ₯해짐

0개의 λŒ“κΈ€