private void ProcessFrame(object sender, EventArgs e) { try { String m = ""; _cascadeClassifier = new CascadeClassifier("C:/Emgu/emgucv-windesktop 3.2.0.2682/opencv/data/haarcascades/haarcascade_frontalface_default.xml"); using (var imageFrame = _capture.QueryFrame().ToImage <Bgr, Byte>()) { if (imageFrame != null) { var grayframe = imageFrame.Convert <Gray, byte>(); var faces = _cascadeClassifier.DetectMultiScale(grayframe, 1.1, 10, Size.Empty); //the actual face detection happens here foreach (var face in faces) { imageFrame.Draw(face, new Bgr(Color.BurlyWood), 3); //the detected face(s) is highlighted here using a box that is drawn around it/them grayframe.Draw(face, new Gray(1.523), 3); unknownFace = grayframe; lable = myRecognizer.RecognizeUser(unknownFace); } } imgCamUser.Image = imageFrame; sqlite_conn.Open(); sqlite_cmd = sqlite_conn.CreateCommand(); sqlite_cmd.CommandText = "select doc_name from doctor where doc_id =" + lable + ";"; sqlite_datareader = sqlite_cmd.ExecuteReader(); while (sqlite_datareader.Read()) { m = sqlite_datareader.GetString(0); } sqlite_cmd.ExecuteNonQuery(); sqlite_conn.Close(); sqlite_datareader.Close(); Console.WriteLine("name " + m + "id" + lable); label4.Text = "Hi " + m; } } catch (Exception ex) { } }
private void recognizeTheFace_Click(object sender, EventArgs e) { trainCascadeClassifier = new CascadeClassifier("C:/Emgu/emgucv-windesktop 3.2.0.2682/opencv/data/haarcascades/haarcascade_frontalface_default.xml"); using (var currentFrame = _capture.QueryFrame().ToImage <Bgr, Byte>()) { if (currentFrame != null) { var grayframe = currentFrame.Convert <Gray, byte>(); var faces = trainCascadeClassifier.DetectMultiScale(grayframe, 1.1, 10, Size.Empty); //the actual face detection happens here foreach (var face in faces) { grayframe.Draw(face, new Gray(1.523), 3); //the detected face(s) is highlighted here using a box that is drawn around it/them } unknownFace = grayframe; } } int lable = myRecognizer.RecognizeUser(unknownFace); Console.Write(lable); MessageBox.Show("" + lable, "Detected Face", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); }
private void ProcessFrame(object sender, EventArgs e) { try { String m = ""; DateTime datetime = DateTime.Now; sqlite_conn = new SQLiteConnection("Data Source=" + Environment.GetEnvironmentVariable("appdata") + "/Project_1_1/Project.db ; Version =3;"); int lable = 0; _cascadeClassifier = new CascadeClassifier("C:/Emgu/emgucv-windesktop 3.2.0.2682/opencv/data/haarcascades/haarcascade_frontalface_default.xml"); using (var imageFrame = _capture.QueryFrame().ToImage <Bgr, Byte>()) { if (imageFrame != null) { var grayframe = imageFrame.Convert <Gray, byte>(); var faces = _cascadeClassifier.DetectMultiScale(grayframe, 1.1, 10, Size.Empty); //the actual face detection happens here foreach (var face in faces) { imageFrame.Draw(face, new Bgr(Color.BurlyWood), 3); //the detected face(s) is highlighted here using a box that is drawn around it/them grayframe.Draw(face, new Gray(1.523), 3); unknownFace = grayframe; lable = myRecognizer.RecognizeUser(unknownFace); } } imgCamUser.Image = imageFrame; if (lable == 0) { label4.Text = "Sorry I don't know you , please leave a copy of ur ID"; } else { sqlite_conn.Open(); sqlite_cmd = sqlite_conn.CreateCommand(); sqlite_cmd.CommandText = "select stu_name from student where stu_id =" + lable + ";"; sqlite_datareader = sqlite_cmd.ExecuteReader(); while (sqlite_datareader.Read()) { m = sqlite_datareader.GetString(0); } sqlite_cmd.ExecuteNonQuery(); sqlite_conn.Close(); sqlite_datareader.Close(); label4.Text = "Hi " + m; String r = ""; // Console.WriteLine("name " + m + "id" + lable); sqlite_conn.Open(); sqlite_cmd = sqlite_conn.CreateCommand(); sqlite_cmd.CommandText = "select student_id from attendance where student_id =" + lable + "and subj_id = '" + subj + "';"; sqlite_datareader = sqlite_cmd.ExecuteReader(); while (sqlite_datareader.Read()) { r = sqlite_datareader.GetString(0); } sqlite_cmd.ExecuteNonQuery(); sqlite_conn.Close(); sqlite_datareader.Close(); if (lable != 0 && r == "") { sqlite_conn.Open(); sqlite_cmd = sqlite_conn.CreateCommand(); sqlite_cmd.CommandText = "insert into attendance values(" + lable + ",'" + subj + "','" + datetime + "');"; sqlite_cmd.ExecuteNonQuery(); sqlite_conn.Close(); } } } } catch (Exception ex) { } }