πdlib github
#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)
β κ°μμ§κ° μΈμμ΄ μλλ κ²μ λλλ§ν¬ μ€ νλμΈ λμΉμ΄ μμ΄μμΌκΉ?
κ°μμ§ μΌκ΅΄μ λλλ§ν¬μ μΌλΆμΈ λμΉμ κ·Έλ €μ£Όμλλ μΈμ κ°λ₯ν΄μ§