人脸检测中的多任务级联卷积神经网络Python示例
在这篇文章中,将介绍如何使用卷积神经网络进行人脸检测。
根据经验,基于深度学习的模型在面部检测方面取得了比opencv,cvlib或dlib更好的结果。
基于深度学习的人脸检测模型的一个例子是MTCNN。链接地址:https://github.com/ipazc/mtcnn 。
可以使用pip命令轻松安装。
pip install mtcnn
使用pip安装mtcnn
Python示例代码如下:
import cv2 from mtcnn.mtcnn import MTCNN detector = MTCNN() image = cv2.imread("street.jpg") result = detector.detect_faces(image) # Result is an array with all the bounding boxes detected. bounding_box = result[0]['box'] keypoints = result[0]['keypoints'] cv2.rectangle(image, (bounding_box[0], bounding_box[1]), (bounding_box[0]+bounding_box[2], bounding_box[1] + bounding_box[3]), (0,155,255), 2) cv2.circle(image,(keypoints['left_eye']), 2, (0,155,255), 2) cv2.circle(image,(keypoints['right_eye']), 2, (0,155,255), 2) cv2.circle(image,(keypoints['nose']), 2, (0,155,255), 2) cv2.circle(image,(keypoints['mouth_left']), 2, (0,155,255), 2) cv2.circle(image,(keypoints['mouth_right']), 2, (0,155,255), 2) cv2.imwrite("detect.jpg", image)
使用mtcnn进行人脸检测的结果如下图所示:
相关推荐
fengzhimohan 2020-11-02
demm 2020-09-18
sunxinyu 2020-09-17
walegahaha 2020-08-15
cherry0 2020-08-15
georgesale 2020-08-14
fengzhimohan 2020-07-23
wenxuegeng 2020-06-14
wenxuegeng 2020-06-08
cherry0 2020-06-06
hnyzyty 2020-06-05
hnyzyty 2020-06-03
wenxuegeng 2020-06-03
walegahaha 2020-06-03
cherry0 2020-06-03
zhaorui0 2020-06-01
kuankeTech 2020-06-01
hnyzyty 2020-05-12
georgesale 2020-05-10
hnyzyty 2020-05-08
hnyzyty 2020-05-05
walegahaha 2020-05-05
wenxuegeng 2020-05-04
玉来愈宏的随笔 2020-05-02
liqing 2020-04-19