//Process Frame void FrameGrabber_Standard(object sender, EventArgs e) { //Get the current frame form capture device currentFrame = grabber.QueryFrame().ToImage <Bgr, byte>().Resize(320, 240, Emgu.CV.CvEnum.Inter.Cubic); //Convert it to Grayscale if (currentFrame != null) { gray_frame = currentFrame.Convert <Gray, Byte>(); //Face Detector Rectangle[] facesDetected = Face.DetectMultiScale(gray_frame, 1.2, 10, new Size(50, 50), Size.Empty); Rectangle face = facesDetected[0]; //Action for each element detected face.X += (int)(face.Height * 0.15); face.Y += (int)(face.Width * 0.22); face.Height -= (int)(face.Height * 0.3); face.Width -= (int)(face.Width * 0.35); result = currentFrame.Copy(face).Convert <Gray, byte>().Resize(130, 130, Emgu.CV.CvEnum.Inter.Cubic); result._EqualizeHist(); //draw the face detected in the 0th (gray) channel with blue color currentFrame.Draw(face, new Bgr(Color.Blue), 2); if (Eigen_Recog.IsTrained) { string name = Eigen_Recog.Recognise(result); int match_value = (int)Eigen_Recog.Get_Eigen_Distance; //Draw the label for each face detected and recognized CvInvoke.PutText(currentFrame, name + " ", new System.Drawing.Point(face.X - 2, face.Y - 2), FontFace.HersheyComplex, 0.5, new Bgr(Color.LightGreen).MCvScalar); ADD_Face_Found(result, name, match_value); } //Show the faces procesed and recognized image_PICBX.Image = currentFrame.ToBitmap(); } }
void FrameGrabber(object sender, EventArgs e) { //Get the current frame form capture device currentFrame = grabber.QueryFrame().ToImage <Bgr, byte>().Resize(320, 240, Emgu.CV.CvEnum.Inter.Cubic); //Convert it to Grayscale //Clear_Faces_Found(); if (currentFrame != null) { gray_frame = currentFrame.Convert <Gray, Byte>(); //Face Detector Rectangle[] facesDetected = Face.DetectMultiScale(gray_frame, 1.2, 10, new Size(50, 50), Size.Empty); Rectangle face = new Rectangle(); //CircleF eyeDetected = eye; //Action for each element detected try { face = facesDetected[0]; face.X += (int)(face.Height * 0.15); face.Y += (int)(face.Width * 0.22); face.Height -= (int)(face.Height * 0.3); face.Width -= (int)(face.Width * 0.35); result = currentFrame.Copy(face).Convert <Gray, byte>().Resize(100, 100, Emgu.CV.CvEnum.Inter.Cubic); result._EqualizeHist(); //draw the face detected in the 0th (gray) channel with blue color currentFrame.Draw(face, new Bgr(Color.Red), 2); if (Eigen_Recog.IsTrained) { string name = Eigen_Recog.Recognise(result); int match_value = (int)Eigen_Recog.Get_Eigen_Distance; //Draw the label for each face detected and recognized CvInvoke.PutText(currentFrame, name + " ", new System.Drawing.Point(face.X - 2, face.Y - 2), FontFace.HersheyComplex, 0.5, new Bgr(Color.LightBlue).MCvScalar); // ADD_Face_Found(result, name, match_value); } } catch { //do nothing as parrellel loop buggy //No action as the error is useless, it is simply an error in //no data being there to process and this occurss sporadically } //Show the faces procesed and recognized image_PICBX.Image = currentFrame.ToBitmap(); } }