facial-landmarks-recognition
facial-landmarks-recognition copied to clipboard
Could not build wheels for dlib, which is required to install pyproject.toml-based projects
When I follow your readme to install the imlib I receive the error in the title. I have pasted it on pastebin as it's huge.
https://pastebin.com/PDJVzYM2
Before installing dlib . You need to install some c++ library tools.
CMake: This is because dlib was developed in C based programming language, so it needs this program to use it. It can be found in the link https://cmake.org/download/. To make sure matching with your operating system, in our case is Windows 10 64-bit version.
Visual studio: As I mentioned before, dlib is C based programming language. Another thing that really need is compiler. The Visual studio can be downloaded in the link https://visualstudio.microsoft.com/visual-cpp-build-tools/. After finishing the installation, you need to install additional packages for C, C++ programming, which is Packages CMake tools for Windows.
# import the necessary packages
import numpy as np
from imutils import face_utils
import dlib
import cv2
# initialize dlib's face detector (HOG-based) and then create
# the facial landmark predictor
# pip install numpy opencv-python dlib imutils
p = "shape_predictor_68_face_landmarks.dat"
detector = dlib.get_frontal_face_detector()
predictor = dlib.shape_predictor(p)
cap = cv2.VideoCapture(0)
while True:
# load the input image and convert it to grayscale
_, image = cap.read()
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
# detect faces in the grayscale image
rects = detector(gray, 0)
image = np.zeros((500, 500, 3), dtype="uint8") # 尺寸可以根据需要调整
# 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)
# 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), 3, (0, 255, 0), -1)
# show the output image with the face detections + facial landmarks
cv2.imshow("Output", image)
k = cv2.waitKey(5) & 0xFF
if k == 27:
break
cv2.destroyAllWindows()
cap.release()
`