如何检测人的脸部特征_自动面部特征检测

2023-11-23 03:10

本文主要是介绍如何检测人的脸部特征_自动面部特征检测,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

如何检测人的脸部特征

Identify faces and extract up to 6 facial features with few lines of code!

只需几行代码即可识别面部并提取多达6个面部特征!

Detection of facial landmarks and their feature points plays an important role in many facial image-related applications such as face recognition or verification, facial expression analysis, pose normalization, and 3D face reconstruction.

面部界标及其特征点的检测在许多与面部图像相关的应用程序中扮演重要角色,例如面部识别或验证,面部表情分析,姿势归一化和3D面部重构。

Detection of facial features is easy for persons; however, for machines it is not an easy task at all. The difficulty comes from high inter-personal variation (e.g., gender, race), intra-personal changes (e.g., pose, expression), and from acquisition conditions (e.g., lighting, image resolution). As a beginner in computer vision, I am sure all of us would have faced a similar challenge of detecting features. To cover variety of facial landmarks needs endless lines of codes.

人的面部特征检测很容易; 但是,对于机器而言,这绝非易事。 困难来自人际间的高度差异(例如性别,种族),人际内部的变化(例如姿势,表情)以及获取条件(例如照明,图像分辨率)。 作为计算机视觉的初学者,我相信我们每个人都会面临类似的特征检测挑战。 要覆盖各种面部标志,需要无休止的代码行。

This motivated me to write a python module called AutoFacialFeatures for performing an automated facial features detection on virtually any image. I am sharing this module so that you can customize and add additional functions as per your choice.

这促使我编写了一个名为AutoFacialFeatures的python模块,用于对几乎所有图像执行自动面部特征检测。 我正在共享此模块,以便您可以根据需要自定义和添加其他功能。

For the source code please visit the following link:

有关源代码,请访问以下链接:

AutoFacialFeatures可以做什么? (What AutoFacialFeatures can do?)

This customizable automated facial features detection module allows the user to detect facial features real-time using webcam, capture a selfie using webcam and detect its facial features, detect for stored face images while taking care of face alignment, image sharpening, image resizing and facial features extraction.

该可自定义的自动面部特征检测模块允许用户使用网络摄像头实时检测面部特征,使用网络摄像头捕获自拍并检测其面部特征,检测存储的面部图像,同时注意面部对齐,图像锐化,图像调整大小和面部特征提取。

I will demonstrate the working of AutoFacialFeatures using real-time and strored images.

我将使用实时图像和强化图像演示AutoFacialFeatures的工作。

先决条件 (Prerequisites)

There are a few packages that must be installed before we can proceed any further. You must install Anaconda distribution which includes most of the packages . You can read this article for a guide to install Anaconda.

在继续进行下一步之前,必须先安装一些软件包。 您必须安装包含大多数软件包的Anaconda发行版 。 您可以阅读该文章的指南,安装Python。

Other packages need to be installed separately by following these steps:

其他套餐 需要按照以下步骤单独安装:

  • Make sure that you have Python 3.6 or greater installed.

    确保您已安装Python 3.6或更高版本。

  • Install imutils, cmake, cv2 and dlib using PIP command either in Command Prompt or Anaconda Prompt:

    在命令提示符或Anaconda提示符中使用PIP命令安装imutils,cmake,cv2dlib

$ 
$ pip install cmake
$ pip install opencv-python
$ pip install dlib

Without further ado, let us use the face detection module!

事不宜迟,让我们使用人脸检测模块!

导入模块 (Importing Module)

Download AutoFacialFeatures.py and shape_predictor_68_face_landmarks.dat (The pre-trained facial landmark predictor model file) files from the links shared above and store them in your working directory (the location where all your other python files and datasets are stored).

从上面共享的链接下载AutoFacialFeatures.pyshape_predictor_68_face_landmarks.dat (预先训练的面部界标预测器模型文件)文件,并将它们存储在您的工作目录中(所有其他python文件和数据集的存储位置)。

Create a new python file where you want to work and import the module in that file.

在要工作的地方创建一个新的python文件,然后将该模块导入该文件中。

# import the autoFacialFeatures module
from AutoFacialFeatures import *

In the above program, all the functions defined in AutoFacialFeatures.py file are imported .

在以上程序中,将导入AutoFacialFeatures.py文件中定义的所有功能。

autoFacialFeatures参数 (autoFacialFeatures Parameters)

Once the module is imported, you can call autoFacialFeatures function in your python file which will automatically do all the required face detection and feature extraction on your image. Before calling the function we must understand the function parameters:

