简体   繁体   English

将两个Haar Cascade xml文件与EmguCV检测和识别一起使用

[英]Use two Haar Cascade xml files with EmguCV detection and recognition

With EmguCV I'm using single haarcascade_face.xml: 通过EmguCV,我使用单个haarcascade_face.xml:

face = new HaarCascade(xmlPath); 

Attached from directory: 从目录附加:

string path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "folder\\haarcascade_face.xml");

This way detection or recognition works for particular xml file face content: 这种检测或识别方式适用于特定的xml文件面部内容:

f = new HaarCascade(path); 

Same way if I change xml to another one for example haarcascade_hand.xml, detection and recognition applies to different object.: 如果我将xml更改为另一种(例如haarcascade_hand.xml),则采用相同的方法,检测和识别适用于不同的对象。

I' not asking, how to detect and recognize different objects with single-process, as I'm doing this with faces: 我不是在问如何通过单进程检测和识别不同的对象,因为我正在使用面孔进行操作:

MCvAvgComp[][] fd = gray.DetectHaarCascade(f, 1.2, 10, Emgu.CV.CvEnum.HAAR_DETECTION_TYPE.DO_CANNY_PRUNING, new Size(20, 20)); 

My question, if there a way, somehow use both haarcascade_face.xml and haarcascade_hand.xml for single process detection and not recognition in the right sense, but differentiation of which particular .xml used by detected object. 我的问题是,是否有办法以某种方式将haarcascade_face.xml和haarcascade_hand.xml都用于单个进程检测,而不是在正确的意义上进行识别,而是区分被检测对象使用哪个特定的.xml。

As I know I cannot combine two haar cascades in one detector, but I can run two detectors to detect two different things. 据我所知,我不能将两个haar级联合并到一个检测器中,但是我可以运行两个检测器来检测两个不同的事物。 I guess iteration between paths to each file during processing should be completely incorrect approach 我猜在处理过程中每个文件的路径之间的迭代应该是完全不正确的方法

Any advice guide or example would very helpful 任何建议指南或示例将非常有帮助

How about doing face and hand detection in an image sequentially. 依次执行图像中的脸部和手部检测怎么样。 It requires you to register 2 Haar detectors and apply them in every image. 它要求您注册2个Haar检测器并将其应用于每个图像。

//register 2 Haar detectors
string face_path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "folder\\haarcascade_face.xml");
string hand_path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "folder\\haarcascade_hand.xml");

HaarCascade face = new HaarCascade(face_path); 
HaarCascade hand= new HaarCascade(hand_path); 

//for every image
MCvAvgComp[][] fd = gray.DetectHaarCascade(face, 1.2, 10, Emgu.CV.CvEnum.HAAR_DETECTION_TYPE.DO_CANNY_PRUNING, new Size(20, 20));
MCvAvgComp[][] hd = gray.DetectHaarCascade(hand, 1.2, 10, Emgu.CV.CvEnum.HAAR_DETECTION_TYPE.DO_CANNY_PRUNING, new Size(20, 20));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM