简体   繁体   中英

How to perform to Template Matching in Emgu CV

Sir,

I am new to Emgu CV.I am making a face recognition software.I was able to detect the faces using HaarCascade xml Classifiers.But im stuck up at the next step regarding how to recognise the face.Anyone please tell me how to use MatchTemplate function...

I found this code on the internet

Image<Gray, Byte> templateImage = new Image<Gray, Byte>(bmpSnip);
Image<Gray, float> resultImage = sourceImage.MatchTemplate(templateImage,Emgu.CV.CvEnum.TM_TYPE.CV_TM_CCOEFF_NORMED);

float[,,] matches = resultImage.Data;
for (int x = 0; x < matches.GetLength(1); x++)
{
for (int y = 0; y < matches.GetLength(0); y++)
{
double matchScore = matches[y, x, 0];
if (matchScore > 0.75)
{
Rectangle rect = new Rectangle(new Point(x,y), new Size(1, 1));
imgSource.Draw(rect, new Bgr(Color.Blue), 1);
}
}

I didnt understand this code...First of all this code is not working....Secondly if anyone know how to do it correctly... Please post the code.....

The MatchTemplate method is designed preliminary for matching objects with defining features. A face, while to you and I may have defining features to the FFT method employed in MatchTemplate the defining features are simply not large enough for face recognition. Surya is correct as a comparison would be interesting and I would suggest the best approach would to be match areas of the template face image to the recognised face from the camera. So for example you would take the the position of the eyes and apply MatchTemplate to the same location and take an average of matching these features to estimate overall accuracy.

The significant problem you will inherently have however is execution time. With a large database of faces MatchTemplate does not reduce the dataset significantly to allow real time processing.

The Eigen Recogniser is a far safer and efficient method. It will be more reliable than creating your own algorithm and significantly faster. Please see my article here on how to implement it:

http://www.codeproject.com/Articles/261550/EMGU-Multiple-Face-Recognition-using-PCA-and-Paral

Hope this helps,

Cheers,

Chris

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