如何使用emgu cv从vidio进行眼和口检测 [英] how to do eye and mouth detection from vidio using emgu cv

查看:97
本文介绍了如何使用emgu cv从vidio进行眼和口检测的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用emgu cv从正在运行的视频中提取了人脸.
现在,我要从检测到的那些面孔中提取眼睛和嘴巴,然后从检测到的眼睛和嘴巴的特征点中提取特征.

有人可以帮助我进行此功能提取阶段吗?

解决方案

这是一个开源项目.您最好将问题发布到该社区.

感谢您的解决方案
真的很有帮助.

我想再问一个问题,在检测haar级联函数中,第二个和第三个参数是:double scaleFactor,int minNeighbors.
我实际上并没有得到它们表示什么以及它们可能的值是什么.如何进行试验. :)




检测图像分析术语和EMGU中的面部特征的方法有很多.一个很好的起点是安装的Emgu.CV.Example文件夹中的FaceDetection示例.这利用了一种称为Haar分类的特征检测方法. EMGU随附的不同Haar分类器位于... \ opencv \ data \ haarcascades文件夹中.在您选择的安装目录下.

所有分类器都是XML Documents(.xml),其中包含复杂的级联,这些级联检查图像以查找与经过训练的特征(如脸,眼,鼻和嘴)相对应的模式.您将感兴趣的两个是:

haarcascade_eye.xml
haarcascade_mcs_mouth.xml


我们在Haar分类器中进行了阅读:

 // 读取HaarCascade对象
HaarCascade face =  HaarCascade(" );
HaarCascade口=  HaarCascade(" );
HaarCascade eye =  HaarCascade(" ); 



我们包括脸部,因为这限制了我们在寻找眼睛和嘴巴.确保在将Haar分类器添加到项目时,将复制到输出目录"属性更改为如果较新则复制,否则将无法找到它.

我们可以通过添加
来更改人脸检测代码以向我们展示嘴

 MCvAvgComp [] [] mouthsDetected = grey.DetectHaarCascade(
嘴,
 1 . 1  10 ,
Emgu.CV.CvEnum.HAAR_DETECTION_TYPE.DO_CANNY_PRUNING,
大小( 20  20 )) ;
gray.ROI = Rectangle.Empty;

 foreach (MCvAvgComp e 中中被检测到[ 0  ])
{
    矩形uthRect = e.rect;
    uthRect.Offset(f.rect.X,f.rect.Y);
    image.Draw(mouthRect, Bgr(Color.Green), 2 );
} 



当您在lena.jpg上运行此命令时,您将无法正确检测到嘴巴,现在必须更改每个值必须具有的DetectHaarCascade属性才能正确检测到嘴巴,但是我建议您现在使用自己获取的图像来完善这些设置.

 DetectHaarCascade(HaarCascade haarObj, double  scaleFactor, int  minNeighbors,HAAR_DETECTION_TYPE标志,大小minSize); 



请注意,我一次只能更改一个属性,因此您可以观察到这些更改.

我建议不要考虑创建自己的Haar分类器,因为如果您不了解EMGU C#和C ++,并且计算时间较长,这会很复杂.

您可能希望使用的一种简单的替代方法是模板匹配,该模板匹配主要在您仅以恒定角度处理人像或面部时有用.例如,这还可以用于进一步分析Haar分类器寻找眼睛虹膜的结果.

我希望这会开始帮助您.

干杯
克里斯


I have extracted faces from the running video using emgu cv.
Now I want to extract eyes and mouth from those detected faces and then do feature extraction from detected feature points of eyes and mouth.

can anyone help me for this feature extraction phase? How to detect eyes in emgu cv in C#?

解决方案

This is an open source project. You will do better to post your question in that community.


Thanks for your solution
It was really helpfull.

I would like to ask one more question, in the detect haar cascade function the second and third argument that is:double scaleFactor, int minNeighbors.
Iam not actually getting what does they signify and what are their possible values.How to experiment with it. :)


Hi,

There are many many ways of detecting facial features in image analysis terms and EMGU. A good starting point for you would be the FaceDetection example in the Emgu.CV.Example folder of the installation. This utilise a method of feature detection called Haar classification. There are different Haar classifiers supplied with EMGU located in ...\opencv\data\haarcascades folder. under your chosen installation directory.

All classifiers are XML Documents(.xml) containing complex cascades that examine the image looking for patterns that correspond to trained features such as face eyes nose and mouth. The two you will be interested in are:

haarcascade_eye.xml
haarcascade_mcs_mouth.xml


We read in the Haar classifiers:

//Read the HaarCascade objects
HaarCascade face = new HaarCascade("haarcascade_frontalface_alt_tree.xml");
HaarCascade mouth = new HaarCascade("haarcascade_mcs_mouth.xml");
HaarCascade eye = new HaarCascade("haarcascade_eye.xml");



We include the face as this limits the are we are looking for eyes and mouth. Make sure you when you add the Haar classifier to your project you change the "Copy to Output Directory" property to Copy if Newer else it won''t be able to be located.

We can the alter the Face Detection code to show us mouths by adding

MCvAvgComp[][] mouthsDetected = gray.DetectHaarCascade(
mouth,
1.1,
10,
Emgu.CV.CvEnum.HAAR_DETECTION_TYPE.DO_CANNY_PRUNING,
new Size(20, 20));
gray.ROI = Rectangle.Empty;

foreach (MCvAvgComp e in mouthsDetected[0])
{
    Rectangle mouthRect = e.rect;
    mouthRect.Offset(f.rect.X, f.rect.Y);
    image.Draw(mouthRect, new Bgr(Color.Green), 2);
}



When you run this on lena.jpg you won''t detect the mouth correctly you must now change the DetectHaarCascade attributes you will have toplay with each value to detect the mouth properly however I suggest that you now work on your own acquired images to perfect these settings.

DetectHaarCascade(HaarCascade haarObj, double scaleFactor, int minNeighbors, HAAR_DETECTION_TYPE flag, Size minSize);



On a small note I would only change one attributes at a time so you observe the changes.

I would suggest not looking into creating your own Haar classifiers as this is fairly complex if you don''t understand EMGU C# and C++ and takes a long time computationally to compute.

An easy alternative method you may wish to employ is template matching which is useful mainly if your dealing only with portraits or faces from a constant angle. This could also by employed to further analyse the results from the Haar Classifiers looking for Iris''s of the eye for example.

I hope this starts to get you on your way.

Cheers
Chris


这篇关于如何使用emgu cv从vidio进行眼和口检测的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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