private void ProcessFrame(object sender, EventArgs e) { try { CurrentFullFrame = VideoCapture.QueryFrame().ToImage <Bgr, Byte>(); if (CurrentFullFrame != null) { if (!FacesDetected) { DetectFaces(); } else { foreach (var face in Faces) { CurrentFullFrame.Draw(face, new Bgr(Color.Red), 1); } string temp = ""; foreach (var item in Users) { temp += item.UserName + " - "; } //MessageBox.Show(temp); foreach (var user in Users) { DialogResult sino = MessageBox.Show("Es usted " + user.UserName + " ?", "Reconocimiento", MessageBoxButtons.YesNo); if (sino == DialogResult.Yes) { UserName = user.UserName; this.DialogResult = DialogResult.OK; this.Dispose(); FacesDetectorTimer.Stop(); FacesRecognizerTimer.Stop(); VideoCapture.Stop(); break; } //CurrentFullFrame.Draw(user.UserName, new Point(user.Face.Left, user.Face.Top), Emgu.CV.CvEnum.FontFace.HersheySimplex, 1, new Bgr(Color.White), 2); //CurrentFullFrame.Draw(user.Distance.ToString(), new Point(user.Face.Right, user.Face.Bottom), Emgu.CV.CvEnum.FontFace.HersheySimplex, 1, new Bgr(Color.White), 2); //MessageBox.Show("Test " + user.UserName); } } FPS++; VideoFrameImageBox.Image = CurrentFullFrame; } } catch (Exception) { return; } }
private void ProcessFrame(object sender, EventArgs e) { try { CurrentFullFrame = VideoCapture.QueryFrame().ToImage <Bgr, Byte>(); if (CurrentFullFrame != null) { if (!FacesDetected) { DetectFaces(); } else { if (IsBrowserOpen && Faces.Length == 0) // No face found when browser is open. Therefore, turn off the browser. { ShutdownBrowserSession(); } foreach (var face in Faces) { CurrentFullFrame.Draw(face, new Bgr(Color.Red), 1); } foreach (var user in Users) { CurrentFullFrame.Draw(user.UserName, new Point(user.Face.Left, user.Face.Top), Emgu.CV.CvEnum.FontFace.HersheySimplex, 1, new Bgr(Color.White), 2); CurrentFullFrame.Draw(user.Distance.ToString(), new Point(user.Face.Right, user.Face.Bottom), Emgu.CV.CvEnum.FontFace.HersheySimplex, 1, new Bgr(Color.White), 2); } } FPS++; VideoFrameImageBox.Image = CurrentFullFrame; } } catch (Exception) { return; } }
private void ProcessFrame(object sender, EventArgs e) { try { CurrentFullFrame = VideoCapture.QueryFrame().ToImage <Bgr, Byte>(); if (CurrentFullFrame != null) { if (!FacesDetected) { DetectFaces(); } else { foreach (var face in Faces) { CurrentFullFrame.Draw(face, new Bgr(Color.Red), 1); } string temp = ""; foreach (var item in Users) { temp += item.UserName + " - "; } //MessageBox.Show(temp); foreach (var user in Users) { DialogResult sino = MessageBox.Show("Es usted " + user.UserName + " ?", "Reconocimiento", MessageBoxButtons.YesNo); if (sino == DialogResult.Yes) { UserName = user.UserName; this.DialogResult = DialogResult.OK; using (StreamWriter writer = new StreamWriter(Path.GetTempPath() + @"\Archivo.dat")) { writer.WriteLine(string.Format("{0}", user.UserName)); } //try //{ // miPrimerSocket.Connect(miDireccion); // //Console.WriteLine("Conectado con exito"); // //Console.WriteLine("Ingrese el texto a enviar al servidor: "); // textoEnviar = Encoding.Default.GetBytes(UserName); //pasamos el texto a array de bytes // miPrimerSocket.Send(textoEnviar, 0, textoEnviar.Length, 0); // y lo enviamos // miPrimerSocket.Close(); //} //catch (Exception error) //{ // MessageBox.Show(error.Message); //} this.Dispose(); FacesDetectorTimer.Stop(); FacesRecognizerTimer.Stop(); VideoCapture.Stop(); break; } //CurrentFullFrame.Draw(user.UserName, new Point(user.Face.Left, user.Face.Top), Emgu.CV.CvEnum.FontFace.HersheySimplex, 1, new Bgr(Color.White), 2); //CurrentFullFrame.Draw(user.Distance.ToString(), new Point(user.Face.Right, user.Face.Bottom), Emgu.CV.CvEnum.FontFace.HersheySimplex, 1, new Bgr(Color.White), 2); //MessageBox.Show("Test " + user.UserName); } } FPS++; VideoFrameImageBox.Image = CurrentFullFrame; } } catch (Exception) { return; } }