导入模块后,您可以在python文件中调用autoFacialFeatures函数,该函数将自动对图像进行所有必需的面部检测和特征提取。 在调用函数之前,我们必须了解函数参数:

autoFacialFeatures(realtime,img_format,
capture_img,image_name,
face_align, radius,
sharpen,sharp_filter,
n_sharp,sigma,strength,
sharpen_resize,sharpen_resize_dim,
extract_roi,img_width)

realtime: boolean. (True if you want to detect real-time facial features using your webcam), default: False

实时 :布尔值。 (如果要使用网络摄像头检测实时面部特征,则为True),默认值:False

img_format: variable of str. (The name of the format in which you want to save your captured image like ‘jpg’ or ‘png’), default: None

img_format :str的变量 (您要保存捕获的图像的格式名称,例如“ jpg”或“ png”),默认值:无

capture_img: boolean. (True if you want to detect facial features on your selfie taken using your webcam), default: True

capture_img :布尔值。 (如果要检测使用网络摄像头拍摄的自拍照的面部特征,则为True),默认值为:True

image_name: variable of str. (The name you wish to give to the duplicate of the image for which you want to detect facial features), default: None

image_name :str的变量。 (要为要检测其面部特征的图像副本指定的名称),默认值:无

face_align: boolean. (True if you want to align the face in the image before detecting facial features), default: True

face_align :布尔值 (如果要在检测面部特征之前将图像中的面部对齐,则为True),默认值为:True

radius: int. (The size of the dots outlining the facial features), default: 3

半径 :整数。 (概述面部特征的点的大小),默认值:3

sharpen: boolean. (True if you want to sharpen the blurred image before detecting facial features), default: False

锐化:布尔值。 (如果要在检测面部特征之前对模糊的图像进行锐化,则为真),默认值:False

sharp_filter: variable of str. (The name of the filter you want to use for sharpening the image, ‘gaussian’ or ‘median’- for more info regarding these filters refer to the source code), default: ‘gaussian’

sharp_filter: str的变量。 (要用于锐化图像的滤镜名称为“ gaussian”或“ median”,有关这些滤镜的更多信息,请参见源代码),默认值为:“ gaussian”

n_sharp: int. (The number of times you want to apply the sharpening filter), default: None

n_sharp:整数。 (您要应用锐化滤镜的次数),默认值:无

sigma: int. (the value of sigma governs the degree of smoothing), default: 1

sigma:整数 (sigma的值决定平滑程度),默认值:1

strength: float. (the value of strength governs the intensity of the sharpening filter), default: 1.0

强度 :浮动。 (强度值控制锐化滤镜的强度),默认值:1.0

sharpen_resize: boolean. (True if you want to resize the sharpened image before detecting facial features), default: False

sharpen_resize :布尔值。 (如果要在检测面部特征之前调整锐化图像的大小,则为True),默认值:False

sharpen_resize_dim: tuple. (The dimensions to which you want to resize the sharpened image), default: (500,500)

sharpen_resize_dim :元组。 (您想要将锐化后的图像调整为的尺寸),默认值:(500,500)

extract_roi: boolean. (True if you want to extract the different facial regions of interest like jaw, eyebrows, nose etc.), default: True

extract_roi :布尔值。 (如果要提取下巴,眉毛,鼻子等不同的面部感兴趣区域,则为True,默认为:True

img_width: int. (defines the desired face width in pixels.), default: 500

img_width :整数 (以像素为单位定义所需的脸部宽度。)默认值:500

使用网络摄像头实时检测面部特征 (Detect facial features real-time using webcam)

We will set the values of autoFacialFeatures function parameters and then run the program.

我们将设置autoFacialFeatures函数参数的值,然后运行该程序。

autoFacialFeatures(realtime=True)

Voila! It automatically does the facial features detection real-time

瞧! 自动实时进行面部特征检测

Image for post

To exit the webcam window press ESC

要退出网络摄像头窗口,请按ESC键。

使用网络摄像头捕获自拍照并检测其面部特征 (Capturing a selfie using webcam and detecting its facial features)

We will set the values of autoFacialFeatures function parameters and then run the program.

我们将设置autoFacialFeatures函数参数的值,然后运行该程序。

sigma=1
strength=0.8
sharp_filter='gaussian'
n_sharp=2
img_format='png'
img_width=500
sharpen_resize_dim=(400,500)
radius=2pic = cv2.imread(name)
clone = pic.copy()
img_name='face_copy.jpg'
cv2.imwrite(img_name, clone)autoFacialFeatures(img_format=img_format,
capture_img=True,image_name=img_name,
face_align=True, radius=radius,
sharpen=True,sharp_filter=sharp_filter,
n_sharp=n_sharp,sigma=sigma,strength=strength,
sharpen_resize=True,
sharpen_resize_dim=sharpen_resize_dim,
extract_roi=True,img_width=img_width)

When you run the program, a webcam window will appear. To capture a selfie press Space and the press ESC to close the webcam window. Afterwards continue pressing Space to move to the next steps.

运行该程序时,将显示一个网络摄像头窗口。 要捕获自拍,请按Space,然后按ESC以关闭网络摄像头窗口。 然后,继续按空格键以进行下一步。

Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post

检测面部特征以存储图像 (Detect facial features for stored images)

For multiple faces

对于多张脸

Image for post
people.jpg
people.jpg
name='people.jpg'   
radius=1pic = cv2.imread(name)
clone = pic.copy()
img_name='face_copy.jpg'
cv2.imwrite(img_name, clone)autoFacialFeatures(capture_img=False,image_name=img_name,
face_align=False, radius=radius,
extract_roi=False)
Image for post

For a single face

单脸

Image for post
female face.jpg
女性face.jpg
name='female face.jpg'sigma=1
strength=0.8
sharp_filter='gaussian'
n_sharp=1
img_width=500
radius=2pic = cv2.imread(name)
clone = pic.copy()
img_name='face_copy.jpg'
cv2.imwrite(img_name, clone)autoFacialFeatures(realtime=False,
capture_img=False,image_name=img_name,
face_align=True, radius=radius,
sharpen=True,sharp_filter=sharp_filter,
n_sharp=n_sharp,sigma=sigma,strength=strength,
sharpen_resize=False,
extract_roi=True,img_width=img_width)
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post
Image for post

你走之前 (Before You Go)

Thanks for reading! Feel free to use this autoFacialFeatures module for your face detection projects. If you have any difficulty or any doubts kindly comment below. Your support is always highly appreciated. If you want to get in touch with me, reach me on jatin.kataria94@gmail.com.

感谢您 的阅读! 随时使用此 autoFacialFeatures 模块进行面部检测项目。 如果您有任何困难或疑问,请在下面评论。 您的支持始终受到高度赞赏。 如果您想与我联系,请通过jatin.kataria94@gmail.com与我联系。

翻译自: https://medium.com/analytics-vidhya/automated-facial-features-detection-baedbf06a43b

如何检测人的脸部特征

原文地址:https://blog.csdn.net/weixin_26750481/article/details/108499855
http://www.taodudu.cc/news/show-8353528.html

相关文章:

  • 使用 OpenCV 进行面部和眼睛检测
  • BiSeNetV2-面部分割
  • 提高面部分析技术准确性和智能化的关键策略
  • 人脸+AI:从GWAS看人类面部特征遗传
  • java/php/net/python基于安卓的掌上校园系统【2024年毕设】
  • 【开题报告】ssm大学生掌上校园appo2kxj计算机毕业设计程序
  • ssm基于安卓的掌上校园系统7m7o8【独家源码】计算机毕业设计问题的解决方案与方法
  • 基于Uniapp+SSM实现的安卓的掌上校园系统
  • ssm大学生掌上校园appo2kxj【独家源码】 应对计算机毕业设计困难的解决方案
  • (附源码)基于Springboot掌上校园系统APP-计算机毕设 33400
  • 基于Springboot掌上校园系统APP-计算机毕设 附源码 33400
  • Springboot掌上校园系统APP-计算机毕业设计源码33400
  • Springboot掌上校园系统APP 计算机专业毕业设计源码33400
  • Springboot掌上校园系统APP 计算机毕设源码33400
  • 谈谈 RPA 开发的经历
  • 在海康实习的那段经历
  • 微信小程序swiper切换特效
  • 资深工程师是一群什么样的人
  • Ruby 思想在 Elixir 项目中的应用
  • CSUOJ nineteen thirteen One big silly dragon gives gifts out 线段树 二分 转化
  • Hi,听说你也是函数式编程爱好者
  • 三分钟英语(二)—Alicha
  • 当你在 Tubi 是一位 Tech Lead
  • 在 Tubi,英文书面沟通是这样的
  • ubuntu 18lts 3090 安装 cuda10.0配置 stylegan2
  • 对于框架的一些个人理解
  • 教你用Python秒破路边“诈骗”残局!发家致富第一步!
  • 怎么用python做棋牌_教你用Python秒破路边“诈骗”棋牌残局!发家致富第一步!...
  • 个人项目之数独的生成与数独残局求解——C语言实现
  • python学习方法之一
  • 这篇关于如何检测人的脸部特征_自动面部特征检测的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!


    原文地址:https://blog.csdn.net/weixin_26750481/article/details/108499855
    本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.chinasem.cn/article/414938

    相关文章

    python利用backoff实现异常自动重试详解

    《python利用backoff实现异常自动重试详解》backoff是一个用于实现重试机制的Python库,通过指数退避或其他策略自动重试失败的操作,下面小编就来和大家详细讲讲如何利用backoff实... 目录1. backoff 库简介2. on_exception 装饰器的原理2.1 核心逻辑2.2

    Java如何根据文件名前缀自动分组图片文件

    《Java如何根据文件名前缀自动分组图片文件》一大堆文件(比如图片)堆在一个目录下,它们的命名规则遵循一定的格式,混在一起很难管理,所以本文小编就和大家介绍一下如何使用Java根据文件名前缀自动分组图... 目录需求背景分析思路实现代码输出结果知识扩展需求一大堆文件(比如图片)堆在一个目录下,它们的命名规

    使用Python实现实时金价监控并自动提醒功能

    《使用Python实现实时金价监控并自动提醒功能》在日常投资中,很多朋友喜欢在一些平台买点黄金,低买高卖赚点小差价,但黄金价格实时波动频繁,总是盯着手机太累了,于是我用Python写了一个实时金价监控... 目录工具能干啥?手把手教你用1、先装好这些"食材"2、代码实现讲解1. 用户输入参数2. 设置无头浏

    使用Python实现IP地址和端口状态检测与监控

    《使用Python实现IP地址和端口状态检测与监控》在网络运维和服务器管理中,IP地址和端口的可用性监控是保障业务连续性的基础需求,本文将带你用Python从零打造一个高可用IP监控系统,感兴趣的小伙... 目录概述:为什么需要IP监控系统使用步骤说明1. 环境准备2. 系统部署3. 核心功能配置系统效果展

    Python实现微信自动锁定工具

    《Python实现微信自动锁定工具》在数字化办公时代,微信已成为职场沟通的重要工具,但临时离开时忘记锁屏可能导致敏感信息泄露,下面我们就来看看如何使用Python打造一个微信自动锁定工具吧... 目录引言:当微信隐私遇到自动化守护效果展示核心功能全景图技术亮点深度解析1. 无操作检测引擎2. 微信路径智能获

    IDEA自动生成注释模板的配置教程

    《IDEA自动生成注释模板的配置教程》本文介绍了如何在IntelliJIDEA中配置类和方法的注释模板,包括自动生成项目名称、包名、日期和时间等内容,以及如何定制参数和返回值的注释格式,需要的朋友可以... 目录项目场景配置方法类注释模板定义类开头的注释步骤类注释效果方法注释模板定义方法开头的注释步骤方法注

    pytorch自动求梯度autograd的实现

    《pytorch自动求梯度autograd的实现》autograd是一个自动微分引擎,它可以自动计算张量的梯度,本文主要介绍了pytorch自动求梯度autograd的实现,具有一定的参考价值,感兴趣... autograd是pytorch构建神经网络的核心。在 PyTorch 中,结合以下代码例子,当你

    Python如何自动生成环境依赖包requirements

    《Python如何自动生成环境依赖包requirements》:本文主要介绍Python如何自动生成环境依赖包requirements问题,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑... 目录生成当前 python 环境 安装的所有依赖包1、命令2、常见问题只生成当前 项目 的所有依赖包1、

    Spring Boot项目中结合MyBatis实现MySQL的自动主从切换功能

    《SpringBoot项目中结合MyBatis实现MySQL的自动主从切换功能》:本文主要介绍SpringBoot项目中结合MyBatis实现MySQL的自动主从切换功能,本文分步骤给大家介绍的... 目录原理解析1. mysql主从复制(Master-Slave Replication)2. 读写分离3.

    微信公众号脚本-获取热搜自动新建草稿并发布文章

    《微信公众号脚本-获取热搜自动新建草稿并发布文章》本来想写一个自动化发布微信公众号的小绿书的脚本,但是微信公众号官网没有小绿书的接口,那就写一个获取热搜微信普通文章的脚本吧,:本文主要介绍微信公众... 目录介绍思路前期准备环境要求获取接口token获取热搜获取热搜数据下载热搜图片给图片加上标题文字上传图片