简体   繁体   中英

Use two Haar Cascade xml files with EmguCV detection and recognition

With EmguCV I'm using single 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:

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.:

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.

As I know I cannot combine two haar cascades in one detector, but I can run two detectors to detect two different things. 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.

//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));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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