OpenCV 4.13.0
开源计算机视觉库 (Open Source Computer Vision)
正在加载...
正在搜索...
未找到匹配项
人脸识别与OpenCV

简介

OpenCV (Open Source Computer Vision) 是一个流行的计算机视觉库,由英特尔于1999年启动。这个跨平台库专注于实时图像处理,并包含最新计算机视觉算法的无专利实现。2008年,Willow Garage接管了支持,OpenCV 2.3.1现在提供了C、C++、PythonAndroid的编程接口。OpenCV以BSD许可证发布,因此它在学术项目和商业产品中都有使用。

OpenCV 2.4现在附带了用于人脸识别的全新FaceRecognizer类,因此您可以立即开始人脸识别实验。本文档是我在学习人脸识别时所希望得到的指南。它将向您展示如何在OpenCV中使用FaceRecognizer进行人脸识别(附带完整的源代码列表),并介绍其背后的算法。我还将展示如何创建您在许多出版物中可以找到的可视化效果,因为有很多人询问。

目前可用的算法有

  • 特征脸(参见EigenFaceRecognizer::create)
  • 费舍尔脸(参见FisherFaceRecognizer::create)
  • 局部二值模式直方图(参见LBPHFaceRecognizer::create)

您无需从本页复制粘贴源代码示例,因为它们位于本文档附带的src文件夹中。如果您在构建OpenCV时启用了示例,那么您很可能已经编译了它们!虽然这可能对非常高级的用户感兴趣,但我决定省略实现细节,因为我担心它们会使新用户感到困惑。

本文档中的所有代码均根据BSD许可证发布,因此请随意用于您的项目。

人脸识别

人脸识别对人类来说是一项简单的任务。在[281]的实验表明,即使是一到三天大的婴儿也能区分熟悉的面孔。那么对于计算机来说这有多难呢?事实证明,我们对人类识别的了解甚少。是内部特征(眼睛、鼻子、嘴巴)还是外部特征(头部形状、发际线)被用于成功的人脸识别?我们如何分析图像,大脑又是如何编码的?David HubelTorsten Wiesel的研究表明,我们的大脑拥有专门的神经细胞,对场景的特定局部特征(如线条、边缘、角度或运动)做出反应。由于我们不将世界视为散乱的碎片,我们的视觉皮层必须以某种方式将不同的信息来源组合成有用的模式。自动化人脸识别就是从图像中提取这些有意义的特征,将它们放入有用的表示中,并对其进行某种分类。

基于人脸几何特征的人脸识别可能是最直观的方法。最早的自动化人脸识别系统之一在[147]中描述:标记点(眼睛、耳朵、鼻子等位置)用于构建特征向量(点之间的距离、它们之间的角度等)。通过计算探针图像和参考图像特征向量之间的欧几里德距离来进行识别。这种方法本质上对光照变化具有鲁棒性,但有一个巨大的缺点:标记点的精确配准很复杂,即使使用最先进的算法也是如此。几何人脸识别方面的一些最新工作在[45]中进行。使用了22维特征向量,在大型数据集上的实验表明,仅几何特征可能不足以进行人脸识别。

[282]中描述的特征脸方法采用了一种整体的人脸识别方法:人脸图像是高维图像空间中的一个点,并找到一个低维表示,在该表示中分类变得容易。低维子空间通过主成分分析(Principal Component Analysis)找到,该分析识别出方差最大的轴。虽然这种变换从重建的角度来看是最佳的,但它没有考虑任何类别标签。想象一个方差由外部来源(例如光照)产生的情况。方差最大的轴不一定包含任何判别信息,因此分类变得不可能。因此,在[25]中,将具有线性判别分析的类特定投影应用于人脸识别。其基本思想是在最小化类内方差的同时最大化类间方差。

最近出现了各种局部特征提取方法。为了避免输入数据的高维性,只描述图像的局部区域,提取的特征(希望能)对局部遮挡、光照和小样本量更具鲁棒性。用于局部特征提取的算法有Gabor小波([304])、离散余弦变换([195])和局部二值模式([4])。在应用局部特征提取时,如何最好地保留空间信息仍然是一个开放的研究问题,因为空间信息是潜在的有用信息。

人脸数据库

我们先获取一些数据进行实验。我不想在这里做一个玩具示例。我们正在进行人脸识别,所以你需要一些人脸图像!你可以创建自己的数据集,或者从现有的人脸数据库开始,http://face-rec.org/databases/为您提供了最新的概述。三个有趣的数据库是(部分描述引用自http://face-rec.org):

  • AT&T人脸数据库 AT&T人脸数据库,有时也称为ORL人脸数据库,包含40个不同对象的每人10张不同图像。对于某些对象,图像是在不同时间拍摄的,光照、面部表情(睁眼/闭眼、微笑/不微笑)和面部细节(戴眼镜/不戴眼镜)各不相同。所有图像均在深色均匀背景下拍摄,对象处于直立、正面位置(允许一些侧向移动)。
  • 耶鲁人脸数据库 A,又称 Yalefaces。AT&T人脸数据库适合初步测试,但它是一个相当简单的数据库。Eigenfaces方法已在其上达到了97%的识别率,因此您不会看到其他算法带来显著改进。耶鲁人脸数据库 A(也称 Yalefaces)是更适合初步实验的数据集,因为识别问题更难。该数据库包含15个人(14名男性,1名女性),每个人有11张大小为\(320 \times 243\)像素的灰度图像。光照条件(中心光、左侧光、右侧光)、面部表情(高兴、正常、悲伤、困倦、惊讶、眨眼)和眼镜(戴眼镜、不戴眼镜)都有变化。

    原始图像未裁剪和对齐。请查看附录,其中有一个Python脚本可以为您完成这项工作。

  • 扩展耶鲁人脸数据库B 扩展耶鲁人脸数据库B的裁剪版本包含38个不同人的2414张图像。该数据库的重点是提取对光照具有鲁棒性的特征,图像在情感/遮挡方面几乎没有变化/...。我个人认为,这个数据集对于我在本文档中进行的实验来说太大了。您最好使用AT&T人脸数据库进行初步测试。[25]中使用了耶鲁人脸数据库B的第一个版本,以查看Eigenfaces和Fisherfaces方法在严重光照变化下的表现。[160]使用了相同的设置拍摄了28个人的16128张图像。扩展耶鲁人脸数据库B是这两个数据库的合并,现在被称为扩展耶鲁人脸数据库B。

准备数据

一旦我们获取了一些数据,就需要将其读入我们的程序。在演示应用程序中,我决定从一个非常简单的CSV文件中读取图像。为什么?因为这是我能想到的最简单的平台独立方法。但是,如果您知道更简单的解决方案,请告诉我。基本上,所有CSV文件只需包含由文件名后跟一个;再后跟标签(作为整数)组成的行,例如以下格式:

/path/to/image.ext;0

让我们分解一下这行。/path/to/image.ext是图像的路径,如果您在Windows下,可能类似C:/faces/person0/image0.jpg。然后是分隔符;,最后我们将标签0分配给该图像。将标签视为此图像所属的主体(人物),因此相同的主体(人物)应具有相同的标签。

从AT&T人脸数据库下载AT&T人脸数据库和相应的CSV文件at.txt,内容如下(文件当然没有...)

./at/s1/1.pgm;0
./at/s1/2.pgm;0
...
./at/s2/1.pgm;1
./at/s2/2.pgm;1
...
./at/s40/1.pgm;39
./at/s40/2.pgm;39

假设我已经将文件提取到D:/data/at,并将CSV文件下载到D:/data/at.txt。那么您只需将./替换为D:/data/即可。您可以在您选择的编辑器中进行此操作,任何足够高级的编辑器都可以做到这一点。一旦您拥有包含有效文件名和标签的CSV文件,就可以通过将CSV文件的路径作为参数传递来运行任何演示:

facerec_demo.exe D:/data/at.txt

请参阅创建CSV文件了解创建CSV文件的详细信息。

特征脸

我们所获得的图像表示存在的问题是其高维性。二维\(p \times q\)灰度图像构成一个\(m = pq\)-维向量空间,因此一个\(100 \times 100\)像素的图像已经位于一个\(10,000\)-维图像空间中。问题是:所有维度对我们都同样有用吗?我们只有在数据存在任何方差时才能做出决定,因此我们正在寻找那些解释大部分信息的分量。主成分分析(PCA)由Karl Pearson(1901年)和Harold Hotelling(1933年)独立提出,旨在将一组可能相关的变量转换为一组较小的、不相关的变量。其思想是,高维数据集通常由相关变量描述,因此只有少数有意义的维度解释了大部分信息。PCA方法找到数据中方差最大的方向,称为主成分。

特征脸算法描述

设\(X = \{ x_{1}, x_{2}, \ldots, x_{n} \}\)是一个随机向量,观测值为\(x_i \in R^{d}\)。

  1. 计算均值\(\mu\)

    \[\mu = \frac{1}{n} \sum_{i=1}^{n} x_{i}\]

  2. 计算协方差矩阵 S

    \[S = \frac{1}{n} \sum_{i=1}^{n} (x_{i} - \mu) (x_{i} - \mu)^{T}`\]

  3. 计算S的特征值\(\lambda_{i}\)和特征向量\(v_{i}\)

    \[S v_{i} = \lambda_{i} v_{i}, i=1,2,\ldots,n\]

  4. 按照特征值降序排列特征向量。\(k\)个主成分是对应于\(k\)个最大特征值的特征向量。

观测向量\(x\)的\(k\)个主成分由下式给出

\[y = W^{T} (x - \mu)\]

其中\(W = (v_{1}, v_{2}, \ldots, v_{k})\)。

从PCA基进行重建由下式给出

\[x = W y + \mu\]

其中\(W = (v_{1}, v_{2}, \ldots, v_{k})\)。

特征脸方法通过以下步骤进行人脸识别:

  • 将所有训练样本投影到PCA子空间。
  • 将查询图像投影到PCA子空间。
  • 在投影的训练图像和投影的查询图像之间找到最近邻。

仍然有一个问题需要解决。假设我们有400张大小为\(100 \times 100\)像素的图像。主成分分析求解协方差矩阵\(S = X X^{T}\),在我们的例子中,\({size}(X) = 10000 \times 400\)。您将得到一个\(10000 \times 10000\)矩阵,大约为\(0.8 GB\)。解决这个问题是不可行的,所以我们需要应用一个技巧。从您的线性代数课程中您知道,一个\(M \times N\)矩阵,其中\(M > N\),最多只能有\(N - 1\)个非零特征值。因此,可以取\(S = X^{T} X\)的特征值分解,大小为\(N \times N\),而不是

\[X^{T} X v_{i} = \lambda_{i} v{i}\]

并通过数据矩阵的左乘得到\(S = X X^{T}\)的原始特征向量

\[X X^{T} (X v_{i}) = \lambda_{i} (X v_{i})\]

得到的特征向量是正交的,为了得到正交归一化的特征向量,它们需要归一化到单位长度。我不想把这变成一篇论文,所以请参阅[79]了解这些方程的推导和证明。

OpenCV中的特征脸

对于第一个源代码示例,我将和您一起过一遍。我首先给出完整的源代码列表,然后我们将详细查看最重要的行。请注意:每个源代码列表都已详细注释,因此您应该能够轻松理解。

此演示应用程序的源代码也可在本文档附带的 src 文件夹中找到。

/*
* 版权所有 (c) 2011. Philipp Wagner <bytefish[at]gmx[dot]de>。
* 根据BSD简化许可证条款发布到公共领域。
*
* 允许以源代码和二进制形式进行重新分发和使用,无论是否修改,但须满足以下条件:
* * 重新分发源代码必须保留上述版权声明、此条件列表和以下免责声明。
* * 以二进制形式重新分发必须在分发附带的文档和/或其他材料中复制上述版权声明、此条件列表和以下免责声明。
* * 未经特定的事先书面许可,不得使用本组织名称或其贡献者的名称来认可或推广从本软件派生的产品。
* 参见 <https://open-source.org.cn/licenses/bsd-license>
* See <https://open-source.org.cn/licenses/bsd-license>
* documentation and/or other materials provided with the distribution.
* * Neither the name of the organization nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* See <https://open-source.org.cn/licenses/bsd-license>
*/
#include "opencv2/core.hpp"
#include "opencv2/face.hpp"
#include <iostream>
#include <fstream>
#include <sstream>
using namespace cv;
using namespace cv::face;
using namespace std;
static Mat norm_0_255(InputArray _src) {
Mat src = _src.getMat();
// 创建并返回归一化图像
Mat dst;
switch(src.channels()) {
case 1:
cv::normalize(_src, dst, 0, 255, NORM_MINMAX, CV_8UC1);
break;
case 3:
cv::normalize(_src, dst, 0, 255, NORM_MINMAX, CV_8UC3);
break;
default:
src.copyTo(dst);
break;
}
return dst;
}
static void read_csv(const string& filename, vector<Mat>& images, vector<int>& labels, char separator = ';') {
std::ifstream file(filename.c_str(), ifstream::in);
if (!file) {
string error_message = "未提供有效的输入文件,请检查文件名。";
CV_Error(Error::StsBadArg, error_message);
}
string line, path, classlabel;
while (getline(file, line)) {
stringstream liness(line);
getline(liness, path, separator);
getline(liness, classlabel);
if(!path.empty() && !classlabel.empty()) {
images.push_back(imread(path, 0));
labels.push_back(atoi(classlabel.c_str()));
}
}
}
int main(int argc, const char *argv[]) {
// 检查命令行参数是否有效,如果未提供参数,则打印使用说明。
// if no arguments were given.
if (argc < 2) {
cout << "用法: " << argv[0] << " <csv.ext> <输出文件夹> " << endl;
exit(1);
}
string output_folder = ".";
if (argc == 3) {
output_folder = string(argv[2]);
}
// 获取CSV文件的路径。
string fn_csv = string(argv[1]);
// 这些向量存储图像和相应的标签。
vector<Mat> images;
vector<int> labels;
// 读取数据。如果给定的输入文件名无效,此操作可能会失败。
// input filename is given.
try {
read_csv(fn_csv, images, labels);
} catch (const cv::Exception& e) {
cerr << "打开文件 \"" << fn_csv << "\" 时出错。原因: " << e.msg << endl;
// 我们无能为力了
exit(1);
}
// 如果此演示所需的图像不足,则退出。
if(images.size() <= 1) {
string error_message = "此演示需要至少2张图像才能运行。请向您的数据集中添加更多图像!";
CV_Error(Error::StsError, error_message);
}
// 从第一张图像获取高度。我们以后会在代码中需要它来将图像重塑为它们的原始大小。
// later in code to reshape the images to their original
// size
int height = images[0].rows;
// 以下几行代码简单地从您的数据集中获取最后一张图像,并将其从向量中移除。这样做是为了确保训练数据(我们用来训练cv::BasicFaceRecognizer的数据)和我们用来测试模型的数据不会重叠。
// your dataset and remove it from the vector. This is
// done, so that the training data (which we learn the
// cv::BasicFaceRecognizer on) and the test data we test
// the model with, do not overlap.
Mat testSample = images[images.size() - 1];
int testLabel = labels[labels.size() - 1];
images.pop_back();
labels.pop_back();
// 以下几行代码创建了一个用于人脸识别的特征脸模型,并使用从给定CSV文件读取的图像和标签对其进行训练。
// face recognition and train it with the images and
// labels read from the given CSV file.
// 这儿是一个完整的PCA,如果你只想保留10个主成分(即特征脸),那么像这样调用工厂方法:
// 10 principal components (read Eigenfaces), then call
// the factory method like this
//
// EigenFaceRecognizer::create(10);
//
// 如果您想创建一个带有置信度阈值(例如 123.0)的FaceRecognizer,请这样调用它:
// confidence threshold (e.g. 123.0), call it with
//
// EigenFaceRecognizer::create(10, 123.0);
//
// 如果您想使用_所有_特征脸并设置阈值,那么可以这样调用方法:
// then call the method like this
//
// EigenFaceRecognizer::create(0, 123.0);
//
Ptr<EigenFaceRecognizer> model = EigenFaceRecognizer::create();
model->train(images, labels);
// 以下行预测给定测试图像的标签
// test image
int predictedLabel = model->predict(testSample);
//
// 要获得预测的置信度,请使用以下方法调用模型:
//
// int predictedLabel = -1;
// double confidence = 0.0;
// model->predict(testSample, predictedLabel, confidence);
//
string result_message = format("预测类别 = %d / 实际类别 = %d。", predictedLabel, testLabel);
cout << result_message << endl;
// 这是如何获取此特征脸模型的特征值的方法
Mat eigenvalues = model->getEigenValues();
// 我们也可以用同样的方法显示特征向量(即特征脸)
Mat W = model->getEigenVectors();
// 从训练数据中获取样本均值
Mat mean = model->getMean();
// 显示或保存
if(argc == 2) {
imshow("mean", norm_0_255(mean.reshape(1, images[0].rows)));
} else {
imwrite(format("%s/mean.png", output_folder.c_str()), norm_0_255(mean.reshape(1, images[0].rows)));
}
// 显示或保存特征脸
for (int i = 0; i < min(10, W.cols); i++) {
string msg = format("特征值 #%d = %.5f", i, eigenvalues.at<double>(i));
cout << msg << endl;
// 获取特征向量 #i
Mat ev = W.col(i).clone();
// 重塑为原始大小并归一化到[0...255]以便显示。
Mat grayscale = norm_0_255(ev.reshape(1, height));
// 显示图像并应用Jet颜色映射以获得更好的感知效果。
Mat cgrayscale;
applyColorMap(grayscale, cgrayscale, COLORMAP_JET);
// 显示或保存
if(argc == 2) {
imshow(format("eigenface_%d", i), cgrayscale);
} else {
imwrite(format("%s/eigenface_%d.png", output_folder.c_str(), i), norm_0_255(cgrayscale));
}
}
// 以预定义的步长显示或保存图像重建结果
for(int num_components = min(W.cols, 10); num_components < min(W.cols, 300); num_components+=15) {
// 从模型中截取特征向量
Mat evs = Mat(W, Range::all(), Range(0, num_components));
Mat projection = LDA::subspaceProject(evs, mean, images[0].reshape(1,1));
Mat reconstruction = LDA::subspaceReconstruct(evs, mean, projection);
// 归一化结果
reconstruction = norm_0_255(reconstruction.reshape(1, images[0].rows));
// 显示或保存
if(argc == 2) {
imshow(format("eigenface_reconstruction_%d", num_components), reconstruction);
} else {
imwrite(format("%s/eigenface_reconstruction_%d.png", output_folder.c_str(), num_components), reconstruction);
}
}
// 如果我们不写入输出文件夹,则显示
if(argc == 2) {
waitKey(0);
}
return 0;
}
Class passed to an error.
定义 core.hpp:120
字符串 msg
格式化错误消息
定义 core.hpp:139
n 维密集数组类
定义于 mat.hpp:840
CV_NODISCARD_STD Mat clone() const
创建数组及其底层数据的完整副本。
Mat col(int x) const
为指定的矩阵列创建矩阵头。
void copyTo(OutputArray m) const
将矩阵复制到另一个矩阵。
Mat reshape(int cn, int rows=0) const
在不复制数据的情况下更改 2D 矩阵的形状和/或通道数。
_Tp & at(int i0=0)
返回对指定数组元素的引用。
int channels() const
返回矩阵通道数。
int cols
定义 mat.hpp:2204
Matx< _Tp, m1, n1 > reshape() const
改变矩阵形状
指定序列的连续子序列(切片)的模板类。
定义位于 types.hpp:630
这是用于将只读输入数组传递给 OpenCV 函数的代理类。
定义 mat.hpp:161
Mat getMat(int idx=-1) const
Scalar mean(InputArray src, InputArray mask=noArray())
计算数组元素的平均值(均值)。
void normalize(InputArray src, InputOutputArray dst, double alpha=1, double beta=0, int norm_type=NORM_L2, int dtype=-1, InputArray mask=noArray())
归一化数组的范数或数值范围。
std::shared_ptr< _Tp > Ptr
定义 cvstd_wrapper.hpp:23
#define CV_8UC1
定义 interface.h:88
#define CV_8UC3
定义于 interface.h:90
String format(const char *fmt,...)
返回使用类似 printf 表达式格式化的文本字符串。
#define CV_Error(code, msg)
调用错误处理器。
定义 base.hpp:399
void imshow(const String &winname, InputArray mat)
在指定窗口中显示图像。
int waitKey(int delay=0)
等待按键操作。
bool imwrite(const String &filename, InputArray img, const std::vector< int > &params=std::vector< int >())
将图像保存到指定文件。
void applyColorMap(InputArray src, OutputArray dst, int colormap)
在给定图像上应用等同于 GNU Octave/MATLAB 的颜色映射表。
int main(int argc, char *argv[])
定义 highgui_qt.cpp:3
定义 face.hpp:54
定义 core.hpp:107
STL 命名空间。

我使用了jet颜色映射,这样你就可以看到灰度值在特定特征脸中是如何分布的。你可以看到,特征脸不仅编码了面部特征,还编码了图像中的光照(参见特征脸#4中的左侧光,特征脸#5中的右侧光)。

图像

我们已经看到,我们可以从其低维近似重建人脸。那么,一个好的重建需要多少特征脸呢?我将使用\(10,30,\ldots,310\)个特征脸进行子图绘制:

// 以预定义的步长显示或保存图像重建结果
for(int num_components = 10; num_components < 300; num_components+=15) {
// 从模型中截取特征向量
Mat evs = Mat(W, Range::all(), Range(0, num_components));
Mat projection = LDA::subspaceProject(evs, mean, images[0].reshape(1,1));
Mat reconstruction = LDA::subspaceReconstruct(evs, mean, projection);
// 归一化结果
reconstruction = norm_0_255(reconstruction.reshape(1, images[0].rows));
// 显示或保存
if(argc == 2) {
imshow(format("eigenface_reconstruction_%d", num_components), reconstruction);
} else {
imwrite(format("%s/eigenface_reconstruction_%d.png", output_folder.c_str(), num_components), reconstruction);
}
}

10个特征向量显然不足以进行良好的图像重建,50个特征向量可能已经足以编码重要的面部特征。对于AT&T人脸数据库,大约300个特征向量可以实现良好的重建。关于成功人脸识别应选择多少个特征脸有一些经验法则,但这很大程度上取决于输入数据。[325]是开始研究此问题的绝佳起点。

图像

费舍尔脸

主成分分析(PCA)是特征脸方法的核心,它找到特征的线性组合,使数据中的总方差最大化。虽然这显然是一种强大的数据表示方式,但它不考虑任何类别,因此在丢弃组件时可能会丢失大量判别信息。想象一种情况,数据中的方差是由外部来源产生的,比如光照。PCA识别出的组件不一定包含任何判别信息,因此投影的样本会混淆在一起,分类变得不可能(参见http://www.bytefish.de/wiki/pca_lda_with_gnu_octave了解示例)。

线性判别分析执行类特定的降维,由伟大的统计学家R. A. Fisher爵士发明。他成功地在他1936年的论文《分类学问题中多重测量的使用》[95]中用于花卉分类。为了找到能够最好地分离类别的特征组合,线性判别分析最大化类间散度与类内散度的比率,而不是最大化整体散度。其思想很简单:同一类别应紧密聚类,而不同类别在低维表示中应尽可能彼此远离。这一点也得到了BelhumeurHespanhaKriegman的认可,因此他们在[25]中将判别分析应用于人脸识别。

费舍尔脸算法描述

设\(X\)为随机向量,样本来自\(c\)个类

\[\begin{align*} X & = & \{X_1,X_2,\ldots,X_c\} \\ X_i & = & \{x_1, x_2, \ldots, x_n\} \end{align*}\]

散度矩阵\(S_{B}\)和S_{W}计算如下

\[\begin{align*} S_{B} & = & \sum_{i=1}^{c} N_{i} (\mu_i - \mu)(\mu_i - \mu)^{T} \\ S_{W} & = & \sum_{i=1}^{c} \sum_{x_{j} \in X_{i}} (x_j - \mu_i)(x_j - \mu_i)^{T} \end{align*}\]

,其中\(\mu\)是总均值

\[\mu = \frac{1}{N} \sum_{i=1}^{N} x_i\]

而\(\mu_i\)是类\(i \in \{1,\ldots,c\}\)的均值

\[\mu_i = \frac{1}{|X_i|} \sum_{x_j \in X_i} x_j\]

费舍尔的经典算法现在寻找一个投影\(W\),它最大化类别可分离性准则

\[W_{opt} = \operatorname{arg\,max}_{W} \frac{|W^T S_B W|}{|W^T S_W W|}\]

根据[25],此优化问题的解由求解广义特征值问题给出

\[\begin{align*} S_{B} v_{i} & = & \lambda_{i} S_w v_{i} \nonumber \\ S_{W}^{-1} S_{B} v_{i} & = & \lambda_{i} v_{i} \end{align*}\]

还有一个问题待解决:\(S_{W}\)的秩最大为\((N-c)\),其中\(N\)为样本数,\(c\)为类别数。在模式识别问题中,样本数\(N\)几乎总是小于输入数据的维度(像素数量),因此散度矩阵\(S_{W}\)变为奇异矩阵(参见[229])。在[25]中,通过对数据执行主成分分析并将样本投影到\((N-c)\)维空间来解决这个问题。然后对降维后的数据执行线性判别分析,因为\(S_{W}\)不再是奇异矩阵。

优化问题可以重写为

\[\begin{align*} W_{pca} & = & \operatorname{arg\,max}_{W} |W^T S_T W| \\ W_{fld} & = & \operatorname{arg\,max}_{W} \frac{|W^T W_{pca}^T S_{B} W_{pca} W|}{|W^T W_{pca}^T S_{W} W_{pca} W|} \end{align*}\]

将样本投影到\((c-1)\)维空间的变换矩阵\(W\)由下式给出

\[W = W_{fld}^{T} W_{pca}^{T}\]

OpenCV中的费舍尔脸

此演示应用程序的源代码也可在本文档附带的 src 文件夹中找到。

/*
* 版权所有 (c) 2011. Philipp Wagner <bytefish[at]gmx[dot]de>。
* 根据BSD简化许可证条款发布到公共领域。
*
* 允许以源代码和二进制形式进行重新分发和使用,无论是否修改,但须满足以下条件:
* * 重新分发源代码必须保留上述版权声明、此条件列表和以下免责声明。
* * 以二进制形式重新分发必须在分发附带的文档和/或其他材料中复制上述版权声明、此条件列表和以下免责声明。
* * 未经特定的事先书面许可,不得使用本组织名称或其贡献者的名称来认可或推广从本软件派生的产品。
* 参见 <https://open-source.org.cn/licenses/bsd-license>
* See <https://open-source.org.cn/licenses/bsd-license>
* documentation and/or other materials provided with the distribution.
* * Neither the name of the organization nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* See <https://open-source.org.cn/licenses/bsd-license>
*/
#include "opencv2/core.hpp"
#include "opencv2/face.hpp"
#include <iostream>
#include <fstream>
#include <sstream>
using namespace cv;
using namespace cv::face;
using namespace std;
static Mat norm_0_255(InputArray _src) {
Mat src = _src.getMat();
// 创建并返回归一化图像
Mat dst;
switch(src.channels()) {
case 1:
cv::normalize(_src, dst, 0, 255, NORM_MINMAX, CV_8UC1);
break;
case 3:
cv::normalize(_src, dst, 0, 255, NORM_MINMAX, CV_8UC3);
break;
default:
src.copyTo(dst);
break;
}
return dst;
}
static void read_csv(const string& filename, vector<Mat>& images, vector<int>& labels, char separator = ';') {
std::ifstream file(filename.c_str(), ifstream::in);
if (!file) {
string error_message = "未提供有效的输入文件,请检查文件名。";
CV_Error(Error::StsBadArg, error_message);
}
string line, path, classlabel;
while (getline(file, line)) {
stringstream liness(line);
getline(liness, path, separator);
getline(liness, classlabel);
if(!path.empty() && !classlabel.empty()) {
images.push_back(imread(path, 0));
labels.push_back(atoi(classlabel.c_str()));
}
}
}
int main(int argc, const char *argv[]) {
// 检查命令行参数是否有效,如果未提供参数,则打印使用说明。
// if no arguments were given.
if (argc < 2) {
cout << "用法: " << argv[0] << " <csv.ext> <输出文件夹> " << endl;
exit(1);
}
string output_folder = ".";
if (argc == 3) {
output_folder = string(argv[2]);
}
// 获取CSV文件的路径。
string fn_csv = string(argv[1]);
// 这些向量存储图像和相应的标签。
vector<Mat> images;
vector<int> labels;
// 读取数据。如果给定的输入文件名无效,此操作可能会失败。
// input filename is given.
try {
read_csv(fn_csv, images, labels);
} catch (const cv::Exception& e) {
cerr << "打开文件 \"" << fn_csv << "\" 时出错。原因: " << e.msg << endl;
// 我们无能为力了
exit(1);
}
// 如果此演示所需的图像不足,则退出。
if(images.size() <= 1) {
string error_message = "此演示需要至少2张图像才能运行。请向您的数据集中添加更多图像!";
CV_Error(Error::StsError, error_message);
}
// 从第一张图像获取高度。我们以后会在代码中需要它来将图像重塑为它们的原始大小。
// later in code to reshape the images to their original
// size
int height = images[0].rows;
// 以下几行代码简单地从您的数据集中获取最后一张图像,并将其从向量中移除。这样做是为了确保训练数据(我们用来训练cv::BasicFaceRecognizer的数据)和我们用来测试模型的数据不会重叠。
// your dataset and remove it from the vector. This is
// done, so that the training data (which we learn the
// cv::BasicFaceRecognizer on) and the test data we test
// the model with, do not overlap.
Mat testSample = images[images.size() - 1];
int testLabel = labels[labels.size() - 1];
images.pop_back();
labels.pop_back();
// 以下行创建了一个费舍尔脸模型,用于
// face recognition and train it with the images and
// labels read from the given CSV file.
// 如果您只想保留10个费舍尔脸,则调用
// the factory method like this
//
// FisherFaceRecognizer::create(10);
//
// 但是,丢弃费舍尔脸是没有用的!请务必始终尝试使用_所有_可用的费舍尔脸进行分类。
// always try to use _all_ available Fisherfaces for
// classification.
//
// 如果您想创建一个带有置信度阈值(例如 123.0)的FaceRecognizer,请这样调用它:
// 置信度阈值(例如 123.0)并使用_所有_费舍尔脸,然后调用它:
// Fisherfaces, then call it with
//
// FisherFaceRecognizer::create(0, 123.0);
//
Ptr<FisherFaceRecognizer> model = FisherFaceRecognizer::create();
model->train(images, labels);
// 以下行预测给定测试图像的标签
// test image
int predictedLabel = model->predict(testSample);
//
// 要获得预测的置信度,请使用以下方法调用模型:
//
// int predictedLabel = -1;
// double confidence = 0.0;
// model->predict(testSample, predictedLabel, confidence);
//
string result_message = format("预测类别 = %d / 实际类别 = %d。", predictedLabel, testLabel);
cout << result_message << endl;
// 这是如何获取此特征脸模型的特征值的方法
Mat eigenvalues = model->getEigenValues();
// 我们也可以用同样的方法显示特征向量(即特征脸)
Mat W = model->getEigenVectors();
// 从训练数据中获取样本均值
Mat mean = model->getMean();
// 显示或保存
if(argc == 2) {
imshow("mean", norm_0_255(mean.reshape(1, images[0].rows)));
} else {
imwrite(format("%s/mean.png", output_folder.c_str()), norm_0_255(mean.reshape(1, images[0].rows)));
}
// 显示或保存最多16个费舍尔脸中的第一个
for (int i = 0; i < min(16, W.cols); i++) {
string msg = format("特征值 #%d = %.5f", i, eigenvalues.at<double>(i));
cout << msg << endl;
// 获取特征向量 #i
Mat ev = W.col(i).clone();
// 重塑为原始大小并归一化到[0...255]以便显示。
Mat grayscale = norm_0_255(ev.reshape(1, height));
// 显示图像并应用Bone颜色映射以获得更好的感知效果。
Mat cgrayscale;
applyColorMap(grayscale, cgrayscale, COLORMAP_BONE);
// 显示或保存
if(argc == 2) {
imshow(format("fisherface_%d", i), cgrayscale);
} else {
imwrite(format("%s/fisherface_%d.png", output_folder.c_str(), i), norm_0_255(cgrayscale));
}
}
// 以预定义的步长显示或保存图像重建结果
for(int num_component = 0; num_component < min(16, W.cols); num_component++) {
// 从模型中切片费舍尔脸
Mat ev = W.col(num_component);
Mat projection = LDA::subspaceProject(ev, mean, images[0].reshape(1,1));
Mat reconstruction = LDA::subspaceReconstruct(ev, mean, projection);
// 归一化结果
reconstruction = norm_0_255(reconstruction.reshape(1, images[0].rows));
// 显示或保存
if(argc == 2) {
imshow(format("fisherface_reconstruction_%d", num_component), reconstruction);
} else {
imwrite(format("%s/fisherface_reconstruction_%d.png", output_folder.c_str(), num_component), reconstruction);
}
}
// 如果我们不写入输出文件夹,则显示
if(argc == 2) {
waitKey(0);
}
return 0;
}

对于这个例子,我将使用耶鲁人脸数据库 A,仅仅是因为它的图表更美观。每个费舍尔脸的长度与原始图像相同,因此可以作为图像显示。这个演示显示(或保存)了最多16个费舍尔脸中的前几个。

图像

费舍尔脸方法学习一个类别特定的变换矩阵,因此它们不像特征脸方法那样明显地捕捉光照。判别分析反而寻找面部特征来区分不同的人。需要提及的是,费舍尔脸方法的性能也严重依赖于输入数据。实际来说:如果你只用光照良好的图片训练费舍尔脸,然后试图识别光照条件差的场景中的人脸,那么该方法很可能会找到错误的成分(仅仅是因为这些特征在光照条件差的图片上可能不占主导地位)。这在某种程度上是合乎逻辑的,因为该方法没有机会学习光照。

费舍尔脸允许重建投影图像,就像特征脸一样。但是由于我们只识别了区分不同主体的特征,你不能期望原始图像有很好的重建。对于费舍尔脸方法,我们将样本图像投影到每个费舍尔脸上。这样你就会有一个很好的可视化,显示每个费舍尔脸描述了哪些特征。

// 以预定义的步长显示或保存图像重建结果
for(int num_component = 0; num_component < min(16, W.cols); num_component++) {
// 从模型中切片费舍尔脸
Mat ev = W.col(num_component);
Mat projection = LDA::subspaceProject(ev, mean, images[0].reshape(1,1));
Mat reconstruction = LDA::subspaceReconstruct(ev, mean, projection);
// 归一化结果
reconstruction = norm_0_255(reconstruction.reshape(1, images[0].rows));
// 显示或保存
if(argc == 2) {
imshow(format("fisherface_reconstruction_%d", num_component), reconstruction);
} else {
imwrite(format("%s/fisherface_reconstruction_%d.png", output_folder.c_str(), num_component), reconstruction);
}
}

这些差异对人眼来说可能很微妙,但你应该能看到一些不同。

图像

局部二值模式直方图

特征脸和费舍尔脸对人脸识别采取了一种整体方法。您将数据视为高维图像空间中的一个向量。我们都知道高维性不好,因此找到一个低维子空间,其中(可能)有用的信息被保留。特征脸方法最大化总散度,如果方差由外部来源产生,这可能会导致问题,因为对所有类别具有最大方差的组件不一定对分类有用(参见http://www.bytefish.de/wiki/pca_lda_with_gnu_octave)。因此,为了保留一些判别信息,我们应用了线性判别分析并进行了优化,如费舍尔脸方法中所述。费舍尔脸方法效果很好...至少对于我们模型中假定的受限场景。

现在,现实生活并不完美。你根本无法保证图像中完美的光照设置,或者一个人有10张不同的图像。那么,如果每个人只有一张图像怎么办?我们对子空间的协方差估计可能会严重错误,识别也会如此。还记得特征脸方法在AT&T人脸数据库上的识别率为96%吗?我们到底需要多少张图像才能获得如此有用的估计?以下是特征脸和费舍尔脸方法在AT&T人脸数据库(一个相当简单的图像数据库)上的Rank-1识别率:

图像

因此,为了获得良好的识别率,每个人至少需要8(±1)张图像,费舍尔脸方法在这方面并没有真正帮助。上述实验是使用facerec框架在https://github.com/bytefish/facerec进行的10折交叉验证结果。这不是一篇出版物,所以我不会用深入的数学分析来支持这些数字。请查阅[189],了解这两种方法在小训练数据集情况下的详细分析。

因此,一些研究集中于从图像中提取局部特征。其思想不是将整个图像视为高维向量,而只描述对象的局部特征。以这种方式提取的特征将隐含地具有低维性。这是一个很好的想法!但您很快就会发现,我们给出的图像表示不仅受光照变化的影响。想想图像中的尺度、平移或旋转等问题——您的局部描述必须至少对这些问题具有一定的鲁棒性。就像SIFT一样,局部二值模式方法源于2D纹理分析。局部二值模式的基本思想是通过将每个像素与其邻域进行比较来总结图像中的局部结构。以一个像素为中心,并根据其邻居对其进行阈值化。如果中心像素的强度大于或等于其邻居,则记为1;否则记为0。最终每个像素都会得到一个二进制数,就像这样:

  1. 因此,对于8个周围像素,您将得到2^8种可能的组合,称为局部二值模式或有时称为LBP代码。文献中描述的第一个LBP运算符实际上使用了固定的3 x 3邻域,就像这样:
图像

LBPH算法描述

LBP算子的更正式描述可以给出为

\[LBP(x_c, y_c) = \sum_{p=0}^{P-1} 2^p s(i_p - i_c)\]

,其中\((x_c, y_c)\)是强度为\(i_c\)的中心像素;\(i_n\)是邻居像素的强度。\(s\)是符号函数,定义为

\[\begin{equation} s(x) = \begin{cases} 1 & \text{如果 \(x \geq 0\)}\\ 0 & \text{否则} \end{cases} \end{equation}\]

这种描述使您能够捕捉图像中非常细微的细节。事实上,作者能够与纹理分类的最新结果竞争。在操作符发布后不久,人们注意到固定邻域未能编码尺度不同的细节。因此,该操作符在[4]中扩展为使用可变邻域。其思想是在一个可变半径的圆上对齐任意数量的邻居,这使得能够捕捉以下邻域:

图像

对于给定的点\((x_c,y_c)\),邻居\((x_p,y_p), p \in P\)的位置可以通过以下公式计算:

\[\begin{align*} x_{p} & = & x_c + R \cos({\frac{2\pi p}{P}})\\ y_{p} & = & y_c - R \sin({\frac{2\pi p}{P}}) \end{align*}\]

其中\(R\)是圆的半径,\(P\)是采样点的数量。

该算子是原始LBP代码的扩展,因此有时被称为扩展LBP(也称为圆形LBP)。如果圆上点的坐标与图像坐标不对应,则该点将被插值。计算机科学中有许多巧妙的插值方案,OpenCV实现采用双线性插值。

\[\begin{align*} f(x,y) \approx \begin{bmatrix} 1-x & x \end{bmatrix} \begin{bmatrix} f(0,0) & f(0,1) \\ f(1,0) & f(1,1) \end{bmatrix} \begin{bmatrix} 1-y \\ y \end{bmatrix}. \end{align*}\]

根据定义,LBP算子对单调灰度变换具有鲁棒性。我们可以通过观察人工修改图像的LBP图像来轻松验证这一点(这样您就可以看到LBP图像是什么样子!)。

图像

那么,接下来要做的就是如何在人脸识别模型中融入空间信息。Ahonen等人[4]提出的表示方法是将LBP图像划分为\(m\)个局部区域,并从每个区域提取直方图。然后通过连接局部直方图(而非合并它们)获得空间增强的特征向量。这些直方图被称为局部二值模式直方图

OpenCV中的局部二值模式直方图

此演示应用程序的源代码也可在本文档附带的 src 文件夹中找到。

/*
* 版权所有 (c) 2011. Philipp Wagner <bytefish[at]gmx[dot]de>。
* 根据BSD简化许可证条款发布到公共领域。
*
* 允许以源代码和二进制形式进行重新分发和使用,无论是否修改,但须满足以下条件:
* * 重新分发源代码必须保留上述版权声明、此条件列表和以下免责声明。
* * 以二进制形式重新分发必须在分发附带的文档和/或其他材料中复制上述版权声明、此条件列表和以下免责声明。
* * 未经特定的事先书面许可,不得使用本组织名称或其贡献者的名称来认可或推广从本软件派生的产品。
* 参见 <https://open-source.org.cn/licenses/bsd-license>
* See <https://open-source.org.cn/licenses/bsd-license>
* documentation and/or other materials provided with the distribution.
* * Neither the name of the organization nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* See <https://open-source.org.cn/licenses/bsd-license>
*/
#include "opencv2/core.hpp"
#include "opencv2/face.hpp"
#include <iostream>
#include <fstream>
#include <sstream>
using namespace cv;
using namespace cv::face;
using namespace std;
static void read_csv(const string& filename, vector<Mat>& images, vector<int>& labels, char separator = ';') {
std::ifstream file(filename.c_str(), ifstream::in);
if (!file) {
string error_message = "未提供有效的输入文件,请检查文件名。";
CV_Error(Error::StsBadArg, error_message);
}
string line, path, classlabel;
while (getline(file, line)) {
stringstream liness(line);
getline(liness, path, separator);
getline(liness, classlabel);
if(!path.empty() && !classlabel.empty()) {
images.push_back(imread(path, 0));
labels.push_back(atoi(classlabel.c_str()));
}
}
}
int main(int argc, const char *argv[]) {
// 检查命令行参数是否有效,如果未提供参数,则打印使用说明。
// if no arguments were given.
if (argc != 2) {
cout << "用法: " << argv[0] << " <csv.ext>" << endl;
exit(1);
}
// 获取CSV文件的路径。
string fn_csv = string(argv[1]);
// 这些向量存储图像和相应的标签。
vector<Mat> images;
vector<int> labels;
// 读取数据。如果给定的输入文件名无效,此操作可能会失败。
// input filename is given.
try {
read_csv(fn_csv, images, labels);
} catch (const cv::Exception& e) {
cerr << "打开文件 \"" << fn_csv << "\" 时出错。原因: " << e.msg << endl;
// 我们无能为力了
exit(1);
}
// 如果此演示所需的图像不足,则退出。
if(images.size() <= 1) {
string error_message = "此演示需要至少2张图像才能运行。请向您的数据集中添加更多图像!";
CV_Error(Error::StsError, error_message);
}
// 以下几行代码简单地从您的数据集中获取最后一张图像,并将其从向量中移除。这样做是为了确保训练数据(我们用来训练cv::BasicFaceRecognizer的数据)和我们用来测试模型的数据不会重叠。
// your dataset and remove it from the vector. This is
// done, so that the training data (which we learn the
// cv::LBPHFaceRecognizer on) 和我们测试模型的测试数据
// the model with, do not overlap.
Mat testSample = images[images.size() - 1];
int testLabel = labels[labels.size() - 1];
images.pop_back();
labels.pop_back();
// 以下行创建了一个LBPH模型,用于
// face recognition and train it with the images and
// labels read from the given CSV file.
//
// LBPHFaceRecognizer使用扩展局部二值模式
// (可能在以后可以使用其他操作符进行配置),并且具有以下默认值
// radius = 1
//
// neighbors = 8
// grid_x = 8
// grid_y = 8
// 因此,如果您想要一个使用半径为2和16个邻居的LBPH FaceRecognizer,请这样调用工厂方法:
//
// 2 and 16 neighbors, call the factory method with
// cv::face::LBPHFaceRecognizer::create(2, 16);
//
// 如果您想要一个阈值(例如 123.0)并使用其默认值,请这样调用:
//
// And if you want a threshold (e.g. 123.0) call it with its default values
//
// cv::face::LBPHFaceRecognizer::create(1,8,8,8,123.0)
//
Ptr<LBPHFaceRecognizer> model = LBPHFaceRecognizer::create();
model->train(images, labels);
// 以下行预测给定测试图像的标签
// test image
int predictedLabel = model->predict(testSample);
//
// 要获得预测的置信度,请使用以下方法调用模型:
//
// int predictedLabel = -1;
// double confidence = 0.0;
// model->predict(testSample, predictedLabel, confidence);
//
string result_message = format("预测类别 = %d / 实际类别 = %d。", predictedLabel, testLabel);
cout << result_message << endl;
// 首先,我们将用它将LBPHFaceRecognizer的阈值设置为0.0,而不重新训练模型。这在评估模型时可能很有用。
// to 0.0 without retraining the model. This can be useful if
// you are evaluating the model
//
model->setThreshold(0.0);
// 现在此模型的阈值已设置为0.0。预测现在返回-1,因为它不可能有一个低于它的距离。
// now returns -1, as it's impossible to have a distance below
// it
predictedLabel = model->predict(testSample);
cout << "预测类别 = " << predictedLabel << endl;
// 显示一些关于模型的信息,因为不像特征脸/费舍尔脸那样有酷炫的模型数据可显示。
// Model data to display as in Eigenfaces/Fisherfaces.
// 由于效率原因,LBP图像不存储在模型中
// within the model
cout << "模型信息:" << endl;
string model_info = format("\tLBPH(半径=%i, 邻居=%i, grid_x=%i, grid_y=%i, 阈值=%.2f)",
model->getRadius(),
model->getNeighbors(),
model->getGridX(),
model->getGridY(),
model->getThreshold());
cout << model_info << endl;
// 例如,我们可以获取直方图
vector<Mat> histograms = model->getHistograms();
// 但是我真的应该可视化它吗?也许长度更有趣。
cout << "直方图大小: " << histograms[0].total() << endl;
return 0;
}

总结

您已经学习了如何在实际应用程序中使用新的FaceRecognizer。阅读完本文档后,您也了解了算法的工作原理,现在是时候尝试可用的算法了。使用它们,改进它们,让OpenCV社区参与进来!

致谢

没有使用AT&T人脸数据库耶鲁人脸数据库A/B人脸图像的许可,本文档是不可能完成的。

人脸数据库

重要提示:使用这些图像时,请注明“AT&T 剑桥实验室”。

人脸数据库,原名ORL人脸数据库,包含一组在1992年4月至1994年4月期间拍摄的人脸图像。该数据库在与剑桥大学工程系语音、视觉和机器人小组合作进行的人脸识别项目中被使用。

该数据库包含40个不同主题的每人十张不同图像。对于某些主题,图像是在不同时间拍摄的,光照、面部表情(睁眼/闭眼,微笑/不微笑)和面部细节(戴眼镜/不戴眼镜)各不相同。所有图像均在深色均匀背景下拍摄,主题处于直立、正面位置(允许一些侧向移动)。

文件格式为PGM。每张图像大小为92x112像素,每个像素有256个灰度级别。图像组织在40个目录中(每个主题一个),目录名称形式为sX,其中X表示主题编号(1到40之间)。在每个目录中,有该主题的十张不同图像,图像名称形式为Y.pgm,其中Y是该主题的图像编号(1到10之间)。

数据库的副本可从以下地址获取:http://www.cl.cam.ac.uk/research/dtg/attarchive/pub/data/att_faces.zip

耶鲁人脸数据库 A

经作者许可,我被允许展示少量图像(例如主题1及其所有变体)以及来自耶鲁人脸数据库A或耶鲁人脸数据库B的所有图像(如特征脸和费舍尔脸)。

耶鲁人脸数据库 A(大小6.4MB)包含15个个体的165张GIF格式灰度图像。每个主体有11张图像,每张图像对应不同的面部表情或配置:中心光、戴眼镜、高兴、左侧光、不戴眼镜、正常、右侧光、悲伤、困倦、惊讶和眨眼。(来源: http://cvc.yale.edu/projects/yalefaces/yalefaces.html)

耶鲁人脸数据库 B

经作者许可,我被允许展示少量图像(例如主题1及其所有变体)以及来自耶鲁人脸数据库A或耶鲁人脸数据库B的所有图像(如特征脸和费舍尔脸)。

扩展耶鲁人脸数据库 B 包含28个人类主体在9种姿态和64种光照条件下的16128张图像。该数据库的数据格式与耶鲁人脸数据库 B 相同。有关数据格式的更详细信息,请参阅耶鲁人脸数据库 B 的主页(或该页面的副本)。

您可以自由使用扩展耶鲁人脸数据库B进行研究。所有使用此数据库的出版物都应注明使用了“扩展耶鲁人脸数据库B”,并引用Athinodoros Georghiades、Peter Belhumeur和David Kriegman的论文“从少到多:可变光照和姿态下人脸识别的光照锥模型”,PAMI,2001,[bibtex]

与原始的包含10个主体的耶鲁人脸数据库B不同,扩展数据库首次由Kuang-Chih Lee、Jeffrey Ho和David Kriegman在“可变光照下人脸识别的线性子空间获取,PAMI,2005年5月[pdf]。”所有实验中使用的测试图像数据都经过手动对齐、裁剪,然后重新调整为168x192像素的图像。如果您发布使用裁剪图像的实验结果,请同时引用PAMI2005论文。(来源: http://vision.ucsd.edu/~leekc/ExtYaleDatabase/ExtYaleB.html)

附录

创建CSV文件

你肯定不想手动创建CSV文件。我为你准备了一个小小的Python脚本create_csv.py(你可以在本教程附带的src/create_csv.py找到它),它可以自动为你创建一个CSV文件。如果你的图像是按照这样的层次结构存放的(/basepath/<subject>/<image.ext>):

philipp@mango:~/facerec/data/at$ tree
.
|-- s1
| |-- 1.pgm
| |-- ...
| |-- 10.pgm
|-- s2
| |-- 1.pgm
| |-- ...
| |-- 10.pgm
...
|-- s40
| |-- 1.pgm
| |-- ...
| |-- 10.pgm

那么只需像这样调用create_csv.py at,其中'at'是文件夹的基本路径,然后您就可以保存输出:

philipp@mango:~/facerec/data$ python create_csv.py at
at/s13/2.pgm;0
at/s13/7.pgm;0
at/s13/6.pgm;0
at/s13/9.pgm;0
at/s13/5.pgm;0
at/s13/3.pgm;0
at/s13/4.pgm;0
at/s13/10.pgm;0
at/s13/8.pgm;0
at/s13/1.pgm;0
at/s17/2.pgm;1
at/s17/7.pgm;1
at/s17/6.pgm;1
at/s17/9.pgm;1
at/s17/5.pgm;1
at/s17/3.pgm;1
[...]

这是脚本,如果你找不到的话

#!/usr/bin/env python

import sys
import os.path

# This is a tiny script to help you creating a CSV file from a face
# database with a similar hierarchie:
#
#  philipp@mango:~/facerec/data/at$ tree
#  .
#  |-- README
#  |-- s1
#  |   |-- 1.pgm
#  |   |-- ...
#  |   |-- 10.pgm
#  |-- s2
#  |   |-- 1.pgm
#  |   |-- ...
#  |   |-- 10.pgm
#  ...
#  |-- s40
#  |   |-- 1.pgm
#  |   |-- ...
#  |   |-- 10.pgm
#

if __name__ == "__main__":

    if len(sys.argv) != 2:
        print "usage: create_csv <base_path>"
        sys.exit(1)

    BASE_PATH=sys.argv[1]
    SEPARATOR=";"

    label = 0
    for dirname, dirnames, filenames in os.walk(BASE_PATH):
        for subdirname in dirnames:
            subject_path = os.path.join(dirname, subdirname)
            for filename in os.listdir(subject_path):
                abs_path = "%s/%s" % (subject_path, filename)
                print "%s%s%d" % (abs_path, SEPARATOR, label)
            label = label + 1

对齐人脸图像

图像数据的精确对齐在情绪检测等任务中尤为重要,因为您需要尽可能多的细节。相信我……您不想手动完成此操作。因此,我为您准备了一个小巧的 Python 脚本。代码非常易于使用。要缩放、旋转和裁剪人脸图像,您只需调用 CropFace(image, eye_left, eye_right, offset_pct, dest_sz),其中:

  • eye_left 是左眼的位置
  • eye_right 是右眼的位置
  • offset_pct 是您希望在眼睛旁边保留的图像百分比(水平、垂直方向)
  • dest_sz 是输出图像的大小

如果您对所有图像使用相同的offset_pctdest_sz,那么它们都会在眼睛处对齐。

#!/usr/bin/env python
# Software License Agreement (BSD License)
#
# Copyright (c) 2012, Philipp Wagner
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
#  * Redistributions of source code must retain the above copyright
#    notice, this list of conditions and the following disclaimer.
#  * Redistributions in binary form must reproduce the above
#    copyright notice, this list of conditions and the following
#    disclaimer in the documentation and/or other materials provided
#    with the distribution.
#  * Neither the name of the author nor the names of its
#    contributors may be used to endorse or promote products derived
#    from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.

import sys, math, Image

def Distance(p1,p2):
  dx = p2[0] - p1[0]
  dy = p2[1] - p1[1]
  return math.sqrt(dx*dx+dy*dy)

def ScaleRotateTranslate(image, angle, center = None, new_center = None, scale = None, resample=Image.BICUBIC):
  if (scale is None) and (center is None):
    return image.rotate(angle=angle, resample=resample)
  nx,ny = x,y = center
  sx=sy=1.0
  if new_center:
    (nx,ny) = new_center
  if scale:
    (sx,sy) = (scale, scale)
  cosine = math.cos(angle)
  sine = math.sin(angle)
  a = cosine/sx
  b = sine/sx
  c = x-nx*a-ny*b
  d = -sine/sy
  e = cosine/sy
  f = y-nx*d-ny*e
  return image.transform(image.size, Image.AFFINE, (a,b,c,d,e,f), resample=resample)

def CropFace(image, eye_left=(0,0), eye_right=(0,0), offset_pct=(0.2,0.2), dest_sz = (70,70)):
  # calculate offsets in original image
  offset_h = math.floor(float(offset_pct[0])*dest_sz[0])
  offset_v = math.floor(float(offset_pct[1])*dest_sz[1])
  # get the direction
  eye_direction = (eye_right[0] - eye_left[0], eye_right[1] - eye_left[1])
  # calc rotation angle in radians
  rotation = -math.atan2(float(eye_direction[1]),float(eye_direction[0]))
  # distance between them
  dist = Distance(eye_left, eye_right)
  # calculate the reference eye-width
  reference = dest_sz[0] - 2.0*offset_h
  # scale factor
  scale = float(dist)/float(reference)
  # rotate original around the left eye
  image = ScaleRotateTranslate(image, center=eye_left, angle=rotation)
  # crop the rotated image
  crop_xy = (eye_left[0] - scale*offset_h, eye_left[1] - scale*offset_v)
  crop_size = (dest_sz[0]*scale, dest_sz[1]*scale)
  image = image.crop((int(crop_xy[0]), int(crop_xy[1]), int(crop_xy[0]+crop_size[0]), int(crop_xy[1]+crop_size[1])))
  # resize it
  image = image.resize(dest_sz, Image.ANTIALIAS)
  return image

def readFileNames():
    try:
        inFile = open('path_to_created_csv_file.csv')
    except:
        raise IOError('There is no file named path_to_created_csv_file.csv in current directory.')
        return False

    picPath = []
    picIndex = []

    for line in inFile.readlines():
        if line != '':
            fields = line.rstrip().split(';')
            picPath.append(fields[0])
            picIndex.append(int(fields[1]))

    return (picPath, picIndex)


if __name__ == "__main__":
  [images, indexes]=readFileNames()
if not os.path.exists("modified"):
    os.makedirs("modified")
for img in images:
    image =  Image.open(img)
    CropFace(image, eye_left=(252,364), eye_right=(420,366), offset_pct=(0.1,0.1), dest_sz=(200,200)).save("modified/"+img.rstrip().split('/')[1]+"_10_10_200_200.jpg")
    CropFace(image, eye_left=(252,364), eye_right=(420,366), offset_pct=(0.2,0.2), dest_sz=(200,200)).save("modified/"+img.rstrip().split('/')[1]+"_20_20_200_200.jpg")
    CropFace(image, eye_left=(252,364), eye_right=(420,366), offset_pct=(0.3,0.3), dest_sz=(200,200)).save("modified/"+img.rstrip().split('/')[1]+"_30_30_200_200.jpg")
    CropFace(image, eye_left=(252,364), eye_right=(420,366), offset_pct=(0.2,0.2)).save("modified/"+img.rstrip().split('/')[1]+"_20_20_70_70.jpg")

想象一下,我们有一张阿诺德·施瓦辛格的照片,该照片受公共领域许可。眼睛的(x,y)位置大约是左眼(252,364)和右眼(420,366)。现在您只需定义水平偏移、垂直偏移以及缩放、旋转和裁剪后的人脸应有的大小。

这里有一些例子

配置裁剪、缩放、旋转后的人脸
0.1 (10%), 0.1 (10%), (200,200)
0.2 (20%), 0.2 (20%), (200,200)
0.3 (30%), 0.3 (30%), (200,200)
0.2 (20%), 0.2 (20%), (70,70)

AT&T 人脸数据库的CSV文件

/home/philipp/facerec/data/at/s13/2.pgm;12
/home/philipp/facerec/data/at/s13/7.pgm;12
/home/philipp/facerec/data/at/s13/6.pgm;12
/home/philipp/facerec/data/at/s13/9.pgm;12
/home/philipp/facerec/data/at/s13/5.pgm;12
/home/philipp/facerec/data/at/s13/3.pgm;12
/home/philipp/facerec/data/at/s13/4.pgm;12
/home/philipp/facerec/data/at/s13/10.pgm;12
/home/philipp/facerec/data/at/s13/8.pgm;12
/home/philipp/facerec/data/at/s13/1.pgm;12
/home/philipp/facerec/data/at/s17/2.pgm;16
/home/philipp/facerec/data/at/s17/7.pgm;16
/home/philipp/facerec/data/at/s17/6.pgm;16
/home/philipp/facerec/data/at/s17/9.pgm;16
/home/philipp/facerec/data/at/s17/5.pgm;16
/home/philipp/facerec/data/at/s17/3.pgm;16
/home/philipp/facerec/data/at/s17/4.pgm;16
/home/philipp/facerec/data/at/s17/10.pgm;16
/home/philipp/facerec/data/at/s17/8.pgm;16
/home/philipp/facerec/data/at/s17/1.pgm;16
/home/philipp/facerec/data/at/s32/2.pgm;31
/home/philipp/facerec/data/at/s32/7.pgm;31
/home/philipp/facerec/data/at/s32/6.pgm;31
/home/philipp/facerec/data/at/s32/9.pgm;31
/home/philipp/facerec/data/at/s32/5.pgm;31
/home/philipp/facerec/data/at/s32/3.pgm;31
/home/philipp/facerec/data/at/s32/4.pgm;31
/home/philipp/facerec/data/at/s32/10.pgm;31
/home/philipp/facerec/data/at/s32/8.pgm;31
/home/philipp/facerec/data/at/s32/1.pgm;31
/home/philipp/facerec/data/at/s10/2.pgm;9
/home/philipp/facerec/data/at/s10/7.pgm;9
/home/philipp/facerec/data/at/s10/6.pgm;9
/home/philipp/facerec/data/at/s10/9.pgm;9
/home/philipp/facerec/data/at/s10/5.pgm;9
/home/philipp/facerec/data/at/s10/3.pgm;9
/home/philipp/facerec/data/at/s10/4.pgm;9
/home/philipp/facerec/data/at/s10/10.pgm;9
/home/philipp/facerec/data/at/s10/8.pgm;9
/home/philipp/facerec/data/at/s10/1.pgm;9
/home/philipp/facerec/data/at/s27/2.pgm;26
/home/philipp/facerec/data/at/s27/7.pgm;26
/home/philipp/facerec/data/at/s27/6.pgm;26
/home/philipp/facerec/data/at/s27/9.pgm;26
/home/philipp/facerec/data/at/s27/5.pgm;26
/home/philipp/facerec/data/at/s27/3.pgm;26
/home/philipp/facerec/data/at/s27/4.pgm;26
/home/philipp/facerec/data/at/s27/10.pgm;26
/home/philipp/facerec/data/at/s27/8.pgm;26
/home/philipp/facerec/data/at/s27/1.pgm;26
/home/philipp/facerec/data/at/s5/2.pgm;4
/home/philipp/facerec/data/at/s5/7.pgm;4
/home/philipp/facerec/data/at/s5/6.pgm;4
/home/philipp/facerec/data/at/s5/9.pgm;4
/home/philipp/facerec/data/at/s5/5.pgm;4
/home/philipp/facerec/data/at/s5/3.pgm;4
/home/philipp/facerec/data/at/s5/4.pgm;4
/home/philipp/facerec/data/at/s5/10.pgm;4
/home/philipp/facerec/data/at/s5/8.pgm;4
/home/philipp/facerec/data/at/s5/1.pgm;4
/home/philipp/facerec/data/at/s20/2.pgm;19
/home/philipp/facerec/data/at/s20/7.pgm;19
/home/philipp/facerec/data/at/s20/6.pgm;19
/home/philipp/facerec/data/at/s20/9.pgm;19
/home/philipp/facerec/data/at/s20/5.pgm;19
/home/philipp/facerec/data/at/s20/3.pgm;19
/home/philipp/facerec/data/at/s20/4.pgm;19
/home/philipp/facerec/data/at/s20/10.pgm;19
/home/philipp/facerec/data/at/s20/8.pgm;19
/home/philipp/facerec/data/at/s20/1.pgm;19
/home/philipp/facerec/data/at/s30/2.pgm;29
/home/philipp/facerec/data/at/s30/7.pgm;29
/home/philipp/facerec/data/at/s30/6.pgm;29
/home/philipp/facerec/data/at/s30/9.pgm;29
/home/philipp/facerec/data/at/s30/5.pgm;29
/home/philipp/facerec/data/at/s30/3.pgm;29
/home/philipp/facerec/data/at/s30/4.pgm;29
/home/philipp/facerec/data/at/s30/10.pgm;29
/home/philipp/facerec/data/at/s30/8.pgm;29
/home/philipp/facerec/data/at/s30/1.pgm;29
/home/philipp/facerec/data/at/s39/2.pgm;38
/home/philipp/facerec/data/at/s39/7.pgm;38
/home/philipp/facerec/data/at/s39/6.pgm;38
/home/philipp/facerec/data/at/s39/9.pgm;38
/home/philipp/facerec/data/at/s39/5.pgm;38
/home/philipp/facerec/data/at/s39/3.pgm;38
/home/philipp/facerec/data/at/s39/4.pgm;38
/home/philipp/facerec/data/at/s39/10.pgm;38
/home/philipp/facerec/data/at/s39/8.pgm;38
/home/philipp/facerec/data/at/s39/1.pgm;38
/home/philipp/facerec/data/at/s35/2.pgm;34
/home/philipp/facerec/data/at/s35/7.pgm;34
/home/philipp/facerec/data/at/s35/6.pgm;34
/home/philipp/facerec/data/at/s35/9.pgm;34
/home/philipp/facerec/data/at/s35/5.pgm;34
/home/philipp/facerec/data/at/s35/3.pgm;34
/home/philipp/facerec/data/at/s35/4.pgm;34
/home/philipp/facerec/data/at/s35/10.pgm;34
/home/philipp/facerec/data/at/s35/8.pgm;34
/home/philipp/facerec/data/at/s35/1.pgm;34
/home/philipp/facerec/data/at/s23/2.pgm;22
/home/philipp/facerec/data/at/s23/7.pgm;22
/home/philipp/facerec/data/at/s23/6.pgm;22
/home/philipp/facerec/data/at/s23/9.pgm;22
/home/philipp/facerec/data/at/s23/5.pgm;22
/home/philipp/facerec/data/at/s23/3.pgm;22
/home/philipp/facerec/data/at/s23/4.pgm;22
/home/philipp/facerec/data/at/s23/10.pgm;22
/home/philipp/facerec/data/at/s23/8.pgm;22
/home/philipp/facerec/data/at/s23/1.pgm;22
/home/philipp/facerec/data/at/s4/2.pgm;3
/home/philipp/facerec/data/at/s4/7.pgm;3
/home/philipp/facerec/data/at/s4/6.pgm;3
/home/philipp/facerec/data/at/s4/9.pgm;3
/home/philipp/facerec/data/at/s4/5.pgm;3
/home/philipp/facerec/data/at/s4/3.pgm;3
/home/philipp/facerec/data/at/s4/4.pgm;3
/home/philipp/facerec/data/at/s4/10.pgm;3
/home/philipp/facerec/data/at/s4/8.pgm;3
/home/philipp/facerec/data/at/s4/1.pgm;3
/home/philipp/facerec/data/at/s9/2.pgm;8
/home/philipp/facerec/data/at/s9/7.pgm;8
/home/philipp/facerec/data/at/s9/6.pgm;8
/home/philipp/facerec/data/at/s9/9.pgm;8
/home/philipp/facerec/data/at/s9/5.pgm;8
/home/philipp/facerec/data/at/s9/3.pgm;8
/home/philipp/facerec/data/at/s9/4.pgm;8
/home/philipp/facerec/data/at/s9/10.pgm;8
/home/philipp/facerec/data/at/s9/8.pgm;8
/home/philipp/facerec/data/at/s9/1.pgm;8
/home/philipp/facerec/data/at/s37/2.pgm;36
/home/philipp/facerec/data/at/s37/7.pgm;36
/home/philipp/facerec/data/at/s37/6.pgm;36
/home/philipp/facerec/data/at/s37/9.pgm;36
/home/philipp/facerec/data/at/s37/5.pgm;36
/home/philipp/facerec/data/at/s37/3.pgm;36
/home/philipp/facerec/data/at/s37/4.pgm;36
/home/philipp/facerec/data/at/s37/10.pgm;36
/home/philipp/facerec/data/at/s37/8.pgm;36
/home/philipp/facerec/data/at/s37/1.pgm;36
/home/philipp/facerec/data/at/s24/2.pgm;23
/home/philipp/facerec/data/at/s24/7.pgm;23
/home/philipp/facerec/data/at/s24/6.pgm;23
/home/philipp/facerec/data/at/s24/9.pgm;23
/home/philipp/facerec/data/at/s24/5.pgm;23
/home/philipp/facerec/data/at/s24/3.pgm;23
/home/philipp/facerec/data/at/s24/4.pgm;23
/home/philipp/facerec/data/at/s24/10.pgm;23
/home/philipp/facerec/data/at/s24/8.pgm;23
/home/philipp/facerec/data/at/s24/1.pgm;23
/home/philipp/facerec/data/at/s19/2.pgm;18
/home/philipp/facerec/data/at/s19/7.pgm;18
/home/philipp/facerec/data/at/s19/6.pgm;18
/home/philipp/facerec/data/at/s19/9.pgm;18
/home/philipp/facerec/data/at/s19/5.pgm;18
/home/philipp/facerec/data/at/s19/3.pgm;18
/home/philipp/facerec/data/at/s19/4.pgm;18
/home/philipp/facerec/data/at/s19/10.pgm;18
/home/philipp/facerec/data/at/s19/8.pgm;18
/home/philipp/facerec/data/at/s19/1.pgm;18
/home/philipp/facerec/data/at/s8/2.pgm;7
/home/philipp/facerec/data/at/s8/7.pgm;7
/home/philipp/facerec/data/at/s8/6.pgm;7
/home/philipp/facerec/data/at/s8/9.pgm;7
/home/philipp/facerec/data/at/s8/5.pgm;7
/home/philipp/facerec/data/at/s8/3.pgm;7
/home/philipp/facerec/data/at/s8/4.pgm;7
/home/philipp/facerec/data/at/s8/10.pgm;7
/home/philipp/facerec/data/at/s8/8.pgm;7
/home/philipp/facerec/data/at/s8/1.pgm;7
/home/philipp/facerec/data/at/s21/2.pgm;20
/home/philipp/facerec/data/at/s21/7.pgm;20
/home/philipp/facerec/data/at/s21/6.pgm;20
/home/philipp/facerec/data/at/s21/9.pgm;20
/home/philipp/facerec/data/at/s21/5.pgm;20
/home/philipp/facerec/data/at/s21/3.pgm;20
/home/philipp/facerec/data/at/s21/4.pgm;20
/home/philipp/facerec/data/at/s21/10.pgm;20
/home/philipp/facerec/data/at/s21/8.pgm;20
/home/philipp/facerec/data/at/s21/1.pgm;20
/home/philipp/facerec/data/at/s1/2.pgm;0
/home/philipp/facerec/data/at/s1/7.pgm;0
/home/philipp/facerec/data/at/s1/6.pgm;0
/home/philipp/facerec/data/at/s1/9.pgm;0
/home/philipp/facerec/data/at/s1/5.pgm;0
/home/philipp/facerec/data/at/s1/3.pgm;0
/home/philipp/facerec/data/at/s1/4.pgm;0
/home/philipp/facerec/data/at/s1/10.pgm;0
/home/philipp/facerec/data/at/s1/8.pgm;0
/home/philipp/facerec/data/at/s1/1.pgm;0
/home/philipp/facerec/data/at/s7/2.pgm;6
/home/philipp/facerec/data/at/s7/7.pgm;6
/home/philipp/facerec/data/at/s7/6.pgm;6
/home/philipp/facerec/data/at/s7/9.pgm;6
/home/philipp/facerec/data/at/s7/5.pgm;6
/home/philipp/facerec/data/at/s7/3.pgm;6
/home/philipp/facerec/data/at/s7/4.pgm;6
/home/philipp/facerec/data/at/s7/10.pgm;6
/home/philipp/facerec/data/at/s7/8.pgm;6
/home/philipp/facerec/data/at/s7/1.pgm;6
/home/philipp/facerec/data/at/s16/2.pgm;15
/home/philipp/facerec/data/at/s16/7.pgm;15
/home/philipp/facerec/data/at/s16/6.pgm;15
/home/philipp/facerec/data/at/s16/9.pgm;15
/home/philipp/facerec/data/at/s16/5.pgm;15
/home/philipp/facerec/data/at/s16/3.pgm;15
/home/philipp/facerec/data/at/s16/4.pgm;15
/home/philipp/facerec/data/at/s16/10.pgm;15
/home/philipp/facerec/data/at/s16/8.pgm;15
/home/philipp/facerec/data/at/s16/1.pgm;15
/home/philipp/facerec/data/at/s36/2.pgm;35
/home/philipp/facerec/data/at/s36/7.pgm;35
/home/philipp/facerec/data/at/s36/6.pgm;35
/home/philipp/facerec/data/at/s36/9.pgm;35
/home/philipp/facerec/data/at/s36/5.pgm;35
/home/philipp/facerec/data/at/s36/3.pgm;35
/home/philipp/facerec/data/at/s36/4.pgm;35
/home/philipp/facerec/data/at/s36/10.pgm;35
/home/philipp/facerec/data/at/s36/8.pgm;35
/home/philipp/facerec/data/at/s36/1.pgm;35
/home/philipp/facerec/data/at/s25/2.pgm;24
/home/philipp/facerec/data/at/s25/7.pgm;24
/home/philipp/facerec/data/at/s25/6.pgm;24
/home/philipp/facerec/data/at/s25/9.pgm;24
/home/philipp/facerec/data/at/s25/5.pgm;24
/home/philipp/facerec/data/at/s25/3.pgm;24
/home/philipp/facerec/data/at/s25/4.pgm;24
/home/philipp/facerec/data/at/s25/10.pgm;24
/home/philipp/facerec/data/at/s25/8.pgm;24
/home/philipp/facerec/data/at/s25/1.pgm;24
/home/philipp/facerec/data/at/s14/2.pgm;13
/home/philipp/facerec/data/at/s14/7.pgm;13
/home/philipp/facerec/data/at/s14/6.pgm;13
/home/philipp/facerec/data/at/s14/9.pgm;13
/home/philipp/facerec/data/at/s14/5.pgm;13
/home/philipp/facerec/data/at/s14/3.pgm;13
/home/philipp/facerec/data/at/s14/4.pgm;13
/home/philipp/facerec/data/at/s14/10.pgm;13
/home/philipp/facerec/data/at/s14/8.pgm;13
/home/philipp/facerec/data/at/s14/1.pgm;13
/home/philipp/facerec/data/at/s34/2.pgm;33
/home/philipp/facerec/data/at/s34/7.pgm;33
/home/philipp/facerec/data/at/s34/6.pgm;33
/home/philipp/facerec/data/at/s34/9.pgm;33
/home/philipp/facerec/data/at/s34/5.pgm;33
/home/philipp/facerec/data/at/s34/3.pgm;33
/home/philipp/facerec/data/at/s34/4.pgm;33
/home/philipp/facerec/data/at/s34/10.pgm;33
/home/philipp/facerec/data/at/s34/8.pgm;33
/home/philipp/facerec/data/at/s34/1.pgm;33
/home/philipp/facerec/data/at/s11/2.pgm;10
/home/philipp/facerec/data/at/s11/7.pgm;10
/home/philipp/facerec/data/at/s11/6.pgm;10
/home/philipp/facerec/data/at/s11/9.pgm;10
/home/philipp/facerec/data/at/s11/5.pgm;10
/home/philipp/facerec/data/at/s11/3.pgm;10
/home/philipp/facerec/data/at/s11/4.pgm;10
/home/philipp/facerec/data/at/s11/10.pgm;10
/home/philipp/facerec/data/at/s11/8.pgm;10
/home/philipp/facerec/data/at/s11/1.pgm;10
/home/philipp/facerec/data/at/s26/2.pgm;25
/home/philipp/facerec/data/at/s26/7.pgm;25
/home/philipp/facerec/data/at/s26/6.pgm;25
/home/philipp/facerec/data/at/s26/9.pgm;25
/home/philipp/facerec/data/at/s26/5.pgm;25
/home/philipp/facerec/data/at/s26/3.pgm;25
/home/philipp/facerec/data/at/s26/4.pgm;25
/home/philipp/facerec/data/at/s26/10.pgm;25
/home/philipp/facerec/data/at/s26/8.pgm;25
/home/philipp/facerec/data/at/s26/1.pgm;25
/home/philipp/facerec/data/at/s18/2.pgm;17
/home/philipp/facerec/data/at/s18/7.pgm;17
/home/philipp/facerec/data/at/s18/6.pgm;17
/home/philipp/facerec/data/at/s18/9.pgm;17
/home/philipp/facerec/data/at/s18/5.pgm;17
/home/philipp/facerec/data/at/s18/3.pgm;17
/home/philipp/facerec/data/at/s18/4.pgm;17
/home/philipp/facerec/data/at/s18/10.pgm;17
/home/philipp/facerec/data/at/s18/8.pgm;17
/home/philipp/facerec/data/at/s18/1.pgm;17
/home/philipp/facerec/data/at/s29/2.pgm;28
/home/philipp/facerec/data/at/s29/7.pgm;28
/home/philipp/facerec/data/at/s29/6.pgm;28
/home/philipp/facerec/data/at/s29/9.pgm;28
/home/philipp/facerec/data/at/s29/5.pgm;28
/home/philipp/facerec/data/at/s29/3.pgm;28
/home/philipp/facerec/data/at/s29/4.pgm;28
/home/philipp/facerec/data/at/s29/10.pgm;28
/home/philipp/facerec/data/at/s29/8.pgm;28
/home/philipp/facerec/data/at/s29/1.pgm;28
/home/philipp/facerec/data/at/s33/2.pgm;32
/home/philipp/facerec/data/at/s33/7.pgm;32
/home/philipp/facerec/data/at/s33/6.pgm;32
/home/philipp/facerec/data/at/s33/9.pgm;32
/home/philipp/facerec/data/at/s33/5.pgm;32
/home/philipp/facerec/data/at/s33/3.pgm;32
/home/philipp/facerec/data/at/s33/4.pgm;32
/home/philipp/facerec/data/at/s33/10.pgm;32
/home/philipp/facerec/data/at/s33/8.pgm;32
/home/philipp/facerec/data/at/s33/1.pgm;32
/home/philipp/facerec/data/at/s12/2.pgm;11
/home/philipp/facerec/data/at/s12/7.pgm;11
/home/philipp/facerec/data/at/s12/6.pgm;11
/home/philipp/facerec/data/at/s12/9.pgm;11
/home/philipp/facerec/data/at/s12/5.pgm;11
/home/philipp/facerec/data/at/s12/3.pgm;11
/home/philipp/facerec/data/at/s12/4.pgm;11
/home/philipp/facerec/data/at/s12/10.pgm;11
/home/philipp/facerec/data/at/s12/8.pgm;11
/home/philipp/facerec/data/at/s12/1.pgm;11
/home/philipp/facerec/data/at/s6/2.pgm;5
/home/philipp/facerec/data/at/s6/7.pgm;5
/home/philipp/facerec/data/at/s6/6.pgm;5
/home/philipp/facerec/data/at/s6/9.pgm;5
/home/philipp/facerec/data/at/s6/5.pgm;5
/home/philipp/facerec/data/at/s6/3.pgm;5
/home/philipp/facerec/data/at/s6/4.pgm;5
/home/philipp/facerec/data/at/s6/10.pgm;5
/home/philipp/facerec/data/at/s6/8.pgm;5
/home/philipp/facerec/data/at/s6/1.pgm;5
/home/philipp/facerec/data/at/s22/2.pgm;21
/home/philipp/facerec/data/at/s22/7.pgm;21
/home/philipp/facerec/data/at/s22/6.pgm;21
/home/philipp/facerec/data/at/s22/9.pgm;21
/home/philipp/facerec/data/at/s22/5.pgm;21
/home/philipp/facerec/data/at/s22/3.pgm;21
/home/philipp/facerec/data/at/s22/4.pgm;21
/home/philipp/facerec/data/at/s22/10.pgm;21
/home/philipp/facerec/data/at/s22/8.pgm;21
/home/philipp/facerec/data/at/s22/1.pgm;21
/home/philipp/facerec/data/at/s15/2.pgm;14
/home/philipp/facerec/data/at/s15/7.pgm;14
/home/philipp/facerec/data/at/s15/6.pgm;14
/home/philipp/facerec/data/at/s15/9.pgm;14
/home/philipp/facerec/data/at/s15/5.pgm;14
/home/philipp/facerec/data/at/s15/3.pgm;14
/home/philipp/facerec/data/at/s15/4.pgm;14
/home/philipp/facerec/data/at/s15/10.pgm;14
/home/philipp/facerec/data/at/s15/8.pgm;14
/home/philipp/facerec/data/at/s15/1.pgm;14
/home/philipp/facerec/data/at/s2/2.pgm;1
/home/philipp/facerec/data/at/s2/7.pgm;1
/home/philipp/facerec/data/at/s2/6.pgm;1
/home/philipp/facerec/data/at/s2/9.pgm;1
/home/philipp/facerec/data/at/s2/5.pgm;1
/home/philipp/facerec/data/at/s2/3.pgm;1
/home/philipp/facerec/data/at/s2/4.pgm;1
/home/philipp/facerec/data/at/s2/10.pgm;1
/home/philipp/facerec/data/at/s2/8.pgm;1
/home/philipp/facerec/data/at/s2/1.pgm;1
/home/philipp/facerec/data/at/s31/2.pgm;30
/home/philipp/facerec/data/at/s31/7.pgm;30
/home/philipp/facerec/data/at/s31/6.pgm;30
/home/philipp/facerec/data/at/s31/9.pgm;30
/home/philipp/facerec/data/at/s31/5.pgm;30
/home/philipp/facerec/data/at/s31/3.pgm;30
/home/philipp/facerec/data/at/s31/4.pgm;30
/home/philipp/facerec/data/at/s31/10.pgm;30
/home/philipp/facerec/data/at/s31/8.pgm;30
/home/philipp/facerec/data/at/s31/1.pgm;30
/home/philipp/facerec/data/at/s28/2.pgm;27
/home/philipp/facerec/data/at/s28/7.pgm;27
/home/philipp/facerec/data/at/s28/6.pgm;27
/home/philipp/facerec/data/at/s28/9.pgm;27
/home/philipp/facerec/data/at/s28/5.pgm;27
/home/philipp/facerec/data/at/s28/3.pgm;27
/home/philipp/facerec/data/at/s28/4.pgm;27
/home/philipp/facerec/data/at/s28/10.pgm;27
/home/philipp/facerec/data/at/s28/8.pgm;27
/home/philipp/facerec/data/at/s28/1.pgm;27
/home/philipp/facerec/data/at/s40/2.pgm;39
/home/philipp/facerec/data/at/s40/7.pgm;39
/home/philipp/facerec/data/at/s40/6.pgm;39
/home/philipp/facerec/data/at/s40/9.pgm;39
/home/philipp/facerec/data/at/s40/5.pgm;39
/home/philipp/facerec/data/at/s40/3.pgm;39
/home/philipp/facerec/data/at/s40/4.pgm;39
/home/philipp/facerec/data/at/s40/10.pgm;39
/home/philipp/facerec/data/at/s40/8.pgm;39
/home/philipp/facerec/data/at/s40/1.pgm;39
/home/philipp/facerec/data/at/s3/2.pgm;2
/home/philipp/facerec/data/at/s3/7.pgm;2
/home/philipp/facerec/data/at/s3/6.pgm;2
/home/philipp/facerec/data/at/s3/9.pgm;2
/home/philipp/facerec/data/at/s3/5.pgm;2
/home/philipp/facerec/data/at/s3/3.pgm;2
/home/philipp/facerec/data/at/s3/4.pgm;2
/home/philipp/facerec/data/at/s3/10.pgm;2
/home/philipp/facerec/data/at/s3/8.pgm;2
/home/philipp/facerec/data/at/s3/1.pgm;2
/home/philipp/facerec/data/at/s38/2.pgm;37
/home/philipp/facerec/data/at/s38/7.pgm;37
/home/philipp/facerec/data/at/s38/6.pgm;37
/home/philipp/facerec/data/at/s38/9.pgm;37
/home/philipp/facerec/data/at/s38/5.pgm;37
/home/philipp/facerec/data/at/s38/3.pgm;37
/home/philipp/facerec/data/at/s38/4.pgm;37
/home/philipp/facerec/data/at/s38/10.pgm;37
/home/philipp/facerec/data/at/s38/8.pgm;37
/home/philipp/facerec/data/at/s38/1.pgm;37