该文作者开源了测试代码,源代码可以在我之前的文章中或者Github中去下载,我对源代码的数据输入部分做了一些改动以更方便的实现人脸检测,即将  facedetect_mtcnn.py主函数文件更改为如下代码:

# coding=utf-8
from __future__ import absolute_import
from __future__ import division
from __future__ import print_functionimport sys
import os
import argparse
import tensorflow as tf
import numpy as np
import detect_face
import cv2
import time
import shutildef reseach_image_name(root_dir):if (os.path.exists(root_dir)):fileNames = os.listdir(root_dir)fileNames = sorted(fileNames)return fileNamesdef main(input_file_list):sess = tf.Session()pnet, rnet, onet = detect_face.create_mtcnn(sess, None)minsize = 40                        # minimum size of facethreshold = [0.6, 0.7, 0.9]        # three steps's thresholdfactor = 0.709                      # scale factoroutput_root_dir = "./output_face_result"if (not os.path.exists(output_root_dir)):os.mkdir(output_root_dir )# 假如path_01 = 'Test\\path_01\\path_02\\path_03',os.mkdir(path_01)创建路径中的最后一级目录,# 即:只创建path_03目录,而如果之前的目录不存在并且也需要创建的话,就会报错。# os.makedirs(path_01)创建多层目录,即:Test,path_01,path_02,path_03如果都不存在的话,会自动创建。else:shutil.rmtree(output_root_dir )     # 先删除原来的目录os.mkdir(output_root_dir)           # 再创建一个新目录for index in range(len(input_file_list)):print("***********开始检测第%d张图像***********"%index)filename = input_file_list[index]input_image_dir = os.path.join(  input_root_dir, filename)output_image_dir =os.path.join( output_root_dir,filename.split(".")[0]+"_result.jpg")draw = cv2.imread(input_image_dir)# cv2.imshow("source image",draw )# cv2.waitKey(0)# cv2.destroyAllWindows()img = cv2.cvtColor(draw, cv2.COLOR_BGR2RGB)bounding_boxes, points = detect_face.detect_face(img, minsize, pnet, rnet, onet, threshold, factor)nrof_faces = bounding_boxes.shape[0]for b in bounding_boxes:cv2.rectangle(draw, (int(b[0]), int(b[1])), (int(b[2]), int(b[3])), (0, 255, 0))print("人脸坐标:{0}".format(b))for p in points.T:for i in range(5):cv2.circle(draw, (p[i], p[i + 5]), 1, (0, 0, 255), 2)print('总共%d个人脸被检测到,保存到%s' % (nrof_faces, output_image_dir))cv2.imshow("detected image", draw)cv2.waitKey(0)cv2.destroyAllWindows()cv2.imwrite(output_image_dir, draw)def detect_video_face(video_file):sess = tf.Session()pnet, rnet, onet = detect_face.create_mtcnn(sess, None)minsize = 40  # minimum size of facethreshold = [0.6, 0.7, 0.9]  # three steps's thresholdfactor = 0.709  # scale factorcamera = cv2.VideoCapture(video_file)while True:(grabbed, frame) = camera.read()if  grabbed == True:img = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)# cv2.imshow("frame",frame)bounding_boxes, points = detect_face.detect_face(img, minsize, pnet, rnet, onet, threshold, factor)nrof_faces = bounding_boxes.shape[0]for b in bounding_boxes:cv2.rectangle(frame, (int(b[0]), int(b[1])), (int(b[2]), int(b[3])), (0, 255, 0))print("人脸坐标:{0}".format(b))for p in points.T:for i in range(5):cv2.circle(frame, (p[i], p[i + 5]), 1, (0, 0, 255), 2)print('总共%d个人脸被检测到' %nrof_faces)cv2.imshow("detected image", frame)if cv2.waitKey(1) & 0xFF == ord('q'):# 通过cap.read() 的返回值ret,若ret值为False,则停止捕获视频。breakcap.release()cv2.destroyAllWindows()def detect_single_pic(image_file):sess = tf.Session()pnet, rnet, onet = detect_face.create_mtcnn(sess, None)minsize = 40  # minimum size of facethreshold = [0.6, 0.7, 0.9]  # three steps's thresholdfactor = 0.709  # scale factorprint("***********开始检测图像***********" )filename = image_filedraw = cv2.imread(filename)cv2.imshow("source image", draw)cv2.waitKey(0)cv2.destroyAllWindows()img = cv2.cvtColor(draw, cv2.COLOR_BGR2RGB)bounding_boxes, points = detect_face.detect_face(img, minsize, pnet, rnet, onet, threshold, factor)nrof_faces = bounding_boxes.shape[0]for b in bounding_boxes:cv2.rectangle(draw, (int(b[0]), int(b[1])), (int(b[2]), int(b[3])), (0, 255, 0))print("人脸坐标:{0}".format(b))for p in points.T:for i in range(5):cv2.circle(draw, (p[i], p[i + 5]), 1, (0, 0, 255), 2)print('总共%d个人脸被检测到'% nrof_faces)cv2.imshow("detected image", draw)cv2.waitKey(0)cv2.destroyAllWindows()if __name__ == '__main__':input_root_dir = "./input_face_image"input_file_list = reseach_image_name( input_root_dir)main(input_file_list)

