On the internet to see a lot of saying that the installation of dlib before the need to install CMake and boost, but also said that need to install VS2015 support the latest C compiler
It seems that it doesn't need to be so complicated to test it yourself.
The computer is configured with 64-bit WIN7, installed python3.6 (64bit), also installed Pycharm
1, installation OpenCV relatively simple, failure to try more than a few times
Pip Install--upgrade Setuptools
Pip Install NumPy matplotlib
Pip Install Opencv-python
This OPENCV even if installed, if the use of Face_cascade = Cv2. Cascadeclassifier (' Xxx/haarcascade_frontalface_default.xml ')
XXX in parentheses is the store path
2. Installation Dlib
Online also said that the first installation of Anaconda is simpler, this step I also omitted, the following to say my installation steps
First use CMD query to support which version of the current system environment dlib
Enter DOS separately input:
Python
Import pip
Print (pip.pep425tags.get_supported ())
Return:
[(' Cp36 ', ' cp36m ', ' win_amd64 '), (' cp36 ', ' none ', ' win_amd64 '), (' Py3 ', ' none ',
' Win_amd64 '), (' cp36 ', ' none ', ' any '), (' CP3 ', ' none ', ' any '), (' py36 ', ' none '),
' Any ', [' py3 ', ' none ', ' any '], (' py35 ', ' none ', ' any '), (' py34 ', ' none ', ' any ')
, (' py33 ', ' none ', ' any '), (' py32 ', ' none ', ' no '), (' py31 ', ' none ', ' any '), (' P
Y30 ', ' none ', ' any ')]
Indicates that the current environment supports the above format installation package
Use pip install dlib, install dlib19.9 failure, do not know is not the speed of the network or the environment does not support, on their own online under a
DLIB-19.7.0-CP36-CP36M-WIN_AMD64.WHL, this format meets the above requirements
Then pip install to store the path/DLIB-19.7.0-CP36-CP36M-WIN_AMD64.WHL
Success, and then run an example
Import Cv2
Import Dlib
detector = Dlib.get_frontal_face_detector ()
Landmark_predictor = Dlib.shape_predictor (' d:/pytion code/shape_predictor_68_face_landmarks.dat ')
img = cv2.imread (' 1.jpg ')
faces = detector (img,1)
if (Len (faces) > 0):
For k,d in Enumerate (faces):
Cv2.rectangle (IMG, (D.left (), D.top ()), (D.right (), D.bottom ()), (255,255,255))
Shape = Landmark_predictor (img,d)
For I in range (68):
Cv2.circle (IMG, (Shape.part (i). x, Shape.part (i). Y), 5, (0,255,0),-1, 8)
Cv2.puttext (Img,str ("), (Shape.part (i). X,shape.part (i). Y), Cv2. font_hershey_simplex,0.5, (255,2555,255))
Else
Print ("No face")
Pass
Print (' {} faces detected '. Format (len (faces))
Cv2.imshow (' Frame ', IMG)
Cv2.imwrite (' faces.jpg ', IMG)
Cv2.waitkey (0)
The directory where the program is stored can be identified with a human face map.
What needs to be explained is that Landmark_predictor = Dlib.shape_predictor (' d:/pytion code/shape_predictor_68_face_landmarks.dat ') contains a DAT database , this is the dlib relies on the face detection of 68 feature detection points, can be downloaded online, can also be downloaded to https://download.csdn.net/download/stephen_yu/10287390
Here is the code execution result