dlib实现人脸landmark点检测以及一些其他的应用

Anita-ff的图像处理之旅 Anita-ff的图像处理之旅     2022-10-13     318

关键词:

首先从中这里下载下代码:

https://github.com/ageitgey/face_recognition#face-recognition

然后安装所以必须的组件,我用的Python3.5

进入example里面跑他的demo,主要就是掉了dlib的接口比如:

    face_locations = face_recognition.face_locations(rgb_frame)
    face_encodings = face_recognition.face_encodings(rgb_frame, face_locations)
    face_landmarks_list = face_recognition.face_landmarks(rgb_frame)

 引入了OpenCV稍微改了下显示,camera实时跟踪人脸的特征点,速度奇慢,而且还不准。

代码很简单:

import face_recognition
import cv2

# This is a super simple (but slow) example of running face recognition on live video from your webcam.
# Theres a second example thats a little more complicated but runs faster.

# PLEASE NOTE: This example requires OpenCV (the `cv2` library) to be installed only to read from your webcam.
# OpenCV is *not* required to use the face_recognition library. Its only required if you want to run this
# specific demo. If you have trouble installing it, try any of the other demos that dont require it instead.

# Get a reference to webcam #0 (the default one)
video_capture = cv2.VideoCapture(0)

# Load a sample picture and learn how to recognize it.
obama_image = face_recognition.load_image_file("obama.jpg")
obama_face_encoding = face_recognition.face_encodings(obama_image)[0]

# Load a second sample picture and learn how to recognize it.
biden_image = face_recognition.load_image_file("biden.jpg")
biden_face_encoding = face_recognition.face_encodings(biden_image)[0]

# Create arrays of known face encodings and their names
known_face_encodings = [
    obama_face_encoding,
    biden_face_encoding
]
known_face_names = [
    "Barack Obama",
    "Joe Biden"
]

while True:
    # Grab a single frame of video
    ret, frame = video_capture.read()

    # Convert the image from BGR color (which OpenCV uses) to RGB color (which face_recognition uses)
    rgb_frame = frame[:, :, ::-1]

    # Find all the faces and face enqcodings in the frame of video
    # face_locations = face_recognition.face_locations(rgb_frame)
    # face_encodings = face_recognition.face_encodings(rgb_frame, face_locations)
    face_landmarks_list = face_recognition.face_landmarks(rgb_frame)

    # Loop through each face in this frame of video
    # for (top, right, bottom, left), face_encoding in zip(face_locations, face_encodings):
    #     # See if the face is a match for the known face(s)
    #     matches = face_recognition.compare_faces(known_face_encodings, face_encoding)
    #
    #     name = "Unknown"

        # If a match was found in known_face_encodings, just use the first one.
        # if True in matches:
        #     first_match_index = matches.index(True)
        #     name = known_face_names[first_match_index]

        # # Draw a box around the face
        # cv2.rectangle(frame, (left, top), (right, bottom), (0, 0, 255), 2)
        #
        # # Draw a label with a name below the face
        # cv2.rectangle(frame, (left, bottom - 35), (right, bottom), (0, 0, 255), cv2.FILLED)
        # font = cv2.FONT_HERSHEY_DUPLEX
        # cv2.putText(frame, name, (left + 6, bottom - 6), font, 1.0, (255, 255, 255), 1)

    for face_landmarks in face_landmarks_list:

        # Print the location of each facial feature in this image
        facial_features = [
            chin,
            left_eyebrow,
            right_eyebrow,
            nose_bridge,
            nose_tip,
            left_eye,
            right_eye,
            top_lip,
            bottom_lip
        ]


        for facial_feature in facial_features:
            for point in face_landmarks[facial_feature]:
                cv2.circle(frame, point, 1, (255, 0, 0))

    # Display the resulting image
    cv2.imshow(Video, frame)

    # Hit q on the keyboard to quit!
    if cv2.waitKey(1) & 0xFF == ord(q):
        break

# Release handle to the webcam
video_capture.release()
cv2.destroyAllWindows()

 

opencv+openvino实现人脸landmarks实时检测(代码片段)

...M算法实现的68个人脸特征点的拟合模型,另外OpenCV中支持landmark的人脸检测会先加载一个很大的模型文件,然后速度感人,觉得还有很大的改进空间。好处是OpenCV自己提供了一个训练工具,可以自己训练模型。常见的MTCNN同时实... 查看详情

dlib实现人脸的68点检测

Dlib实现68点标定效果图展示:主要是通过68点的模型进行提取脸部的68点的特征值。(相应细节都已经注释)//设置人脸的标记点#include<dlibopencv.h>#include<opencv2opencv.hpp>#include<dlibimage_processingfrontal_face_detector.h>#include< 查看详情

opencv+dlib实现疲劳检测(代码片段)

...,传入68关键点模型#分别取两个眼睛区域(lStart,lEnd)=FACIAL_LANDMARKS_68_IDXS["left_eye"]#返回左眼开始索引,结束索引(rStart,rEnd)=FACIAL_LANDMARKS_68_IDXS["right_eye"]FACIAL_LANDMARKS_68_IDXS=OrderedDict([ ("mouth",(48,68)), ("right_eyebrow",(17,22)), ("left_eyebrow",(22,... 查看详情

opencv联合dlib人脸检测例子

