void FrameGrabber(object sender, EventArgs e) { NamePersons.Add(""); currentFrame = grabber.QueryFrame().Resize(320, 240, Emgu.CV.CvEnum.INTER.CV_INTER_CUBIC); gray = currentFrame.Convert <Gray, Byte>(); MCvAvgComp[][] facesDetected = gray.DetectHaarCascade( face, 1.2, 10, Emgu.CV.CvEnum.HAAR_DETECTION_TYPE.DO_CANNY_PRUNING, new Size(20, 20)); foreach (MCvAvgComp f in facesDetected[0]) { t = t + 1; result = currentFrame.Copy(f.rect).Convert <Gray, byte>().Resize(100, 100, Emgu.CV.CvEnum.INTER.CV_INTER_CUBIC); currentFrame.Draw(f.rect, new Bgr(Color.Red), 2); if (trainingImages.ToArray().Length != 0) { MCvTermCriteria termCrit = new MCvTermCriteria(ContTrain, 0.001); EigenObjectRecognizer recognizer = new EigenObjectRecognizer( trainingImages.ToArray(), labels.ToArray(), 5000, ref termCrit); name = recognizer.Recognize(result); currentFrame.Draw(name, ref font, new Point(f.rect.X - 2, f.rect.Y - 2), new Bgr(Color.LightGreen)); } NamePersons[t - 1] = name; NamePersons.Add(""); /* * gray.ROI = f.rect; * MCvAvgComp[][] eyesDetected = gray.DetectHaarCascade( * eye, * 1.1, * 10, * Emgu.CV.CvEnum.HAAR_DETECTION_TYPE.DO_CANNY_PRUNING, * new Size(20, 20)); * gray.ROI = Rectangle.Empty; * * foreach (MCvAvgComp ey in eyesDetected[0]) * { * Rectangle eyeRect = ey.rect; * eyeRect.Offset(f.rect.X, f.rect.Y); * currentFrame.Draw(eyeRect, new Bgr(Color.Blue), 2); * } */ } t = 0; for (int nnn = 0; nnn < facesDetected[0].Length; nnn++) { names = names + NamePersons[nnn] + ", "; } imageBoxFrameGrabber.Image = currentFrame; NamePersons.Clear(); }