唐国梁 openCV学习笔记
opencv基础
官方文档:https://docs.opencv.org/master/d9/df8/tutorial_root.html
OpenCV 源码:https://github.com/opencv/opencv
人脸识别相关算法的链接
1. Haar Cascade 哈尔级联
- 核心原理
(1)使用Haar-like特征做检测
(2)Integral Image : 积分图加速特征计算
(3)AdaBoost : 选择关键特征,进行人脸和非人脸分类
(4)Cascade : 级联,弱分类器成为强分类器
PS:积分图就是只遍历一次图像就可以求出图像中所有区域像素和的快速算法,大大的提高了图像特征值计算的效率
论文:Rapid Object Detection using a Boosted Cascade of Simple Features
参考博文:https://www.cnblogs.com/zyly/p/9410563.html
3. Haar cascade
它提供了四个级联分类器(针对人脸的正面):
(1)haarcascade_frontalface_alt.xml (FA1):
22 stages and 20 x 20 haar features
(2)haarcascade_frontalface_alt2.xml (FA2):
20 stages and 20 x 20 haar features
(3)haarcascade_frontalface_alt_tree.xml (FAT):
47 stages and 20 x 20 haar features
(4)haarcascade_frontalface_default.xml (FD):
25 stages and 24 x 24 haar features
2. 基于dlib进行人脸检测
-
Dlib是一个深度学习开源工具,基于C++开发,也支持Python开发接口。
-
由于Dlib对于人脸特征提取支持很好,有很多训练好的人脸特征提取模型供开发者使用,所以Dlib人脸识别开发很适合做人脸项目开发。
官网地址:http://dlib.net
Github 源码库:https://github.com/davisking/dlib
- HOG 方向梯度直方图(Histogram of Oriented Gradient)
(1)HOG是一种特征描述子,通常用于从图像数据中提取特征。它广泛用于计算机视觉任务的物体检测。
(2)特征描述子的作用:它是图像的简化表示,仅包含有关图像的最重要信息。
论文:《Histograms of Oriented Gradients for Human Detection》
3. 关键点检测
3.1 基于dlib关键点检测
- dlib.get_frontal_face_detector( ) 获取人脸检测器
- dlib.shape_predictor( ) 预测人脸关键点
人脸关键点模型,下载地址:
http://dlib.net/files/shape_predictor_68_face_landmarks.dat.bz2.
3.2 基于face_recognition进行人脸关键点检测
- face_recognition 是使用简单的人脸识别工具,它使用dlib先进的人脸识别技术构建而成,并具有深度学习功能。
(1)Github 地址:https://github.com/ageitgey/face_recognition
(2)官方指南:
https://face-recognition.readthedocs.io/en/latest/readme.html
(3)源码实现:
https://face-recognition.readthedocs.io/en/latest/face_recognition.html
4 目标跟踪
-
基于dlib库 —— 检测人脸、跟踪人脸;
-
基于dlib库 —— 选定目标物体,跟踪目标;
5 人脸识别
5.1 基于dlib人脸识别
dlib 提供的高精度人脸识别算法是基于深度学习网络ResNet-34实现。该网络基于三百万张照片进行训练,最终获得了人脸检测模型。
下载地址:
https://github.com/davisking/dlib-models/blob/master/dlib_face_recognition_resnet_model_v1.dat.bz2
5.2 face_recognition 人脸识别
用到的方法:
-
face_distance(face_encodings, face_to_compare)
-
face_locations(img, number_of_times_to_upsample=1, model=“hog”)
-
face_landmarks(face_image, face_locations=None, model=“large”)
-
face_encodings(face_image, known_face_locations=None, num_jitters=1, model=“small”)
-
compare_faces(known_face_encodings, face_encoding_to_check, tolerance=0.6)
face_recognition的API文档:
https://face-recognition.readthedocs.io/en/latest/_modules/face_recognition/api.html#face_locations