64位+win7+Python3.6+dlib19.7检测人脸 详细图文教程
来源:互联网 发布:linux python 安装sip 编辑:程序博客网 时间:2024/06/10 18:18
系统环境
win7旗舰sp1,64位机
python3.6.2
dlib19.7.0 (其他版本例子没有cnn_face_detector.py和里面对应的一些模块功能和函数,运行该实例会报错)
效果展示
官网
http://dlib.net/
https://pypi.python.org/pypi/dlib#downloads
dlib-19.7.0-cp36-cp36m-win_amd64.whl (md5) 下载
https://github.com/davisking/dlib Git下载
链接:http://pan.baidu.com/s/1eRC8PpC 密码:8cfp
列表
应用软件
dlib-19.7.0-cp36-cp36m-win_amd64.whl (pip本地安装使用)
dlib-19.7.0.tar.gz (解压,源文件和实例)
dlib19.7.0运行需要的模型(model)和训练、测试、测试数据(data)集合
dlib_face_recognition_resnet_model_v1.dat.bz2
mmod_human_face_detector.dat.bz2
shape_predictor_5_face_landmarks.dat.bz2
shape_predictor_68_face_landmarks.dat.bz2
说明:.bz2文件解压后得到.dat文件,勿修改文件名(直接删除文件名后缀.bz2),否则运行程序报错。
python各种库(whl格式)下载地址
http://www.lfd.uci.edu/~gohlke/pythonlibs/https://pypi.python.org/pypi?%3Aaction=index
说明:使用whl免去了下载、编译、匹配和调试的操作,节省了大量的时间。
运行命令
python C:/local/dlib-19.7/python_examples/cnn_face_detector.py C:/local/dlib-19.7/python_examples/mmod_human_face_detector.dat C:/local/dlib-19.7/examples/faces/2008_007676.jpg
运行输出
(test) C:\Users\Administrator>python C:/local/dlib-19.7/python_examples/cnn_face_detector.py C:/local/dlib-19.7/python_examples/mmod_human_face_detector.dat C:/local/dlib-19.7/examples/faces/2008_007676.jpgProcessing file: C:/local/dlib-19.7/examples/faces/2008_007676.jpgNumber of faces detected: 7Detection 0: Left: 225 Top: 53 Right: 264 Bottom: 93 Confidence: 1.060071349143982Detection 1: Left: 193 Top: 113 Right: 232 Bottom: 153 Confidence: 1.0537749528884888Detection 2: Left: 261 Top: 125 Right: 300 Bottom: 165 Confidence: 1.0504766702651978Detection 3: Left: 365 Top: 129 Right: 404 Bottom: 169 Confidence: 1.0493420362472534Detection 4: Left: 131 Top: 74 Right: 178 Bottom: 122 Confidence: 1.0421613454818726Detection 5: Left: 313 Top: 117 Right: 352 Bottom: 157 Confidence: 1.024323582649231Detection 6: Left: 100 Top: 130 Right: 156 Bottom: 187 Confidence: 1.0235471725463867Hit enter to continue
源代码
cnn_face_detector.py
#!/usr/bin/python# The contents of this file are in the public domain. See LICENSE_FOR_EXAMPLE_PROGRAMS.txt## This example shows how to run a CNN based face detector using dlib. The# example loads a pretrained model and uses it to find faces in images. The# CNN model is much more accurate than the HOG based model shown in the# face_detector.py example, but takes much more computational power to# run, and is meant to be executed on a GPU to attain reasonable speed.## You can download the pre-trained model from:# http://dlib.net/files/mmod_human_face_detector.dat.bz2## The examples/faces folder contains some jpg images of people. You can run# this program on them and see the detections by executing the# following command:# ./cnn_face_detector.py mmod_human_face_detector.dat ../examples/faces/*.jpg### COMPILING/INSTALLING THE DLIB PYTHON INTERFACE# You can install dlib using the command:# pip install dlib## Alternatively, if you want to compile dlib yourself then go into the dlib# root folder and run:# python setup.py install# or# python setup.py install --yes USE_AVX_INSTRUCTIONS --yes DLIB_USE_CUDA# if you have a CPU that supports AVX instructions, you have an Nvidia GPU# and you have CUDA installed since this makes things run *much* faster.## Compiling dlib should work on any operating system so long as you have# CMake and boost-python installed. On Ubuntu, this can be done easily by# running the command:# sudo apt-get install libboost-python-dev cmake## Also note that this example requires scikit-image which can be installed# via the command:# pip install scikit-image# Or downloaded from http://scikit-image.org/download.html.import sysimport dlibfrom skimage import ioif len(sys.argv) < 3: print( "Call this program like this:\n" " ./cnn_face_detector.py mmod_human_face_detector.dat ../examples/faces/*.jpg\n" "You can get the mmod_human_face_detector.dat file from:\n" " http://dlib.net/files/mmod_human_face_detector.dat.bz2") exit()cnn_face_detector = dlib.cnn_face_detection_model_v1(sys.argv[1])win = dlib.image_window()for f in sys.argv[2:]: print("Processing file: {}".format(f)) img = io.imread(f) # The 1 in the second argument indicates that we should upsample the image # 1 time. This will make everything bigger and allow us to detect more # faces. dets = cnn_face_detector(img, 1) ''' This detector returns a mmod_rectangles object. This object contains a list of mmod_rectangle objects. These objects can be accessed by simply iterating over the mmod_rectangles object The mmod_rectangle object has two member variables, a dlib.rectangle object, and a confidence score. It is also possible to pass a list of images to the detector. - like this: dets = cnn_face_detector([image list], upsample_num, batch_size = 128) In this case it will return a mmod_rectangless object. This object behaves just like a list of lists and can be iterated over. ''' print("Number of faces detected: {}".format(len(dets))) for i, d in enumerate(dets): print("Detection {}: Left: {} Top: {} Right: {} Bottom: {} Confidence: {}".format( i, d.rect.left(), d.rect.top(), d.rect.right(), d.rect.bottom(), d.confidence)) rects = dlib.rectangles() rects.extend([d.rect for d in dets]) win.clear_overlay() win.set_image(img) win.add_overlay(rects) dlib.hit_enter_to_continue()
遇到问题、分享经验欢迎加入QQ群:452205574
- 64位+win7+Python3.6+dlib19.7检测人脸 详细图文教程
- 人脸识别(4)--Python3.6+dlib19.4识别实例
- windows10 dlib19 andaconda python3.6
- 人脸识别(3)--Python3.6+dlib19.4在Mac下环境搭建
- win7 64位 python3.4&opencv3.0配置安装教程
- 【安装】win7 64位安装sql server2005图文教程
- 64位 WIN7 安装oracle 11g R2图文教程
- WIN7硬盘安装最新详细图文教程
- Win7安装MySQL详细图文教程
- 超详细win7、win8安装图文教程
- win7 vs2015 python2.7配置dlib19.4
- win7 64位搭建汇编环境详细教程
- Win7,64位,VS2013,WinPcap4.1.3详细配置教程
- win7 64位搭建汇编环境详细教程
- 【教程】Win7-64位安装OpenSSL详细过程
- 人工智能学习tensorFlow_gpu-1.1.0图文详细安装教程(64位机win7旗舰sp1+Anaconda3-4.2.0+Pycharm2017.2.4)附所有软件下载地址
- python3.6中安装xgboost 基于win7 64位系统
- WIN7 32/64位安装SQL Server 2005详细步骤(图文)
- oracle删除数据后的恢复
- Creo实战系列-第一讲Creo有限元分析培训圆满落幕
- 树莓派3开机自动注册IP
- 代理模式
- C++运算符
- 64位+win7+Python3.6+dlib19.7检测人脸 详细图文教程
- [python]自问自答:python -m参数?
- header头信息解析以及CORS 跨域 access-control-allow-headers 的问题
- C语言结构体和数组的转换
- 学习笔记 |《ORANGE’S:一个操作系统的实现》| (一) Ubuntu
- 设计模式-工厂方法模式
- oracle将普通表改为分区表
- Android约束布局ConstraintLayout 项目实战攻略
- 使用geotools的GeoTiffReader函数时出现Could not initialize class org.hsqldb.lib.FrameworkLoggerwenti