ios iPhone 上的人脸识别

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10272129/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 17:59:28  来源:igfitidea点击:

Face Recognition on the iPhone

iosopencvcomputer-vision

提问by Rory Lester

How can I do facial recognition on the iPhone. Could someone provide me with references/articles to point me in the right direction please? I have done research and realised that I need to do face detection first to extract the image and then do facial recognition by comparing it with other images within a database.

如何在 iPhone 上进行面部识别。有人可以向我提供参考资料/文章来指出我正确的方向吗?我做了研究并意识到我需要先进行面部检测以提取图像,然后通过将其与数据库中的其他图像进行比较来进行面部识别。

I have realised that I have do the face detection by using OpenCV or by utilising iOS 5.0 and upwards to detect the face. I am unsure on the facial recognition (I plan on storing images on a remote database and then doing the comparison against the remote database).

我意识到我已经通过使用 OpenCV 或使用 iOS 5.0 及更高版本来检测人脸来进行人脸检测。我不确定面部识别(我计划将图像存储在远程数据库中,然后与远程数据库进行比较)。

采纳答案by TomP89

Face detection

人脸检测

I would use the Haarcascades available in open CV to perform quick and accurate face detection.

我会使用开放简历中提供的 Haarcascades 来执行快速准确的人脸检测。

http://opencv.willowgarage.com/wiki/FaceDetection

http://opencv.willowgarage.com/wiki/FaceDetection

Face recognition

人脸识别

I would use a method such as Principal Component Analysis (PCA) a.k.a eigenfaces.

我会使用诸如主成分分析 (PCA) 又名特征脸之类的方法。

http://www.cognotics.com/opencv/servo_2007_series/part_5/index.html

http://www.cognotics.com/opencv/servo_2007_series/part_5/index.html

That link shows a tutorial on how to get that working with OpenCV - I think this is written for C but i'm sure you can get the basic jist of it.

该链接显示了有关如何使用 OpenCV 进行操作的教程 - 我认为这是为 C 编写的,但我相信您可以获得它的基本原理。

