Jetson (3)--- 人脸识别(安装)

https://github.com/ageitgey/face_recognition/blob/master/README_Simplified_Chinese.md

https://medium.com/@ageitgey/build-a-hardware-based-face-recognition-system-for-150-with-the-nvidia-jetson-nano-and-python-a25cb8c891fd

 

1. 准备安装依赖库文件

$ sudo apt-get update
$ sudo apt-get install python3-pip cmake libopenblas-dev liblapack-dev libjpeg-dev 

2. 由于nano的内存只有4G,在编译dlib的过程中,需要一个交换文件

$ git clone https://github.com/JetsonHacksNano/installSwapfile
$ cd installSwapfile
$ ./installSwapfile.sh

注意:如果执行./installSwapfile.sh不添加任何参数,默认挂在在/mnt目录下,默认大小为6G,如果SD卡的空间比较小,建议更换大的SD卡,或者插入一个U盘,扩展一下挂在空间。编译结束后,可以删除交换空间。删除交换文件的命令是:

$ su root
$ swapoff swapfile
$ rm /mnt/swapfile

3. 需要对nano进行一下重启,重启之后,安装numpy

$ pip3 install numpy

4. 下载dlib安装包,解压之后,需要对源代码中一行代码进行注释

$ wget http://dlib.net/files/dlib-19.17.tar.bz2
$ tar jxvf dlib-19.17.tar.bz2
$ cd dlib-19.17

5. 在dlib/cuda/目录下的该 cudnn_dlibapi.cpp文件中

$ gedit dlib/cuda/cudnn_dlibapi.cpp
找到对应的一行代码,进行删除(可以采用注释的方式删除)
forward_algo = forward_best_algo;
//forward_algo = forward_best_algo;
$ sudo python3 setup.py install

执行编译,编译的时间有点长,请耐心等待。

6. 安装face_recongnition的库

$ sudo pip3 install face_recognition

7.测试代码链接:https://github.com/ageitgey/face_recognition/examples/facerec_from_webcam_faster.py

# Load a sample picture and learn how to recognize it.
obama_image = face_recognition.load_image_file("obama.jpg")
obama_face_encoding = face_recognition.face_encodings(obama_image)[0]

# Load a second sample picture and learn how to recognize it.
biden_image = face_recognition.load_image_file("biden.jpg")
biden_face_encoding = face_recognition.face_encodings(biden_image)[0]

# Create arrays of known face encodings and their names
known_face_encodings = [obama_face_encoding, biden_face_encoding]
known_face_names = ["Barack Obama","Joe Biden"]

修改对应图片,即可完成自己的人脸识别。

上一篇:Jetson (4)--- 人脸识别(下)


下一篇:Jetson Nano 安装 VsCode