C++人脸检测/识别实现
我本以为谷歌可以回答这个问题,但我运气不佳。
有谁知道除了 Viola-Jones(类似 Haar 特征的增强级联)方法之外的任何人脸检测算法的开源 C++ 实现吗?
另外,是否存在 Fisherfaces 的开源 C++ 实现?
谢谢。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这篇文章引起了一些关注,所以我想更新它。在撰写本文时,我已向 OpenCV 贡献了我编写的人脸识别库,其中包括 Eigenfaces、Fisherfaces 和局部二进制模式直方图。因此,OpenCV 2.4.2 现在附带了入门所需的一切,请参阅非常详细的文档:
现在是原始答案。
我是凯文帖子中链接的文章的作者。请注意,您需要找到 Fisherfaces 的非对称矩阵 S_{W}^{-1} S_{B} 的特征值,我在博客中没有明确提及。 OpenCV 当前版本仅具有对称矩阵求解器;由于特征值和奇异值对于非对称矩阵并不等效,因此您也不能使用 SVD。对于我的项目,我已将 JAMA 求解器改编为 C++,用于求解非对称矩阵的特征值问题,因此无需使用外部库。 CMakeLists.txt 已配置,因此也可以使用 Eigen,因此您可以选择。
现在我终于找到了一些时间来使用 OpenCV2 C++ API 实现 Fisherfaces 方法 并推送了将代码写入我的 github 帐户:
main.cpp 向您展示如何使用 Fisherfaces 类 以及如何使用线性判别分析,示例如下:http://www.bytefish.de/wiki/pca_lda_with_gnu_octave。它是一个 CMake 项目,因此编译就像打字一样简单:
我不知道这是否是在答案中发布代码的首选 Stackoverflow 方式,但我认为发布有点太长了。
请注意两件事。 (1) 我从 CSV 文件中读取图像(就像这个< /a>),您不必关心标签的顺序。 (2)我按列存储特征向量,而OpenCV中的PCA按行存储它们。这样做只是个人喜好问题,但我从未在任何其他解算器中见过这种情况,因此我决定按列存储它们。
This post gets some attention, so I'd like to update it. I've contributed the face recognition library I wrote to OpenCV, which includes Eigenfaces, Fisherfaces and Local Binary Patterns Histograms at time of writing this. So OpenCV 2.4.2 now comes with everything to get started, see the very detailed documentation:
Now the original answer.
I am the author of the article linked in Kevin's post. Please note that you need to find the eigenvalues of the non-symmetric matrix S_{W}^{-1} S_{B} for the Fisherfaces, I didn't explicitly mention it in my blog. OpenCV only has a solver for symmetric matrices in its current version; since eigenvalues and singular values aren't equivalent for non-symmetric matrices you can't use a SVD either. For my project I have adapted the JAMA solver to C++ for solving the eigenvalue problem for non-symmetric matrices, so there's no need to use an external library for it. The CMakeLists.txt is configured, so Eigen can be used as well, so you have the choice.
Now I've finally found some minutes to implement the Fisherfaces method with the OpenCV2 C++ API and pushed the code into my github account at:
The main.cpp shows you how to use the Fisherfaces class and how to use the Linear Discriminant Analysis with the same example as on: http://www.bytefish.de/wiki/pca_lda_with_gnu_octave. It comes as a CMake project, so compiling is as easy as typing:
I don't know if it's the preferred Stackoverflow way to post code in the answer, but I think it's a bit too long to post.
Please note two things. (1) I read the images from a CSV file (just like this one), you don't have to care about the order of the labels. (2) I store the eigenvectors by column, while the PCA in OpenCV stores them by row. It's just a matter of personal taste to do so, but I've never seen that for any other solver and so I decided to store them by column.