python百度人脸识别教程,Python图像识别库

  python百度人脸识别教程,Python图像识别库

  dlibdlib简介

  这里我们主要尝试实现人脸检测。Dlib的人脸检测主要基于HOG-SVM,与opencv的人脸检测不同。相比之下,dlib的识别准确率更高,即使遮挡很小也能识别。(不过,情况一定要具体分析。相反,opencv可以检测到一些人脸。但dlib的人脸识别图像尺寸大于80X80可以获得更好的识别效果。Dlib还可以对齐68个键。

  如果你想要更高的识别准确率,因为我以前做实验的数据都是一个人的头像,我就简单粗暴的把两者结合起来了。写if else哈哈哈哈哈哈

  但是安装dlib库比较麻烦。另外你还需要下载很多其他的库,下载VS,我记得安装后找了很多教程,花了我一些时间才安装好。

  实现:

  Importdlibimportcv2#dlib正面人脸检测器frontal _ face _ detector detector=dlib . get _ frontal _ face _ detector(# image path img(64,64)) #img_gray=cv2.cvtcolor) img、cv2。COLOR_RGB2GRAY)图像窗口生成Dlib # win=Dlib . Image _ window(# win . set _ Image)img))所有图像中使用检测器的人脸:),Len) Faces)) for i,dinenumerate) faces): print),the first),the first)。左(,(t),)右: ),右: ),上: ),下:).d.top())、tuple(d.right)、d.bottom))、0,255,255)、2)else 3360 print) no face )cv2 . non img)

  如之前的博客测试图所示,我们发现dlib并不能识别一切。所以,请具体看看你确定的数据集。

  我又换了一个像素大小的,但是我全认出来了。

  关键点定位:

  # instantiation detector=dlib . get _ frontier _ face _ detector(predictor=dlib . shape _ predictor(shape _ predictor)img=cv2 . im read(r c:(users(Lenovo))Desktop)2 . jpg)# number of faces rects=detector)img,1)printing(len(rects)(print)rects(foriinrange)len)rects)):landmarks=NP . matrix([[p[p . x,p.y] frex] 1) print(idx,pos))用cv2圈出每个特征点

  原图

  结果

  要键入的参数:

  链接:KCDickJ9VFS1 SMKA87EJRG,https://pan。Baidu.com/s/1

  抽屉代码:ju3e

  完整版见我的github。

  有批量处理的代码。

郑重声明:本文由网友发布,不代表盛行IT的观点,版权归原作者所有,仅为传播更多信息之目的,如有侵权请联系,我们将第一时间修改或删除,多谢。

留言与评论(共有 条评论)
   
验证码: