人脸识别逻辑 [英] Face Recognition Logic

查看:146
本文介绍了人脸识别逻辑的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想开发一个用户输入图像(一个人)的应用程序,系统应该能够从一个人的图像中识别出面部。如果图像中有多个人,系统也可以工作。

I want to develop an application in which user input an image (of a person), a system should be able to identify face from an image of a person. System also works if there are more than one persons in an image.

我需要一个逻辑,我不知道如何以这种方式处理图像像素数据它识别人脸。

I need a logic, I dont have any idea how can work on image pixel data in such a manner that it identifies person faces.

推荐答案

如果你想建立一个系统,Eigenface可能是一个很好的算法教育目的,因为它相对简单,并作为该领域许多其他算法的起点。基本上你所做的就是拍摄一堆人脸图像(训练数据),如果它们是RGB,则将它们切换为灰度,调整它们以使每个图像具有相同的尺寸,通过堆叠图像的列使图像成为矢量(它们现在是2D矩阵),计算所有图像中每个像素值的平均值,并从矩阵中的每个条目中减去该值,使得分量矢量不会是仿射的。完成后,计算结果的协方差矩阵,求解其特征值和特征向量,找到主成分。这些组件将作为矢量空间的基础,并一起描述人脸图像彼此不同的最重要方式。

Eigenface might be a good algorithm to start with if you're looking to build a system for educational purposes, since it's relatively simple and serves as the starting point for a lot of other algorithms in the field. Basically what you do is take a bunch of face images (training data), switch them to grayscale if they're RGB, resize them so that every image has the same dimensions, make the images into vectors by stacking the columns of the images (which are now 2D matrices) on top of each other, compute the mean of every pixel value in all the images, and subtract that value from every entry in the matrix so that the component vectors won't be affine. Once that's done, you compute the covariance matrix of the result, solve for its eigenvalues and eigenvectors, and find the principal components. These components will serve as the basis for a vector space, and together describe the most significant ways in which face images differ from one another.

一旦你完成了这一点,您可以通过将新面部图像转换为面部矢量,投影到新的矢量空间,并计算它与其他投影面部矢量之间的线性距离来计算新面部图像的相似性得分。

Once you've done that, you can compute a similarity score for a new face image by converting it into a face vector, projecting into the new vector space, and computing the linear distance between it and other projected face vectors.

如果您决定走这条路线,请注意选择在适当的光照条件和姿势角度下拍摄的脸部图像。这两个因素对于系统在呈现新面孔时的表现有很大的作用。如果培训库没有考虑探测图像的属性,那么您将获得无意义的结果。 (我曾经在从互联网上下载的随机图片上训练了一个特征脸系统,它给了我比尔克林顿作为伊丽莎白二世画面的最强匹配,尽管画廊里还有另一张女王的照片。他们都有白色头发朝向同一个方向,并在类似的照明条件下拍照,这对于电脑来说已经足够了。)

If you decide to go this route, be careful to choose face images that were taken under an appropriate range of lighting conditions and pose angles. Those two factors play a huge role in how well your system will perform when presented with new faces. If the training gallery doesn't account for the properties of a probe image, you're going to get nonsense results. (I once trained an eigenface system on random pictures pulled down from the internet, and it gave me Bill Clinton as the strongest match for a picture of Elizabeth II, even though there was another picture of the Queen in the gallery. They both had white hair, were facing in the same direction, and were photographed under similar lighting conditions, and that was good enough for the computer.)

如果你想从多个面部拉脸在同一图像中的人,您将需要一个完整的系统来检测面部,将它们拉入单独的文件中,并对它们进行预处理,以便它们与从其他图片中绘制的其他面部相当。这些都是他们自己的巨大主题。我已经看到人们使用肤色和基于纹理的方法完成了一些很好的工作来剪切非面部的图像组件,但这些也很容易受到训练数据变化的影响。颜色铸造特别难以控制,这就是为什么图像的灰度转换和/或小波表示很流行的原因。

If you want to pull faces from multiple people in the same image, you're going to need a full system to detect faces, pull them into separate files, and preprocess them so that they're comparable with other faces drawn from other pictures. Those are all huge subjects in their own right. I've seen some good work done by people using skin color and texture-based methods to cut out image components that aren't faces, but these are also highly subject to variations in training data. Color casting is particularly hard to control, which is why grayscale conversion and/or wavelet representations of images are popular.

机器学习是FR系统中许多重要过程的基石,因此我无法强调良好训练数据的重要性。那里有很多学习算法,但在我看来最重要的是朴素的贝叶斯分类器;随着训练数据集的大小增加,其他方法会聚合贝叶斯,因此如果您计划使用较小的数据集,则只需要花哨。请记住,您的训练数据的质量将决定整个系统的成败,只要它是可靠的,您就可以从为支持企业而编写的算法森林中挑选您喜欢的任何树。

Machine learning is the keystone of many important processes in an FR system, so I can't stress the importance of good training data enough. There are a bunch of learning algorithms out there, but the most important one in my view is the naive Bayes classifier; the other methods converge on Bayes as the size of the training dataset increases, so you only need to get fancy if you plan to work with smaller datasets. Just remember that the quality of your training data will make or break the system as a whole, and as long as it's solid, you can pick whatever trees you like from the forest of algorithms that have been written to support the enterprise.

编辑:对您的训练数据进行良好的健全性检查是为您的探测和图库图像计算平均面部。 (这正是它听起来的样子;在控制图像大小之后,为每个图像取RGB信道的总和,并将每个像素除以图像的数量。)预处理越好,平均面部看起来就越人性化。如果两个平均面孔看起来像不同的人 - 不同的性别,种族,头发颜色,等等 - 这是一个警告信号,表明您的训练数据可能不适合您的想法。

A good sanity check for your training data is to compute average faces for your probe and gallery images. (This is exactly what it sounds like; after controlling for image size, take the sum of the RGB channels for every image and divide each pixel by the number of images.) The better your preprocessing, the more human the average faces will look. If the two average faces look like different people -- different gender, ethnicity, hair color, whatever -- that's a warning sign that your training data may not be appropriate for what you have in mind.

这篇关于人脸识别逻辑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