I found a face recognition article and tried it, but it didn't go smoothly, so I'll write it down.
Face recognition can be performed using Python. Moreover, the library is open to the public. Moreover, it seems easy. First article I saw: https://www.cresco.co.jp/blog/entry/9468/
I was wondering if face recognition could be used for things that are just a problem in my work. I first saw it with a light feeling like "just install it with pip".
>pip3 install face_recognition
I got an error during installation and couldn't proceed at all ... I googled while looking at the unreadable English
I was angry because I didn't have a wheel. what is that? It seems to be a zip for python distribution.
>pip install -U wheel
Still more errors dlib
In the first place, face_recognition seems to be for using a face recognition library called dlib. Is it a wrapper for python? Reference: https://qiita.com/nonbiri15/items/f95b5fb01ae38980c9ce
It seems that you need to install dlib.
>pip3 install dlib
After all error rolls out
It seems that dlib is made in C It seems that CMAKE is necessary. cmake-3.18.0-rc2-win64-x64.msi ↑ DL and install
Still more ~ It seems to build with VC ++ (that's right) Reference: https://qiita.com/strv13570/items/a0542600532deee61391 I had Visual studio 2017, but I didn't want to touch VC ++, so I didn't. Since there is no help for it, change it to use VC ++ and install it
As mentioned above, set the path etc. as appropriate (confirmation)
>pip3 install dlib
・
・
・
Successfully installed dlib-19.20.0
Finally, I passed dlib.
pip3 install face_recognition
・
・
・
Successfully installed Pillow-7.1.2 face-recognition-1.3.0 numpy-1.19.0
It was a long way to finally install it ... I thought Gugu, why did everyone put in anacondas? ?? Is it business?
For the time being, create two folders with reference to the site and put photos in it. How to use it like creating a face folder you know and a face folder you don't know, putting them in each, and taking a diff. I tried each below.
As mentioned above, the intention of the usage review has become an installation memo ...
I plan to try various other things Reference: https://www.kkaneko.jp/dblab/dlib/facerec.html
Postscript: ↑ I looked at the site and tried it
import face_recognition
src_img = face_recognition.load_image_file("./face/obama.png ")
src_img_encoding = face_recognition.face_encodings(src_img)[0]
print(src_img_encoding)
img1="./face2/tosi.png "
img2="./face2/tosi2.png "
img3="./face2/tosi3.png "
dest_img1 = face_recognition.load_image_file(img1)
dest_img_encoding1 = face_recognition.face_encodings(dest_img1)[0]
dest_img_encoding2 = face_recognition.face_encodings(face_recognition.load_image_file(img2))[0]
dest_img_encoding3 = face_recognition.face_encodings(face_recognition.load_image_file(img3))[0]
results = face_recognition.compare_faces([src_img_encoding], dest_img_encoding1)
print(img1 , results)
results = face_recognition.compare_faces([src_img_encoding], dest_img_encoding2)
print(img2 , results)
results = face_recognition.compare_faces([src_img_encoding], dest_img_encoding3)
print(img3 , results)
>test_face.py
./face2/tosi.png [False]
./face2/tosi2.png [False]
./face2/tosi3.png [True]
Process finished with exit code 0
Facial features can be quantified and compared It ’s really easy! !!
Recommended Posts