You could also look at implementing it yourself if you feel brave (it's not too bad)...

如果您感到勇敢,您也可以考虑自己实施它(还不错)...

http://www.face-rec.org/algorithms/PCA/jcn.pdf

http://www.face-rec.org/algorithms/PCA/jcn.pdf

http://blog.zabarauskas.com/eigenfaces-tutorial/

http://blog.zabarauskas.com/eigenfaces-tutorial/

Database

数据库

I actually did something similar to you albeit on a PC not an iPhone but its still the same concept. I stored all my images in the database as Blob data types then loaded them into my program when necessary.

我实际上做了一些与你类似的事情,虽然是在 PC 上而不是 iPhone 上,但它仍然是相同的概念。我将所有图像作为 Blob 数据类型存储在数据库中,然后在必要时将它们加载到我的程序中。

Edit

编辑

The database is a particularly tricky part of the system as this is where the biggest bottleneck is. In my application, I would go through the following steps...

数据库是系统中特别棘手的部分,因为这是最大的瓶颈所在。在我的应用程序中,我将执行以下步骤...

  1. Open application and grab training images from database
  2. Generate training set based on these images
  3. Once 1 and 2 have been completed the system is very quick as it just performs recognition against the training set.
  1. 打开应用程序并从数据库中抓取训练图像
  2. 根据这些图像生成训练集
  3. 一旦 1 和 2 完成,系统就会非常快,因为它只是针对训练集执行识别。

Fortunately for me, my database server was located on a LAN therefore speed wasn't a problem, however I can see why you have an issue due to the fact that on a mobile device you have a limited data connection (speed/bandwidth). You can compress the images however this may lead to a worse recognition rate, due to image quality reduction and also you will have to decode on the device. There is also the issue of how to expose the remote database to the application, however I do believe this is possible using PHP and JSON (and other technologies, see below).

对我来说幸运的是,我的数据库服务器位于 LAN 上,因此速度不是问题,但是我可以理解为什么您会遇到问题,因为在移动设备上您的数据连接(速度/带宽)有限。您可以压缩图像,但是这可能会导致识别率下降,因为图像质量会降低,而且您还必须在设备上进行解码。还有一个问题是如何将远程数据库公开给应用程序,但是我相信使用 PHP 和 JSON(以及其他技术,见下文)是可能的。

Retrieving data from a remote database

从远程数据库检索数据

Maybe you could do an initial synchronize with the database so that the images are cached on the phone? One way or another I think you are probably going to have to have the images on the phone at some point regardless.

也许您可以与数据库进行初始同步,以便将图像缓存在手机上?无论如何,我认为您可能会以某种方式在某个时候将图像保存在手机上。

Figuring out the best way to store the recognition data/images in the database was one of the biggest challenges I faced so I would be interested to hear if you find a good method.

找出将识别数据/图像存储在数据库中的最佳方法是我面临的最大挑战之一,因此我很想知道您是否找到了一个好的方法。

回答by Sedate Alien

As you pointed out, the first step (detection of the face) is easy with iOS 5 and CoreImage.framework. Quick example:

正如您所指出的,使用 iOS 5 和CoreImage.framework. 快速示例:

CIImage *image = [CIImage imageWithCGImage:image_ref];
NSDictionary *options = [NSDictionary dictionaryWithObject:CIDetectorAccuracyHigh forKey:CIDetectorAccuracy];
CIDetector *detector = [CIDetector detectorOfType:CIDetectorTypeFace context:nil options:options];
NSArray *features = [detector featuresInImage:image];

for (CIFaceFeature *feature in features)
{
  CGRect face_bounds = [feature bounds];
  CGPoint mouth_position = [feature mouthPosition];
  // do something with these values
}

With regards to the second part of your question (i.e. facial recognition), I shall leave that to someone more qualified than myself to answer. :)

关于你问题的第二部分(即面部识别),我会留给比我更有资格的人来回答。:)

回答by bytefish

You probably want to look at the midianproject by Pedro Centieiro, which performs Face Recognition on iOS 5 with OpenCV. It's on github at:

您可能想查看Pedro Centieiro的midian项目,该项目使用 OpenCV 在 iOS 5 上执行人脸识别。它在 github 上:

It uses parts of my libfacerec, so it supports Eigenfaces, Fisherfaces and Local Binary Patterns Histograms for face recognition.

它使用了我的libfacerec 的一部分,因此它支持用于人脸识别的 Eigenfaces、Fisherfaces 和 Local Binary Patterns Histograms。

回答by Jo?o Daniel

Face recognition can be implemented as a machine learning algorithm. This bookhas a chapter that describe this task and how to implement it. Worth the reading!

人脸识别可以实现为机器学习算法。本书有一章描述了这个任务以及如何实现它。值得一读!

It uses Single value decomposition(SVD), more specifically the Tensor SVD method.

它使用单值分解(SVD),更具体地说是Tensor SVD 方法

回答by Shubham Mishra

We have following face recognition api :-

我们有以下人脸识别api:-

1. OpenCV

2. Kairos

3. CraftarAR

4. AAFaceDetection

5. MoodMe

And in my opinion CraftARis good if you want to use in offline application and in case you want to use online then Kairosis best. While OpenCVis also a famous and reliable option.

在我看来CraftAR,如果您想在离线应用程序中使用是好的,如果您想在线使用则Kairos是最好的。虽然OpenCV也是一个著名且可靠的选择。

And best advantage of OPENCV is that it is open source.

OPENCV 的最大优势在于它是开源的。

Please search these on google to get more details and also look at github examples to see how these api work.

请在 google 上搜索这些以获取更多详细信息,并查看 github 示例以了解这些 api 是如何工作的。