如何使用OpenCV面部识别? [英] How to do Face Recognition using OpenCV?

查看:205
本文介绍了如何使用OpenCV面部识别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图做一些面部识别(不是检测)东西使用OpenCV。我在这篇文章中找到了一些代码:

I am trying to do some Face Recognition (not detection) stuff using OpenCV. I found this article with some code:

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

但是,此代码使用较旧的C样式OpenCV API。有人有一个C ++ API版本的这个使用更新的版本,如OpenCV 2.3.1?

However, this code is written using the older C-style OpenCV API. Does someone have a C++ API version of this using a more recent version like OpenCV 2.3.1?

推荐答案

面部识别项目为我的工程师学位,使用c ++ api。我认为关于c ++中面部识别的一切都是相当简单的,甚至比C(更少的指针)更简单。要使用PCA,您需要一个名为PCA的类,此处 a>。只要使用正确的方法和阅读文档与理解。要构建具有输入数据的矩阵,我创建了一个适当大小的矩阵,然后将图片作为行(使用方法重塑)到它(在cv :: Mat中有一个方法,使您可以轻松地获取一行矩阵)。您只需要确保基本数据和测试数据具有相同的参数(渠道,大小等)。

I'm doing a face recognition project for my engineer's degree, using c++ api. I think that everything regarding face recognition in c++ is fairly straightforward, even simpler than in C (less pointers). To use PCA you have a class named PCA described here. Just use the proper methods and read documentation with understanding. To build the matrix with input data I've created a matrix of proper size, then pasted pictures as rows (use method reshape) into it (there is a method in cv::Mat that lets you to get easily a row of a matrix). You just need to keep sure that base data and tested data have the same parameters (channels, size,etc.)

编辑: p>

     using namespace cv; //somewhere near top

将数据插入数据矩阵:

    62       Mat reshaped=img.reshape(1,1);
    63       Mat dataRow=_data.row(y++);
    64       resize(reshaped,dataRow,dataRow.size(),0,0,CV_INTER_LINEAR);

计算pca:

    251 _pca(_data,Mat(),CV_PCA_DATA_AS_ROW); //compute pca 
    252 _pca.project(_data,_vectors); // project original data to new coordinates

由于opencv的文档不是最好的,不想花一些时间阅读它。大多数c api函数在c ++ api中有等价的,你只需要做一些写入搜索窗口并按回车搜索。而且,在c ++中还有一些教程来抓住c ++ api。

As opencv's documentation isn't the best out there, it doesn't hurt to spend some time reading it. Most of the c api functions have their equivalents in c++ api, You only need to do some "write into search window and hit enter" searching. And, there are also tutorials in c++ to get a grip of the c++ api.

这篇关于如何使用OpenCV面部识别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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