private static void ProcessFrame(object sender, EventArgs e) { detectedFaces.Clear(); //Get Current Frame currentFrame = Capture.QueryFrame(); Image <Gray, byte> grayFrame = currentFrame.Convert <Gray, byte>(); //Detect Faces in current frame FaceDetection.Detect(grayFrame, detectedFaces); Description = ""; String name = ""; MCvFont font = new MCvFont(FONT.CV_FONT_HERSHEY_TRIPLEX, 0.5d, 0.5d); foreach (var box in detectedFaces) { //Recognize each face name = FaceRecognition.Recognize(grayFrame, box, 2000); //Draw box and name Around Face currentFrame.Draw(box, new Bgr(Color.Blue), 2); currentFrame.Draw(name, ref font, new Point(box.Left + 5, box.Bottom - 5), new Bgr(Color.Aqua)); Description += name + " "; } Count = detectedFaces.Count; //Display current frame Count = detectedFaces.Count; ImageBoxOutput.Image = currentFrame; }
private static void ProcessTrainFrame(object sender, EventArgs e) { detectedFaces.Clear(); //Get Current Frame currentFrame = Capture.QueryFrame(); Image <Gray, byte> grayFrame = currentFrame.Convert <Gray, byte>(); //Detect Faces in current frame FaceDetection.Detect(grayFrame, detectedFaces); //Can only Train if there is only one face detected if (detectedFaces.Count == 1) { currentFrame.Draw(detectedFaces[0], new Bgr(Color.Green), 2); } else { detectedFaces.Clear(); } //Display current frame ImageBoxOutput.Image = currentFrame; }