private void StartCapturing() { if (_biometricClient.FaceCaptureDevice == null) { MessageBox.Show(@"Please select camera from the list"); return; } // Set face capture from stream var face = new NFace { CaptureOptions = NBiometricCaptureOptions.Manual }; _subject = new NSubject(); _subject.Faces.Add(face); facesView.Face = face; _biometricClient.FacesDetectAllFeaturePoints = true; // Begin capturing faces _biometricClient.BeginCapture(_subject, OnCapturingCompleted, null); lblStatus.Text = string.Empty; EnableControls(true); ////_task = _biometricClient.CreateTask(NBiometricOperations.Capture | NBiometricOperations.Enroll | NBiometricOperations.Segment | NBiometricOperations.AssessQuality, _subject); ////_biometricClient.PerformTask(_task); ////if (_task.Status == NBiometricStatus.Ok) ////{ //// pictureBoxCroped.Image = _subject.Faces[0].Image.ToBitmap(); //// _croppedPhotoImage = _subject.Faces[0].Image.ToBitmap(); ////} }
private void OnCapturingCompleted(NBiometricTask task) { var status = task.Status; if (task.Error != null) { Utils.ShowException(task.Error); } if (status == NBiometricStatus.Ok) { _segmentedFace = _subject.Faces[1]; fvPreview.Face = _segmentedFace; icaoWarningView.Face = _segmentedFace; fvFront.Face = _segmentedFace; fvLeftRoll.Face = _segmentedFace; fvRightRoll.Face = _segmentedFace; fvLeftYaw.Face = _segmentedFace; fvRightYaw.Face = _segmentedFace; fvDownPitch.Face = _segmentedFace; fvUpPitch.Face = _segmentedFace; } lblStatus.Text = status.ToString(); lblStatus.ForeColor = status == NBiometricStatus.Ok ? Color.Green : Color.Red; EnableControls(false); }
private void CapturingOperationInit() { _subject = new NSubject(); var face = new NFace { CaptureOptions = NBiometricCaptureOptions.Stream }; _subject.Faces.Add(face); lockFormFaceView.Face = face; }
/* * private void OnCreationCompleted(IAsyncResult r) * { * lock (locker) * { * try * { * NBiometricStatus status = _biometricClient.EndCreateTemplate(r); * if (status != NBiometricStatus.Ok) * { * MessageBox.Show(string.Format("The template was not extracted: {0}.", status)); * } * // EnableVerifyButton(); * } * catch (Exception ex) * { * Utils.ShowException(ex); * } * } * }*/ private string OpenImageTemplate(NFaceView faceView, out NSubject subject) { string savePath = Server.MapPath("~/image/");//指定上传文件在服务器上的保存路径; if (FileUpload1.PostedFile.FileName != null) { if (FileUpload1.HasFile) { //检查服务器上是否存在这个物理路径,如果不存在则创建 if (!System.IO.Directory.Exists(savePath)) { System.IO.Directory.CreateDirectory(savePath); } savePath = savePath + "\\" + FileUpload1.FileName; FileUpload1.SaveAs(savePath); } } subject = null; faceView.Face = null; // msgLabel.Text = string.Empty; string fileLocation = string.Empty; // openFileDialog.FileName = null; // openFileDialog.Title = @"Open Template"; // if (openFileDialog.ShowDialog() == DialogResult.OK) // load template { fileLocation = savePath; // Check if given file is a template try { subject = NSubject.FromFile(savePath); // EnableVerifyButton(); } catch { } // If file is not a template, try to load it as image if (subject == null) { // Create a face object NFace face = new NFace() { FileName = fileLocation }; faceView.Face = face; subject = new NSubject(); subject.Faces.Add(face); // Extract a template from the subject nle.CreateTemplate(subject); } } //subject.Dispose(); return(fileLocation); }
protected override void Dispose(bool disposing) { UnsubscribeFromFaceEvents(); _face = null; _attributes = null; if (disposing && (components != null)) { components.Dispose(); } base.Dispose(disposing); }
private static NSubject CreateSubject(string fileName, bool isMultipleSubjects) { var subject = new NSubject { IsMultipleSubjects = isMultipleSubjects }; var face = new NFace { FileName = fileName }; subject.Faces.Add(face); return(subject); }
private void VerificationOperationInit() { VerificationOperationButtonconfig(); lblInfo.Text = Resources.Capturing_user___; _subject = new NSubject(); var face = new NFace { CaptureOptions = NBiometricCaptureOptions.Stream }; _subject.Faces.Add(face); nlockLoginFaceView.Face = _subject.Faces[0]; _currentop = Ops.Ongoing; _biometricClient.BeginCapture(_subject, OnCapturingCompleted, null); }
private async void BtnStartClickAsync(object sender, EventArgs e) { if (capturedFaces.Count == 7) { MessageBox.Show("All Faces captured."); return; } if (_biometricClient.FaceCaptureDevice == null) { MessageBox.Show(@"Please select camera from the list"); return; } // Set face capture from stream _face = new NFace { CaptureOptions = NBiometricCaptureOptions.Stream }; _subject = new NSubject(); _subject.Faces.Add(_face); fvPreview.Face = _face; icaoWarningView.Face = _face; _biometricClient.FacesCheckIcaoCompliance = true; var task = _biometricClient.CreateTask(NBiometricOperations.Capture | NBiometricOperations.Segment | NBiometricOperations.CreateTemplate, _subject); /*var task = _biometricClient.CreateTask(NBiometricOperations.Capture | NBiometricOperations.Segment, _subject);*/ lblStatus.Text = string.Empty; EnableControls(true); try { var performedTask = await _biometricClient.PerformTaskAsync(task); OnCapturingCompleted(performedTask); } catch (Exception ex) { Utils.ShowException(ex); lblStatus.Text = string.Empty; EnableControls(false); var a = 8; } }
private async void btnStart_Click(object sender, EventArgs e) { #region Iniciar captura de facial if (_biometricClient.FaceCaptureDevice == null) { MessageBox.Show(@"Seleccione una camara de la lista"); return; } // Set face capture from stream var face = new NFace { CaptureOptions = NBiometricCaptureOptions.Stream }; if (!chbCaptureAutomatically.Checked) { face.CaptureOptions |= NBiometricCaptureOptions.Manual; } _subjectFace = new NSubject(); _subjectFace.Faces.Add(face); facesView.Face = face; // Begin capturing faces EnableFaceControls(true); lblStatus.Text = string.Empty; //lblQuality.Text = string.Empty; try { var status = await _biometricClient.CaptureAsync(_subjectFace); await OnCapturingFaceCompletedAsync(status); } catch (Exception ex) { Neurotec.Samples.Utils.ShowException(ex); lblStatus.Text = string.Empty; //lblQuality.Text = string.Empty; EnableFaceControls(false); } #endregion }
public async Task <PersonaInfo> BuscarFacial(string imagenBase64, int idBusqueda) { #region BuscarHuella var face = new NFace(); var subject = new NSubject(); var buscador = new BiometriaBuscador(); try { var template = Convert.FromBase64String(imagenBase64); face.SampleBuffer = new Neurotec.IO.NBuffer(template); subject.Faces.Add(face); var result = await buscador.BuscarFacialEnTemplates(subject, idBusqueda); return(result.PersonaIdentificar); } catch (Exception ex) { Utils.LogEvent(ex.Message); throw; } #endregion }
private void OnDetectDone(IAsyncResult r) { NF = _biometricClient.EndDetectFaces(r); }
public async Task <VerificarHuellaInfo> BuscarFacialEnTemplates(NSubject subjectBuscar, int idBusqueda) { #region BuscarHuellaEnTemplates var select = "SELECT ESTADO,MUNICIPIO,CERESO,ANO,FOLIO,FOTO_CENTRO FROM BTS.FICHA "; var conn = new OracleConnection(_connStr); var template = new byte[] { }; var subject = new NSubject(); var facial = new NFace(); var _verificarHuellaInfo = new VerificarHuellaInfo(); try { await conn.OpenAsync(); var cmdSelect = new OracleCommand(select, conn); var dr = await cmdSelect.ExecuteReaderAsync(); while (await dr.ReadAsync()) { if (dr.IsDBNull(5) == false) { template = (byte[])dr[5]; facial = new NFace(); facial.SampleBuffer = new Neurotec.IO.NBuffer(template); subject = new NSubject(); subject.Faces.Add(facial); var status = await _biometricClient.VerifyAsync(subject, subjectBuscar); var verificationStatus = string.Format("Verification status: {0}", status); if (status == NBiometricStatus.Ok) { _verificarHuellaInfo.Identificado = true; _verificarHuellaInfo.PersonaIdentificar.id = idBusqueda; _verificarHuellaInfo.PersonaIdentificar.Identificado = true; _verificarHuellaInfo.PersonaIdentificar.estado = dr.GetInt16(0); _verificarHuellaInfo.PersonaIdentificar.municipio = dr.GetInt16(1); _verificarHuellaInfo.PersonaIdentificar.cereso = dr.GetString(2); _verificarHuellaInfo.PersonaIdentificar.ano = dr.GetInt16(3); _verificarHuellaInfo.PersonaIdentificar.folio = dr.GetInt64(4); await RegistrarMatch(_verificarHuellaInfo.PersonaIdentificar, 1, conn); break; } } } return(_verificarHuellaInfo); } catch (Exception ex) { Utils.LogEvent(ex.Message); throw; } finally { conn.Close(); conn.Dispose(); } #endregion }
/* * int score; * private void OnVerifyCompleted(IAsyncResult r) * { * lock (locker) * { * * try * { * NBiometricStatus status = _biometricClient.EndVerify(r); * if (status == NBiometricStatus.Ok || status == NBiometricStatus.MatchNotFound) * { * //get matching score * score = _subject1.MatchingResults[0].Score; * // string msg = string.Format("Score of matched templates: {0}", score); * //msgLabel.Text = msg; * // MessageBox.Show(msg); * } * else MessageBox.Show(status.ToString()); * } * catch (Exception ex) * { * Utils.ShowException(ex); * } * } * * }*/ protected void Button1_Click(object sender, EventArgs e) { deleteresultshow(); NMatcher nm = new NMatcher(); OpenImageTemplate(faceView1, out _subject1); MySqlConnection conn = new MySqlConnection("server=localhost;database=test;uid=root;password=root"); conn.Open(); String sqlcommand = String.Format("select * from imgdata"); MySqlCommand cmd = new MySqlCommand(sqlcommand, conn); MySqlDataReader msr = cmd.ExecuteReader(); while (msr.Read()) { string id = (string)msr.GetValue(1); byte[] blob = (byte[])msr.GetValue(0); string name = (string)msr.GetValue(2); string gender = (string)msr.GetValue(3); DateTime bir = (DateTime)msr.GetValue(4); string birth = bir.ToShortDateString(); string phonenumber = (string)msr.GetValue(5);; Neurotec.Images.NImage img = ImageData.getNImageDataFromBytes(blob); NFace face = new NFace(); face.Image = img; NSubject subject = new NSubject(); subject.Faces.Add(face); // _biometricClient.BeginCreateTemplate(subject, OnCreationCompleted, subject); nle.CreateTemplate(subject); // Thread.Sleep(500); if (_subject1 != null && subject != null) { int score1 = nm.Verify(_subject1.GetTemplateBuffer(), subject.GetTemplateBuffer()); // _biometricClient.BeginVerify(_subject1,subject, OnVerifyCompleted, null); btlist.Add(new btnode(blob, score1, id, name, gender, birth, phonenumber)); } } conn.Close(); msr.Close(); int maxscore = 0; int temp = 0; string str = ""; for (int i = 0; i < btlist.Count; i++) { sqlcommand = "insert into resultshow(score,id,name,gender,birth,phonenumber,data) values(@score,@id,@name,@gender,@birth,@phonenumber,@data)"; cmd = new MySqlCommand(sqlcommand, conn); MySqlParameter[] param = new MySqlParameter[7]; param[0] = new MySqlParameter("@score", btlist[i].score); param[1] = new MySqlParameter("@id", btlist[i].id); param[2] = new MySqlParameter("@name", btlist[i].name); param[3] = new MySqlParameter("@gender", btlist[i].gender); param[4] = new MySqlParameter("@birth", btlist[i].birth); param[5] = new MySqlParameter("@phonenumber", btlist[i].phonenumber); param[6] = new MySqlParameter("@data", btlist[i].blob); for (int j = 0; j < param.Length; j++) { cmd.Parameters.Add(param[j]); } conn.Open(); try { cmd.ExecuteNonQuery(); } catch (System.Exception ex) { StreamWriter sw = new StreamWriter("C:\\myerror.txt", true, Encoding.Default); sw.Write(ex.Message); sw.Close(); //一旦发生错误程序就停止运行,等待用户发现 Console.Read(); } conn.Close(); conn.Dispose(); msr.Dispose();/* * if (btlist[i].score>maxscore) * { * maxscore = btlist[i].score; * temp = i; * }*/ // str += btlist[i].score + " "; } // MessageBox.Show(str); /* * sqlcommand = "insert into resultshow(score,data) values(@score,@data)"; * cmd = new MySqlCommand(sqlcommand, conn); * MySqlParameter[] param = new MySqlParameter[2]; * param[0] = new MySqlParameter("@score",btlist[temp].score); * param[1] = new MySqlParameter("@data", btlist[temp].blob); * for (int i = 0; i < param.Length; i++) * cmd.Parameters.Add(param[i]); * conn.Open(); * try * { * cmd.ExecuteNonQuery(); * } * catch (System.Exception ex) * { * StreamWriter sw = new StreamWriter("C:\\myerror.txt", true, Encoding.Default); * sw.Write(ex.Message); * sw.Close(); * //一旦发生错误程序就停止运行,等待用户发现 * Console.Read(); * } * * conn.Close(); * conn.Dispose(); * msr.Dispose(); */ Response.Redirect("Default4.aspx", false); }