...文注释。本例子是用opencv加载图像,然后调用dlib进行人脸检测,得到人脸所在区域以及特征点,最后还是用opencv描绘人脸特征点。例子源码以及解释:#include<dlib/image_processing/frontal_face_detector.h 查看详情

opencv联合dlib人脸检测例子

...文注释。本例子是用opencv加载图像,然后调用dlib进行人脸检测,得到人脸所在区域以及特征点,最后还是用opencv描绘人脸特征点。例子源码以及解释:#include<dlib/image_processing/frontal_face_detector.h>#include<dlib/ima... 查看详情

dlib人脸关键点检测的模型分析与压缩

...分析与压缩.htmlgithub项目:https://github.com/miaoerduo/dlib-face-landmark-compression 人脸关键点检测的技术在很多领域上都 查看详情

dlib库的68特征原理人脸关键点检测原理

...ttps://blog.csdn.net/ebzxw/article/details/80441556shape_predictor_68_face_landmarks.dat是已经训练好的人脸关键点检测器。dlib_face_recognition_resnet_model_v1.dat是训练好的ResNet人脸识别模型。(说明:ResNet是何凯明在微软的时候提出的深度残差网络,获... 查看详情

人脸检测进阶:更快的5点面部标志检测器(代码片段)

...标志检测器进行比较。然后我们将使用Python、dlib和OpenCV实现面部标志检测,然后运行它并查看结果。最后,我们将讨论使用5点面部标志检测器的一些限制,并重点介绍一些您应该使用5点版本的68点面部标志检测器的... 查看详情

dlib库包的介绍与使用,opencv+dlib检测人脸框opencv+dlib进行人脸68关键点检测,opencv+dlib实现人脸识别,dlib进行人脸特征聚类dlib视频目标跟踪(代码片段)

文章目录:1dlib库介绍2dlib人脸检测:绘制出人脸检测框2.1dlib人脸检测源码2.2opencv+dlib人脸检测2.3dlib人脸检测总结3dlib人脸关键点检测:并绘制检测框、关键点、不同区域关键点连线3.1dlib人脸关键点检测源码3.2opencv... 查看详情

用dlib进行简单的人脸特征提取特征向量到csv文件中,用knn进行预测识别(代码片段)

...模型为dlib_face_recognition_resnet_model_v1.datshape_predictor_68_face_landmarks.dat进行人脸检测和标注68个特征点importnumpyasnpimportcv2importdlibdetector=dlib.get_frontal_face_detector()predictor=dlib.shape_predictor('dlib\\shape_predictor_68_face_landmarks.dat')#cv2... 查看详情

图片人脸检测——dlib版

上几篇给大家讲了OpenCV的图片人脸检测,而本文给大家带来的是比OpenCV更加精准的图片人脸检测Dlib库。点击查看往期:《图片人脸检测——OpenCV版(二)》《视频人脸检测——OpenCV版(三)》dlib与OpenCV对比识别精准... 查看详情

opencv联合dlib人脸检测例子二(加快检测)(代码片段)

本篇博客是在opencv联合dlib人脸检测例子的基础上改进了下,加快检测流程观察了下,opencv利用haar级联分类器检测人脸区域的速度要稍快于dlib的frontal_face_detector检测人脸区域的速度。所以这篇博客是利用opencv先检测出人... 查看详情

基于dlib的人脸检测(68关键点)(代码片段)

...f08;1)环境搭建(2)下载开源数据集二、具体实现效果展示:效果展示:总结前言imutils这个图像处理工具包,除了简化opencv的一些操作之外,还有专门配合dlib处理人脸数据的工具face_utils。dlib提取人脸... 查看详情

MTCNN 与 DLIB 相比如何进行人脸检测?

】MTCNN与DLIB相比如何进行人脸检测?【英文标题】:HowdoesMTCNNperformvsDLIBforfacedetection?【发布时间】:2018-06-0910:18:46【问题描述】:我看到MTCNN被推荐,但没有看到DLIB和MTCNN的直接比较。我认为既然MTCNN使用神经网络,它可能更适... 查看详情

dlib 的 CNN 人脸检测器使用哪种架构?

...很多,但找不到。是对发表在CNN人脸检测上的一些论文的实现吗?dlib的卷积人脸检测器的理论部分有详细的介绍吗?【问题讨论】:ThisfacedetectorismadeusingthenowclassicHis 查看详情

人脸识别完整项目实战(14):实时人脸特征点标定程序设计

...绍Win10环境下,基于VisualStudio2015+Opencv+Dlib开发环境,如何实现实时视频流人脸特征点标定程序的设计。本文内容已经同步录制成视频课程,课程地址:《人脸识别完整项目实战》二、正文2.1界面设计人脸特征点标定程序沿用之前... 查看详情

使用 Dlib/python 检测前额点

...】:2019-12-0516:27:24【问题描述】:我们有什么方法可以在人脸图像的额头上获取点吗?我正在使用68点地标shape_predictor来获取脸上的其他点,但对于这个特殊问题,我需要从发际线到前额中心的点。任何建议都会有所帮助。【问... 查看详情

视频是不能p的系列:使用dlib实现人脸识别

本文内容原理说明实现过程本文小结本文是#视频是不能P的系列#的第三篇。此前,我们已经可以通过OpenCV或者Dlib实现对人脸的检测,并在此基础上实现了某种相对有趣的应用。譬如,利用人脸特征点提取面部轮廓并生成表情包... 查看详情