新建了两个文件夹,一个文件夹放待检测的图片,另一个文件夹放检测后的结果图片,如下所示:

这是 input_face_image文件夹下的待测试图片:

运行程序,可以看到检测效果:

......

当然,检测结果图片都被保存到了 output_face_image文件夹下。

基于MTCNN卷积神经网络的人脸识别相关推荐

  1. 基于深度卷积神经网络进行人脸识别的原理是什么?

    原文:https://www.zhihu.com/question/60759296 基于深度卷积神经网络进行人脸识别的原理是什么? 这里的人脸识别包括但不限于:人脸检测,人脸对齐,身份验证识别,和表 ...

  2. 基于CNN卷积神经网络的人脸识别

    一.利用卷积神经网络进行人脸检测,称作CFF(卷积人脸搜索) 卷积神经网络人脸识别的大致流程: 1)对本地人脸进行特征提取 2)打开摄像头(opencv) 3)从cap获取信息 4)找人脸 5)对人脸 ...

  3. 基于深度卷积神经网络的人脸识别考勤系统-VGG-PYTHON-QT(1)

    本项目设计并实现了一个应用于小型企业员工考勤的刷脸考勤系统,整个系统使用Python语言开发,并利用Pyqt5作为桌面端系统界面的开发工具,以SQL Server作为数据库管理系统,最终集成所有刷脸考 ...

  4. 基于卷积神经网络的人脸识别(自我拍摄获取数据集)

    基于卷积神经网络的人脸识别 完整代码.数据请见:https://download.csdn.net/download/weixin_43521269/12837110 人脸识别,是基于人的脸部特征信息 ...

  5. python人脸识别系统界面设计_基于卷积神经网络的人脸识别系统的设计(Python)

    基于卷积神经网络的人脸识别系统的设计(Python)(论文10000字,外文翻译,参考代码,流程图,人脸图像库) 摘要:随着社会的进步与发展,个人信息的保护变得十分重要.传统的密码保护方式已经不再满足 ...

  6. 博士论文——基于卷积神经网络的人脸识别研究 __张燕红

    论文题目 作者 年份 关键词 链接 备注 基于卷积神经网络的人脸识别研究 张燕红 2018 人脸识别:卷积神经网络:特征提取:分块策略:正则化 博士论文 摘要:随着信息技术的蓬勃发展,人们的学习和生活 ...

  7. 基于卷积神经网络的人脸识别算法

    摘要:近年来,随着科学技术的不断发展,人脸识别技术日渐成熟,使得人脸识别技术的使用率不断增大.例如:门禁.ATM机.公安系统以及新兴起的人机交互等领域,都应用到了人脸识别系统.在人脸识别研究领域中,深 ...

  8. 深度学习(十五)基于级联卷积神经网络的人脸特征点定位

    基于级联卷积神经网络的人脸特征点定位 原文地址:http://blog.csdn.net/hjimce/article/details/49955149 作者:hjimce 一.相关理论 本篇博文主要 ...

  9. 【转】干货|孙启超:卷积神经网络在人脸识别技术中的应用

    2018-08-27 21:45:01 随着 iPhone X 的发布,Face ID 人脸识别技术开始进入人们的日常生活中,当我们拿起手机并看着它的时候就可以实现手机解锁的功能.而人脸识别中的关键技 ...

最新文章

  1. 手杀***病毒Trojan.Win32.Generic.11EBD5EC
  2. Android 截屏并写入SD卡中
  3. 2015.08.15冒泡排序
  4. Python画散点图(Knn中数据)
  5. Python super超类方法
  6. [CS101] 转载:浅议Fibonacci(斐波纳契)数列求解
  7. HDU-2544-最短路( 最短路)
  8. Vue3学习之第四节:setup()中使用watch、watchEffect 函数
  9. ABAP--动态创建类型和变量的使用程序样例
  10. python自定义函数如何命名_Python 自定义类之函数和运算符重载
  11. JAVA实现电路布线问题
  12. 2021-06-03TunePat Amazon Video Downloader使用教程:如何下载电影和电视节目
  13. US1M-ASEMI高效恢复二极管US1M
  14. Python相关分析—一个金融场景的案例实操
  15. 阿里视频直播自定义推拉流地址生成
  16. 计算机设备驱动程序的安装与更新,电脑系统驱动如何安装更新?
  17. SikuliX教程-下载与安装
  18. 推荐一个Mac清理工具 CleanMyMac X 4.8.0
  19. 怒刷python作业(西北工业大学cpSkill平台)
  20. 读Applying Deep Learning To Airbnb Search有感

热门文章

  1. Java高并发编程 (马士兵老师视频)笔记(二)并发容器
  2. C语言--“.”与“-”有什么区别?
  3. node 连接MySQL
  4. 为什么‘A‘的ASCII码是65,‘a‘是97呢?
  5. 树莓派+阿里云轻松智能家居DIY-app
  6. XXE外部实体注入漏洞总结
  7. 大端模式和小端模式是什么意思?
  8. python设置excel单元格宽度
  9. OPenGL 学习笔记之 VAO VBO EBO 以及SHADER 并使用其绘制三角形
  10. 【云原生】K8S master节点更换IP以及master高可用故障模拟测试