关于人脸检测python库 dlib 初识 1
简介
上了一门计算机视觉的课程,初步了解, dlib python库
参考链接
http://dlib.net/face_detector.py.html 人脸检测的链接
原理
This face detector is made using the now classic Histogram of Oriented
Gradients (HOG) feature combined with a linear classifier, an image
pyramid, and sliding window detection scheme. This type of object detector
is fairly general and capable of detecting many types of semi-rigid objects
in addition to human faces. Therefore, if you are interested in making
your own object detectors then read the train_object_detector.py example program.
谷歌翻译
该面部检测器是使用现在经典的定向直方图(HOG)功能与线性分类器,图像金字塔和滑动窗口检测方案组合而成的。
这种类型的物体检测器相当通用,并且能够检测除人脸之外的许多类型的半刚性物体。
因此,如果您有兴趣制作自己的对象检测器,请阅读train_object_detector.py示例程序。
如果没有猜错应该使用了传统的方法??
想得到分数
# Finally, if you really want to you can ask the detector to tell you the score
# for each detection. The score is bigger for more confident detections.
# The third argument to run is an optional adjustment to the detection threshold,
# where a negative value will return more detections and a positive value fewer.
# Also, the idx tells you which of the face sub-detectors matched. This can be
# used to broadly identify faces in different orientations.
code
# coding=utf-8
import dlib # 人脸算法库
from imageio import imread
import glob # 操作文件的相关模块
# 准备好人脸检测器和显示窗口,获取图片路径
detector = dlib.get_frontal_face_detector()
win = dlib.image_window()
paths=glob.glob('faces/*.jpg')
# 对每一张图片进行检测,并显示检测结果对应的矩形框
for path in paths:
img = imread(path)
# 1 表示将图片放大一杯,便于检测更过人脸
dets = detector(img, 1)
print('检测到了 %d 个人脸' % len(dets))
for i,d in enumerate(dets):
# 函数用于将一个可遍历的数据对象(如列表、元组或字符串)
# 组合为一个索引序列,同时列出数据和数据下标,一般用在 for 循环当中。
print("Detection {}: Left: {} Top: {} Right: {} Bottom: {}".format(i, d.left(), d.top(), d.right(), d.bottom())) # dets 是已经检测到的人脸
win.clear_overlay() # 清除覆盖
win.set_image(img)
win.add_overlay(dets)
dlib.hit_enter_to_continue()
dets, scores, idx = detector.run(img, 1, -1) # 其中1 表示放大 -1 表示 阈值 如果为正数那么相关的低于阈值的信息就会被筛选掉
for i, d in enumerate(dets):
print("Detection {}, score: {}, face_type:{}".format(d, scores[i], idx[i]))
结果
检测到了 1 个人脸
Detection 0: Left: 206 Top: 428 Right: 872 Bottom: 1094
Hit enter to continue
Detection [(206, 428) (872, 1094)], score: 2.9385107197297926, face_type:0
Detection [(114, 744) (176, 806)], score: -0.7111557926037881, face_type:2
Detection [(170, 847) (213, 890)], score: -0.8928528437771357, face_type:3
Detection [(121, 793) (196, 868)], score: -0.9795470083884772, face_type:1
关于人脸检测python库 dlib 初识 1的更多相关文章
- Python 3 利用 Dlib 实现摄像头人脸检测特征点标定
0. 引言 利用 Python 开发,借助 Dlib 库捕获摄像头中的人脸,进行实时人脸 68 个特征点标定: 支持多张人脸: 有截图功能: 图 1 工程效果示例( gif ) 图 2 工程效果示例( ...
- Python 3 利用 Dlib 实现人脸检测和剪切
0. 引言 利用 Python 开发,借助 Dlib 库进行人脸检测 / face detection 和剪切: 1. crop_faces_show.py : 将检测到的人脸剪切下来,依次排序平 ...
- 人脸检测? 对Python来说太简单, 调用dlib包就可以完成
"Dlib 是一个现代化的 C ++ 工具包,包含用于创建复杂软件的机器学习算法和工具 " .它使您能够直接在 Python 中运行许多任务,其中一个例子就是人脸检测. 安装 dl ...
- winds dlib人脸检测与识别库
在人脸检测与人脸识别库中dlib库所谓是非常好的了.检测效果非常ok,下面我们来了解一下这个神奇的库吧! 第一步我们首先学会安装:dlib ,winds+pytho3.6.5 Windows不支持p ...
- 【计算机视觉】人脸检测模型的评估方法-linux
前言 人脸检测标准库FDDB详细介绍了数据库和使用方法.对于训练的模型,如何评估模型的效果呢,本文对此进行介绍.说实话,参考了很多博客,但是感觉都不是很明白(当然本文也会有瑕疵),故在此记录! 测试环 ...
- dlib python 人脸检测与关键点标记
http://blog.csdn.net/sunmc1204953974/article/details/49976045 人脸检测 #coding=utf-8 # -*- coding: utf-8 ...
- Python学习--使用dlib、opencv进行人脸检测标注
参考自https://www.pyimagesearch.com/2017/04/03/facial-landmarks-dlib-opencv-python/ 在原有基础上有一部分的修改(image ...
- Python 3 利用 Dlib 实现摄像头实时人脸检测和平铺显示
1. 引言 在某些场景下,我们不仅需要进行实时人脸检测追踪,还要进行再加工:这里进行摄像头实时人脸检测,并对于实时检测的人脸进行初步提取: 单个/多个人脸检测,并依次在摄像头窗口,实时平铺显示检测到的 ...
- Python 3 利用 Dlib 19.7 进行人脸检测
0. 引言 / Overview 介绍 Dlib 中基于 HOG,Histogram of Oriented Gradients / 方向梯度直方图 实现 Face Detect / 人脸检测 的两个 ...
- Dlib库中实现正脸人脸检测的测试代码
Dlib库中提供了正脸人脸检测的接口,这里参考dlib/examples/face_detection_ex.cpp中的代码,通过调用Dlib中的接口,实现正脸人脸检测的测试代码,测试代码如下: #i ...
随机推荐
- 什么是 Java 中的 JIT(Just-In-Time)?
Java 中的 JIT(Just-In-Time)编译器 1. JIT 的定义 JIT(Just-In-Time)编译器是一种用于 Java 虚拟机(JVM)的动态编译技术.它在 Java 程序运行时 ...
- kettle介绍-Step之Script Values/Mod(JavaScript 代码) 一
Script Values/Mod JavaScript 代码介绍 JavaScript 代码步骤提供了一个用户界面,用户可以编写 JavaScript 代码到脚本区,脚本区域中的每一行代码都会执行一 ...
- 如何在Uniapp项目中引入uni_modules中的依赖?
在Uniapp项目中引入uni_modules中的依赖分为以下几种情况: 对于通用组件: 如果你已经通过HBuilderX插件市场安装了某个uni_modules组件,通常只需在页面的.vue文件中按 ...
- 【踩坑系列】使用Comparator.comparing对中文字符串排序结果不对
1. 踩坑经历 假设有这样一个业务场景,需要对各个城市的订单量排序,排序规则为: 先根据订单量倒序排列,再根据城市名称正序排列. 示例代码: import lombok.Getter; import ...
- Git Reset 彻底解析:--hard 模式操作步骤、风险与完整恢复指北
结论先行 使用 git reset --hard <commit_id> 可强制将本地代码.暂存区.工作目录彻底回退到指定提交状态,但会丢弃目标提交之后的所有提交记录(需谨慎操作,尤其涉及 ...
- 【Java持久层技术演进全解析】从JDBC到MyBatis再到MyBatis-Plus
从JDBC到MyBatis再到MyBatis-Plus:Java持久层技术演进全解析 引言 在Java企业级应用开发中,数据持久化是核心需求之一.本文将系统性地介绍Java持久层技术的演进过程,从最基 ...
- Django 数据迁移报错之“TypeError: __init__() missing 1 required positional argument: 'on_delete'”
当执行 python manage.py makemigrations 出现错误:TypeError: init() missing 1 required positional argument: ' ...
- Advanced pandas
Advanced pandas import numpy as np import pandas as pd Categorical Data This section introduces the ...
- TEA密码与逆向工程
前置信息 TEA系列概述:TEA算法是一种分组密码算法,由剑桥大学计算机实验室的David Wheeler和Roger Needham于1994年发明.它使用64位的明文分组和128位的密钥进行加 ...
- 企业AI应用模式解析:从本地部署到混合架构
在人工智能快速发展的今天,企业如何选择合适的大模型应用方式成为了一个关键问题.本文将详细介绍六种主流的企业AI应用模式,帮助您根据自身需求做出最优选择. 1. 本地部署(On-Premise Depl ...