protected virtual void Process(DPFP.Sample Sample) { DrawPicture(ConvertSampleToBitmap(Sample)); DPFP.FeatureSet features = ExtractFeatures(Sample, DPFP.Processing.DataPurpose.Verification); if (features != null) { byte[] bytes = new byte[1632]; features.Serialize(ref bytes); for (int x = 0; x < List_Usuarios.Count; x++) { DPFP.Template templeate = new DPFP.Template(); templeate.DeSerialize(List_Usuarios[x].fingerPrint); DPFP.Verification.Verification.Result result = new DPFP.Verification.Verification.Result(); Verificator.Verify(features, templeate, ref result); if (result.Verified) { _idCliente = List_Usuarios[x].id_Cliente; return; } } //videoSourcePlayer1.BackgroundImage = Properties.Resources.Desconocido; MessageBox.Show("Cliente no encontrado", "Information", MessageBoxButtons.OK, MessageBoxIcon.Stop); } }
protected virtual void Process(DPFP.Sample Sample) { DrawPicture(ConvertSampleToBitmap(Sample)); DPFP.FeatureSet features = ExtractFeatures(Sample, DPFP.Processing.DataPurpose.Verification); if (features != null) { byte[] bytes = new byte[1632]; features.Serialize(ref bytes); for (int x = 0; x < List_Usuarios.Count; x++) { DPFP.Template templeate = new DPFP.Template(); templeate.DeSerialize(List_Usuarios[x].fingerPrint); DPFP.Verification.Verification.Result result = new DPFP.Verification.Verification.Result(); Verificator.Verify(features, templeate, ref result); if (result.Verified) { int id_usuario = List_Usuarios[x].id_Cliente; var usuario = (from cliente in contexto.tb_Usuarios where cliente.id_usuario == id_usuario select cliente).Single(); MessageBox.Show("VERIFICADO " + usuario.nombre_usuario); return; } } MessageBox.Show("NO ENCONTRADO"); } }
private DPFP.Template convertTemplate(string p) { byte[] decByte3 = Convert.FromBase64String(p); DPFP.Template tmp = new DPFP.Template(); tmp.DeSerialize(decByte3); return(tmp); }
public void OnComplete(object Capture, string ReaderSerialNumber, DPFP.Sample Sample) { //Process(Sample); try { Connection con = new Connection(); con.Connect(); SqlCommand cmd = new SqlCommand(); cmd.CommandText = " select * from resident "; cmd.Connection = Connection.con; SqlDataAdapter sd = new SqlDataAdapter(cmd); DataTable dt = new DataTable(); sd.Fill(dt); foreach (DataRow dr in dt.Rows) { byte[] _img = (byte[])dr["resident_fingerprint"]; //string id = dr["RESIDENT_ID"].ToString(); MemoryStream ms = new MemoryStream(_img); DPFP.Template Template = new DPFP.Template(); Template.DeSerialize(ms); DPFP.Verification.Verification Verificator = new DPFP.Verification.Verification(); // Process(Sample); DPFP.FeatureSet features = ExtractFeatures(Sample, DPFP.Processing.DataPurpose.Verification); if (features != null) { DPFP.Verification.Verification.Result result = new DPFP.Verification.Verification.Result(); Verificator.Verify(features, Template, ref result); // UpdateStatus(result.FARAchieved); if (result.Verified) { MessageBox.Show("This Resident is already Registered!!!"); Reset(); FMPIclear(); break; } else { MakeReport("fingerprint captured."); SetPrompt("Scan fingerprint again"); Process(Sample); if (scans.Text == "0 scans left") { cp.StopCapture(); } break; } } else { } } } catch { } }
public static DPFP.Template ProcessDBTemplate(byte[] _data) { DPFP.Template _template = null; Stream _ms = new MemoryStream(_data); _template = new DPFP.Template(); //deserialize _template.DeSerialize(_ms); return(_template); }
public void OnComplete(object Control, DPFP.FeatureSet FeatureSet, ref DPFP.Gui.EventHandlerStatus Status) { DPFP.Verification.Verification ver = new DPFP.Verification.Verification(); DPFP.Verification.Verification.Result res = new DPFP.Verification.Verification.Result(); try { string mem = null; con.Open(); SqlCommand cmd = new SqlCommand("select memName,finger from familyMembers where CardNo='" + CardNo + "'", con); SqlDataReader dr = cmd.ExecuteReader(); DPFP.Template template = new DPFP.Template(); while (dr.Read()) { mem = dr["memName"].ToString(); byte[] tmp = (byte[])dr["finger"]; template.DeSerialize(tmp); if (template != null) { ver.Verify(FeatureSet, template, ref res); Data.IsFeatureSetMatched = res.Verified; Data.FalseAcceptRate = res.FARAchieved; string rate = Data.FalseAcceptRate.ToString() + "00"; string sp = rate.Remove(2); label1.Text = sp + " %"; if (sp == "00") { label1.Text = "100 %"; } if (res.Verified) { MessageBox.Show("Verification Success"); con.Close(); UserLogin.member = mem; return; } } } } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { con.Close(); } //if (!res.Verified) // Status = DPFP.Gui.EventHandlerStatus.Failure; //MessageBox.Show("Unauthorized User"); Data.Update(); }
public IEnumerable <Record> getFingerPrintTemplate() { SqlConnection sqlcon = Connection.con(); try { using (sqlcon) { SqlCommand cmd = new SqlCommand("getFingerPrintCourse", sqlcon); if (sqlcon.State == ConnectionState.Closed) { sqlcon.Open(); } cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@session", Session); cmd.Parameters.AddWithValue("@semesterid", Semester); cmd.Parameters.AddWithValue("@courseid", Courseid); SqlDataReader reader; reader = cmd.ExecuteReader(); //DataTable dt = new DataTable(); //dt.Load(reader); var id = ""; DPFP.Template template = new DPFP.Template(); List <Record> record = new List <Record>(); while (reader.Read()) { id = reader["MatricNo"].ToString(); //DPFP.Template template = new DPFP.Template(); MemoryStream memStreamTemplate = new MemoryStream((byte[])reader["FingerPrint"]); // Dim memStreamTemplate As New MemoryStream(CType(reader("Features"), Byte())) template.DeSerialize(memStreamTemplate); var rec = new Record(id, template); record.Add(rec); } reader.Close(); return(record); } } catch (Exception ex) { throw new Exception(ex.ToString()); } finally { con.CloseCon(); } }
protected void Process(DPFP.Sample Sample) { TimeSpan begin = TimeSpan.Parse("07:00"); TimeSpan stop = TimeSpan.Parse("19:00"); TimeSpan now = DateTime.Now.TimeOfDay; if (now >= begin && now <= stop) { bool verified = false; // Draw fingerprint sample image. DrawPicture(ConvertSampleToBitmap(Sample)); // Process the sample and create a feature set for the enrollment purpose. DPFP.FeatureSet features = ExtractFeatures(Sample, DPFP.Processing.DataPurpose.Verification); // Check quality of the sample and start verification if it's good // TODO: move to a separate task if (features != null) { foreach (var val in list) { Staff_finger = val; f_print = Convert.FromBase64String(val); DPFP.Template temp = new DPFP.Template(); temp.DeSerialize(f_print); Template = temp; DPFP.Verification.Verification.Result result = new DPFP.Verification.Verification.Result(); Verificator.Verify(features, Template, ref result); //UpdateStatus(result.FARAchieved); if (result.Verified) { verified = true; MakeReport("The fingerprint was VERIFIED."); checktimeOut(); //dbAccess(); } } // Compare the feature set with our template if (!verified) { MessageBox.Show("Invalid staff"); } } } else { MessageBox.Show("System Inactive"); } }
public void VerificarChecado(frmChecarEntradaSalida FrmChecar, DPFP.Sample Sample, DataTable datosHuellas, ref bool acceso, ref string id_usuario) { try { foreach (DataRow usuario in datosHuellas.Rows) { DPFP.Template templateGuardado = new DPFP.Template(); templateGuardado.DeSerialize(ConvertirStringToBytes.StringToBytes(usuario["HuellaDigital"].ToString())); if (ProcesarChecado(Sample, templateGuardado, FrmChecar)) { id_usuario = usuario["IDEmpleado"].ToString(); acceso = true; break; } } } catch (Exception ex) { LogError.AddExcFileTxt(ex, "LectorHuell ~ VerificarChecado"); } }
private bool CargarDedos() { try { DPFP.Template template; int k; byte[] blob; string archivo; for (k = 1; k <= 10; k++) { if (k <= 5) { archivo = RutaImagenes + Usuario + "_d" + k.ToString().Trim() + ".ddo"; } else { archivo = RutaImagenes + Usuario + "_i" + (k - 5).ToString().Trim() + ".ddo"; } if (File.Exists(archivo)) { var stream = File.Open(archivo, FileMode.Open); blob = new byte[(int)stream.Length]; stream.Read(blob, 0, (int)stream.Length); template = new DPFP.Template(); template.DeSerialize(blob); Templates.Add(template); stream.Close(); } } return(true); } catch (Exception ex) { //MessageBox.Show(ex.Message, "Verificar Huella", MessageBoxButtons.OK, MessageBoxIcon.Error); throw ex; return(false); } }
protected override void Process(DPFP.Sample Sample) { base.Process(Sample); // Process the sample and create a feature set for the enrollment purpose. DPFP.FeatureSet features = ExtractFeatures(Sample, DPFP.Processing.DataPurpose.Verification); // Check quality of the sample and start verification if it's good // TODO: move to a separate task if (features != null) { byte[] bytes = new byte[1632]; features.Serialize(ref bytes); //"0X" + BitConverter.ToString( bytes ).Replace("-","") for (int x = 0; x < List_Usuarios.Count; x++) { DPFP.Template templeate = new DPFP.Template(); templeate.DeSerialize(List_Usuarios[x].dedo); //Compare the feature set with our template DPFP.Verification.Verification.Result result = new DPFP.Verification.Verification.Result(); Verificator.Verify(features, templeate, ref result); //UpdateStatus(result.FARAchieved); if (result.Verified) { MessageBox.Show("VERIFICADO " + List_Usuarios[x].nombre_usuario);//MakeReport("The fingerprint was VERIFIED."); return; } } MessageBox.Show("NO ENCONTRADO"); //if (templeate == null) // return; } }
private string comparar(DPFP.FeatureSet features) { string mensaje = ""; try { f.conexion.Open(); SqlCommand y = new SqlCommand("select Huella, Nombres from Huellas where huella is not null", f.conexion); SqlDataReader select; select = y.ExecuteReader(); byte[] tx = null; int cont = 0; DPFP.Verification.Verification.Result resulta = new DPFP.Verification.Verification.Result(); while (select.Read()) { tx = (byte[])select.GetValue(0); DPFP.Template templates = new DPFP.Template(); templates.DeSerialize((byte[])tx); verify.Verify(features, templates, ref resulta); if (resulta.Verified) { mensaje = "Huella registrada"; textBox1.Text = select.GetValue(1).ToString(); cont++; break; } } } catch (Exception er) { MessageBox.Show(er.Message + "..."); } f.conexion.Close(); return(mensaje); }
//@session char (9),@semesterid int,@courseid int public List <Record> VerifyFingerPrint() { try { SqlCommand cmd = new SqlCommand("verifyfingerprint", con.ActiveCon()); cmd.CommandType = CommandType.StoredProcedure; //cmd.Parameters.AddWithValue("@Searchvalue", Search); SqlDataReader reader; reader = cmd.ExecuteReader(); //DataTable dt = new DataTable(); //dt.Load(reader); var id = ""; DPFP.Template template = new DPFP.Template(); List <Record> record = new List <Record>(); while (reader.Read()) { id = reader["MatricNo"].ToString(); //DPFP.Template template = new DPFP.Template(); MemoryStream memStreamTemplate = new MemoryStream((byte[])reader["FingerPrint"]); // Dim memStreamTemplate As New MemoryStream(CType(reader("Features"), Byte())) template.DeSerialize(memStreamTemplate); var rec = new Record(id, template); record.Add(rec); } return(record); } catch (Exception ex) { throw new Exception(ex.ToString()); } }
protected virtual void Process(DPFP.Sample Sample) { DrawPicture(ConvertSampleToBitmap(Sample)); DPFP.FeatureSet features = ExtractFeatures(Sample, DPFP.Processing.DataPurpose.Verification); if (features != null) { byte[] bytes = new byte[1632]; features.Serialize(ref bytes); imprimir imprimir = new imprimir(mostrar_info); for (int x = 0; x < lista.Count; x++) { DPFP.Template templeate = new DPFP.Template(); //if (lista[x].huella == null) //{ // return; //} templeate.DeSerialize(lista[x].huella); DPFP.Verification.Verification.Result result = new DPFP.Verification.Verification.Result(); Verificator.Verify(features, templeate, ref result); if (result.Verified) { id_usuario = lista[x].id_cliente; tipo_persona = lista[x].tipo; if (tipo_persona == "Cliente") { if (id_usuario == id_usuario_anterior && tipo_persona == tipo_persona_anterior) { } else { var fecha = contexto.sp_Buscar_Clientes_Id(id_usuario).ToList(); //if() valor = verificar_vencimiento(Convert.ToDateTime(fecha[0].fecha_corte)); //var usuario = (from cliente in contexto.Catalogo_Clientes where cliente.id_cliente == id_usuario select cliente).Single(); var data = (Byte[])fecha[0].foto; var stream = new MemoryStream(data); Foto_videoSourcePlayer.BackgroundImage = Image.FromStream(stream); this.Invoke(imprimir, new Object_Checado() { nombre = fecha[0].nombre, valor = valor, fecha = Convert.ToDateTime(fecha[0].fecha_corte) }); id_usuario_anterior = id_usuario; tipo_persona_anterior = tipo_persona; timer1.Start(); } } else if (tipo_persona == "Instructor") { if (id_usuario == id_usuario_anterior && tipo_persona == tipo_persona_anterior) { } else { var estatus = contexto.sp_Buscar_Instructor_Id(id_usuario).First(); if (estatus.estatus == true) { contexto.sp_Registro_Ingreso(id_usuario, true, true, id_responsable); } else if (estatus.estatus == false) { contexto.sp_Registro_Ingreso(id_usuario, true, false, id_responsable); } var usuario = (from cliente in contexto.Catalogo_Instructores where cliente.id_instructor == id_usuario select cliente).First(); var data = (Byte[])usuario.foto; var stream = new MemoryStream(data); Foto_videoSourcePlayer.BackgroundImage = Image.FromStream(stream); valor = 2; this.Invoke(imprimir, new Object_Checado() { nombre = usuario.nombre, valor = valor }); id_usuario_anterior = id_usuario; tipo_persona_anterior = tipo_persona; timer1.Start(); } } return; } } this.Invoke(imprimir, new Object_Checado() { nombre = "Desconocido", valor = 0 }); color_pictureBox.BackColor = Color.White; Foto_videoSourcePlayer.BackgroundImage = Properties.Resources.Desconocido; } }
public void ProcesarPersonal(DPFP.Sample Sample) { try { bool banRegistrado = true; DrawPicturePersonal(ConvertSampleToBitmapPersonal(Sample)); DPFP.FeatureSet features = ExtractFeaturesPersonal(Sample, DPFP.Processing.DataPurpose.Enrollment); if (features != null) { try { Enroller.AddFeatures(features); } catch (Exception) { //LogError.AddExcFileTxt(ex, "LectorHuella ~ ProcesarPersonal"); this.FrmCapturaHuella.Invoke(new Function(delegate() { FrmCapturaHuella.lblInstrucciones.Text = "Error al procesar las huellas."; FrmCapturaHuella.lblInstrucciones.BackColor = Color.Red; })); Thread.Sleep(2400); } } finally { UpdateStatusPersonal(); switch (Enroller.TemplateStatus) { case DPFP.Processing.Enrollment.Status.Ready: Template = Enroller.Template; if (DatosHuellas == null) { Usuario_Negocio UN = new Usuario_Negocio(); Usuario DatosAux = new Usuario { Conexion = Comun.Conexion }; UN.ObtenerHuellasDigitales(DatosAux); DatosHuellas = DatosAux.TablaDatos; } foreach (DataRow usuario in DatosHuellas.Rows) { DPFP.Template templateGuardado = new DPFP.Template(); templateGuardado.DeSerialize(ConvertirStringToBytes.StringToBytes(usuario["HuellaDigital"].ToString())); if (procesarPersonal(Sample, templateGuardado)) { banRegistrado = false; break; } } if (banRegistrado) { FrmCapturaHuella.Lector.Stop(); activaBtnPersonal(); } else { Enroller.Clear(); FrmCapturaHuella.Lector.Stop(); FrmCapturaHuella.Invoke(new Function(delegate() { FrmCapturaHuella.lblInstrucciones.Text = "La huella ya estĆ” registrada."; FrmCapturaHuella.lblInstrucciones.BackColor = Color.Red; //System.Windows.Forms.MessageBox.Show("La huella ya estĆ” registrada.", "Sistema Administrador CSL", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); //FrmCapturaHuella.DialogResult = System.Windows.Forms.DialogResult.Abort; })); Thread.Sleep(2400); Template = null; FrmCapturaHuella.Lector = new LectorHuella(); FrmCapturaHuella.frmCatEmpleadoHuella_Load(new object(), new EventArgs()); UpdateStatusPersonal(); } break; case DPFP.Processing.Enrollment.Status.Failed: Enroller.Clear(); FrmCapturaHuella.Lector.Stop(); UpdateStatusPersonal(); Template = null; FrmCapturaHuella.Lector.Start(); break; } } }
public Idp[] GetPersons() { MySqlCommand selectJoin = new MySqlCommand(); selectJoin.Connection = mySqlConnection; selectJoin.CommandText = "SELECT b.id, first_name, last_name, other_names, dob, yob, gender, marital_status, state, lga, " + "f.finger_1, finger_2, finger_3, finger_4, finger_5, finger_6, finger_7, finger_8, finger_9, finger_10, " + "p.photo " + "from bios as b join photos as p on b.id = p.id join fingers as f on b.id = f.id"; List <Idp> persons = new List <Idp>(); try { mySqlConnection.Open(); MySqlDataReader dr = selectJoin.ExecuteReader(System.Data.CommandBehavior.SequentialAccess); while (dr.Read()) { Idp person = new Idp(); if (!dr.IsDBNull(dr.GetOrdinal("id"))) { person.ID = dr.GetString("id"); } if (!dr.IsDBNull(dr.GetOrdinal("first_name"))) { person.FirstName = dr.GetString("first_name"); } if (!dr.IsDBNull(dr.GetOrdinal("last_name"))) { person.LastName = dr.GetString("last_name"); } if (!dr.IsDBNull(dr.GetOrdinal("other_names"))) { person.OtherNames = dr.GetString("other_names"); } if (!dr.IsDBNull(dr.GetOrdinal("dob"))) { person.DoB = dr.GetDateTime("dob"); } if (!dr.IsDBNull(dr.GetOrdinal("yob"))) { person.YoB = dr.GetInt32("yob"); } if (!dr.IsDBNull(dr.GetOrdinal("gender"))) { person.Gender = dr.GetString("gender"); } if (!dr.IsDBNull(dr.GetOrdinal("marital_status"))) { person.MaritalStatus = dr.GetString("marital_status"); } if (!dr.IsDBNull(dr.GetOrdinal("state"))) { person.State = dr.GetString("state"); } if (!dr.IsDBNull(dr.GetOrdinal("lga"))) { person.LGA = dr.GetString("lga"); } for (int index = 0; index < person.FingerTemplates.Length; index++) { int realIndex = index + 1; int ordinal = dr.GetOrdinal("finger_" + realIndex); if (!(dr.IsDBNull(ordinal))) { byte[] deserializedTemplate = (byte[])dr["finger_" + realIndex]; DPFP.Template template = new DPFP.Template(); template.DeSerialize(deserializedTemplate); person.FingerTemplates[index] = template; } } int phOrdinal = dr.GetOrdinal("photo"); if (!(dr.IsDBNull(phOrdinal))) { byte[] imgBytes = GetBytes(dr, phOrdinal); person.Photo = ByteArrayToImage(imgBytes); } persons.Add(person); } dr.Close(); } catch (Exception ex) { } finally { mySqlConnection.Close(); } return(persons.ToArray()); }
protected override void Process(DPFP.Sample Sample) { base.Process(Sample); // Process the sample and create a feature set for the enrollment purpose. DPFP.FeatureSet features = ExtractFeatures(Sample, DPFP.Processing.DataPurpose.Verification); // Check quality of the sample and start verification if it's good // TODO: move to a separate task if (features != null) { // Compare the feature set with our template DPFP.Verification.Verification.Result result = new DPFP.Verification.Verification.Result(); //template dibuat switch case // ambil dari database , nama dan template // upload data finger dan data id , id[n] = Fingerprint //Indexes , string connstring = "Host=192.168.56.102;Username=david;Password=david;Database=QFC_ADMIN"; // Making connection with Npgsql provider NpgsqlConnection conn = new NpgsqlConnection(connstring); conn.Open(); string sql = "select name,fingerprint from res_partner where customer = True and fingerprint is not null;"; // data adapter making request from our connection NpgsqlDataAdapter da = new NpgsqlDataAdapter(sql, conn); //datataba /* DataResult<Fmd> resultConversion = null; * IdentifyResult identifyResult = null; * string MobileNumber = ""; * string Cnic = ""; */ // Check capture quality and throw an error if bad. // if (!this.CheckCaptureResult(captureResult)) return; // See the SDK documentation for an explanation on threshold scores. //int thresholdScore = DPFJ_PROBABILITY_ONE * 1 / 100000; // https://stackoverflow.com/questions/55838416/matching-fingerprint-with-a-database-sourceafis //https://stackoverflow.com/questions/41742993/digital-persona-finger-print-verification-from-database-not-working //DataSet dataSetBiometric = DatabaseHandler.getData("select CNIC, MOBILE_NUMBER, BIOMETRIC from ACCOUNT_OPENING"); //select CNIC, MOBILE_NUMBER, BIOMETRIC from ACCOUNT_OPENING ds.Reset(); // filling DataSet with result from NpgsqlDataAdapter da.Fill(ds); // since it C# DataSet can handle multiple tables, we will select first dt = ds.Tables[0]; foreach (DataRow dr in dt.Rows) { byte[] _img = (byte[])dr["fingerprint"]; MemoryStream ms = new MemoryStream(_img); DPFP.Template Template = new DPFP.Template(); Template.DeSerialize(ms); DPFP.Verification.Verification Verificator = new DPFP.Verification.Verification(); base.Process(Sample); DPFP.FeatureSet features2 = ExtractFeatures(Sample, DPFP.Processing.DataPurpose.Verification); if (features2 != null) { DPFP.Verification.Verification.Result result2 = new DPFP.Verification.Verification.Result(); Verificator.Verify(features2, Template, ref result2); UpdateStatus(result.FARAchieved); if (result2.Verified) { MakeReport("The fingerprint was VERIFIED."); MakeReport(dr["name"].ToString()); MessageBox.Show(dr["name"].ToString()); } else { MakeReport("The fingerprint was NOT VERIFIED."); } } } /*Fmd[] fmds = new Fmd[ds.Tables[0].Rows.Count]; * for (int i = 0; i < ds.Tables[0].Rows.Count; i++) * { * fmds[0] = Fmd.DeserializeXml(ds.Tables[0].Rows[i]["BIOMETRIC"].ToString());//BIOMETRIC * resultConversion = FeatureExtraction.CreateFmdFromFid(captureResult.Data, Constants.Formats.Fmd.ANSI); * identifyResult = Comparison.Identify(resultConversion.Data, 0, fmds, thresholdScore, dataSetBiometric.Tables[0].Rows.Count); * if (identifyResult.ResultCode == Constants.ResultCode.DP_SUCCESS) * { * MobileNumber = dataSetBiometric.Tables[0].Rows[i]["MOBILE_NUMBER"].ToString(); * Cnic = dataSetBiometric.Tables[0].Rows[i]["CNIC"].ToString(); * break; * } * }*/ //Verificator.Verify(features, Template, ref result); //DPFP.Verification.Verification.Result result2 = new DPFP.Verification.Verification.Result(); // Verificator.Verify(features, Template2, ref result2); //UpdateStatus(result.FARAchieved); // if (result.Verified) // MakeReport("The fingerprint was VERIFIED RIGHT."); //else if (result.Verified) // MakeReport("The fingerprint was VERIFIED LEFT."); //else // MakeReport("The fingerprint was NOT VERIFIED."); } }
public void GetAllFingerprintsAgain(string FingerTable) { Items.Clear(); SqlConnection sqlcon = new SqlConnection(DPData.Database.ConnectionString); SqlCommand cmd; sqlcon.Open(); try { SqlDataReader reader; if (!UseIdentityProcess) { cmd = new SqlCommand("Select Features, FingerID from " + FingerTable + " " + " ", sqlcon); cmd.CommandTimeout = 0; reader = cmd.ExecuteReader(CommandBehavior.Default); while (reader.Read()) { string id = reader["FingerID"].ToString(); DPFP.Template template = new DPFP.Template(); MemoryStream memStreamTemplate = new MemoryStream((byte[])reader["Features"]); template.DeSerialize(memStreamTemplate); Record record = new Record(id, template); Items.Add(record); } } else { // -----------------------------------------------'----------------------------------------------- cmd = new SqlCommand("select Features, FingerID from fingerprints " + " order by fingerID", sqlcon); cmd.CommandTimeout = 0; string CurrentID = ""; string PreviousID = ""; reader = cmd.ExecuteReader(CommandBehavior.Default); DPFP.ID.User Usr; Int16 Fingerposition = 0; DPFP.Template template = new DPFP.Template(); string id; while (reader.Read()) { id = reader["FingerID"].ToString(); CurrentID = id; MemoryStream memStreamTemplate = new MemoryStream((byte[])reader["Features"]); template.DeSerialize(memStreamTemplate); if (PreviousID != CurrentID & PreviousID != "") { UserCollection.AddUser(ref Usr); Fingerposition = 0; } if (PreviousID != CurrentID) { Usr = new DPFP.ID.User(id); } Usr.AddTemplate(template, (FingerPosition)Fingerposition); PreviousID = id; Fingerposition += 1; } if (Usr != null) { UserCollection.AddUser(ref Usr); } cmd.Dispose(); } } catch (Exception ex) { logger.WriteLog(ex); } }
public RecordCollection(Database Owner, string FingerTable, bool _UseIdentityProcess = false, bool AutoLoadData = true, string LoadSql = "") : base(new List <Record>()) { SqlCommand cmd; SqlDataReader reader; UseIdentityProcess = _UseIdentityProcess; try { FTable = FingerTable; if (AutoLoadData) { if (!UseIdentityProcess) { itmG = new List <Record>(255); this.owner = Owner; if (LoadSql == "") { LoadSql = "select Features, FingerID from " + FingerTable + " order by fingerID"; } cmd = new SqlCommand(LoadSql, Owner.Connection); cmd.CommandTimeout = 0; reader = cmd.ExecuteReader(CommandBehavior.Default); string id; Record record; while (reader.Read()) { id = reader["FingerID"].ToString(); MemoryStream memStreamTemplate = new MemoryStream((byte[])reader["Features"]); DPFP.Template template = new DPFP.Template(); template.DeSerialize(memStreamTemplate); record = new Record(id, template); Items.Add(record); } } else { // -----------------------------------------------'----------------------------------------------- if (LoadSql == "") { LoadSql = "select Features, FingerID from " + FingerTable + " order by fingerID"; } if (!LoadSql.ToLower().Contains(" order ")) { LoadSql += " order by fingerID"; } cmd = new SqlCommand(LoadSql, Owner.Connection); cmd.CommandTimeout = 0; string CurrentID = ""; string PreviousID = ""; reader = cmd.ExecuteReader(CommandBehavior.Default); DPFP.ID.User Usr = new User(""); Int16 Fingerposition = 0; DPFP.Template template = new DPFP.Template(); string id; while (reader.Read()) { id = reader["FingerID"].ToString(); if (string.IsNullOrEmpty(id.Trim())) { continue; } CurrentID = id; MemoryStream memStreamTemplate = new MemoryStream((byte[])reader["Features"]); template.DeSerialize(memStreamTemplate); if (PreviousID != CurrentID & PreviousID != "") { UserCollection.AddUser(ref Usr); Fingerposition = 0; } if (PreviousID != CurrentID) { Usr = new DPFP.ID.User(id); } Usr.AddTemplate(template, (FingerPosition)Fingerposition); PreviousID = id; Fingerposition += 1; } if (Usr != null) { UserCollection.AddUser(ref Usr); } } cmd.Dispose(); } } catch (Exception ex) { logger.WriteLog(ex); } }
public RecordCollection(Database Owner, DataTable dt, bool _UseIdentityProcess = false) : base(new List <Record>()) { UseIdentityProcess = _UseIdentityProcess; try { if (!UseIdentityProcess) { itmG = new List <Record>(255); string id; Record record; foreach (DataRow reader in dt.Rows) { id = reader["FingerID"].ToString(); MemoryStream memStreamTemplate = new MemoryStream((byte[])reader["Features"]); DPFP.Template template = new DPFP.Template(); template.DeSerialize(memStreamTemplate); record = new Record(id, template); Items.Add(record); } } else { string CurrentID = ""; string PreviousID = ""; DPFP.ID.User Usr; Int16 Fingerposition = 0; DPFP.Template template = new DPFP.Template(); string id; foreach (DataRow reader in dt.Rows) { id = reader["FingerID"].ToString(); if (string.IsNullOrEmpty(id.Trim())) { continue; } CurrentID = id; MemoryStream memStreamTemplate = new MemoryStream((byte[])reader["Features"]); template.DeSerialize(memStreamTemplate); if (PreviousID != CurrentID & PreviousID != "") { Usr = new User(CurrentID); UserCollection.AddUser(ref Usr); Fingerposition = 0; } if (PreviousID != CurrentID) { Usr = new DPFP.ID.User(id); } Usr.AddTemplate(template, (FingerPosition)Fingerposition); PreviousID = id; Fingerposition += 1; } if (Usr != null) { UserCollection.AddUser(ref Usr); } } } catch (Exception ex) { try { logger.WriteLog(ex); } catch (Exception exx) { } } finally { } }
protected virtual void Process(DPFP.Sample Sample) { // Process the sample and create a feature set for the enrollment purpose. DPFP.FeatureSet features = ExtractFeatures(Sample, DPFP.Processing.DataPurpose.Verification); // Check quality of the sample and start verification if it's good // TODO: move to a separate task if (features != null) { List <Staff> staffs; // Compare the feature set with our template using (ModelContext db = new ModelContext()) { staffs = db.Staffs.ToList(); } Template = new DPFP.Template(); foreach (var staff in staffs) { if (staff.Fingerprint != null) { Template.DeSerialize(staff.Fingerprint); DPFP.Verification.Verification.Result result = new DPFP.Verification.Verification.Result(); Verificator.Verify(features, Template, ref result); if (result.Verified) { verPicBox.Invoke(new Action(() => { verPicBox.ImageLocation = staff.ImageUrl; verPicBox.Visible = true; })); rptLbl.Invoke(new Action(() => rptLbl.Text = $"{staff.Lastname} {staff.Firstname} VERIFIED.")); LogStaff logStaff = new LogStaff(); switch (logStaff.LogAttendance(staff)) { case 0: rptLbl.Invoke(new Action(() => rptLbl.Text = $"{staff.Lastname} {staff.Firstname} already logged.")); break; case 1: rptLbl.Invoke(new Action(() => rptLbl.Text = $"{staff.Lastname} {staff.Firstname} Goodbye!.")); break; case 2: rptLbl.Invoke(new Action(() => rptLbl.Text = $"{staff.Lastname} {staff.Firstname} Welcome!.")); break; default: rptLbl.Invoke(new Action(() => rptLbl.Text = $"error")); break; } ; break; } else { rptLbl.Invoke(new Action(() => rptLbl.Text = "The fingerprint was NOT VERIFIED.")); } } } } }
protected override void Process(DPFP.Sample Sample) { //base.Process(Sample); // Process the sample and create a feature set for the enrollment purpose. DPFP.FeatureSet features = ExtractFeatures(Sample, DPFP.Processing.DataPurpose.Verification); // Check quality of the sample and start verification if it's good // TODO: move to a separate task if (features != null) { // Compare the feature set with our template DPFP.Verification.Verification.Result result = new DPFP.Verification.Verification.Result(); //Indexes , //string connstring = "Host=192.168.100.20;Username=postgres;Password=postgres;Database=Serenity"; string connstring = "Host=localhost;Username=sgeede_fingerprint;Password=;Database=SERENITY_PRODUCTION"; // Making connection with Npgsql provider NpgsqlConnection conn = new NpgsqlConnection(connstring); conn.Open(); string sql = "select id,name_related,fingerprint from hr_employee where is_referral = True and fingerprint is not null;"; // data adapter making request from our connection NpgsqlDataAdapter da = new NpgsqlDataAdapter(sql, conn); string spa_order = ""; using (var cmd = new NpgsqlCommand()) { cmd.Connection = conn; cmd.CommandText = "select id from paid_off_commission_referral_wizard order by id desc limit 1;"; var reader = cmd.ExecuteReader(); while (reader.Read()) { for (int i = 0; i < reader.FieldCount; i++) { spa_order = reader[i].ToString(); } } } ds.Reset(); // filling DataSet with result from NpgsqlDataAdapter da.Fill(ds); // since it C# DataSet can handle multiple tables, we will select first dt = ds.Tables[0]; foreach (DataRow dr in dt.Rows) { byte[] _img = (byte[])dr["fingerprint"]; MemoryStream ms = new MemoryStream(_img); DPFP.Template Template = new DPFP.Template(); Template.DeSerialize(ms); DPFP.Verification.Verification Verificator = new DPFP.Verification.Verification(); base.Process(Sample); DPFP.FeatureSet features2 = ExtractFeatures(Sample, DPFP.Processing.DataPurpose.Verification); if (features2 != null) { DPFP.Verification.Verification.Result result2 = new DPFP.Verification.Verification.Result(); Verificator.Verify(features2, Template, ref result2); UpdateStatus(result2.FARAchieved); if (result2.Verified) { MakeReport("The fingerprint was VERIFIED."); MakeReport(dr["name_related"].ToString()); //MessageBox.Show(spa_order); //MessageBox.Show(dr["name_related"].ToString()); using (var cmd = new NpgsqlCommand()) { cmd.Connection = conn; cmd.CommandText = "update paid_off_commission_referral_wizard set referral_id = (@p) where id = (@q);"; cmd.Parameters.AddWithValue("p", dr["id"]); cmd.Parameters.AddWithValue("q", spa_order); //cmd.Parameters.AddWithValue("p", "Hello world"); cmd.ExecuteNonQuery(); } string message = "Referral is set to "; message += dr["name_related"].ToString(); //MessageBox.Show(message); //confirmation referral = dr["name_related"].ToString(); MakeName(referral); ConfirmationForm Confirmation = new ConfirmationForm(); //Confirmation.Text += message; Confirmation.TopMost = true; Confirmation.ShowDialog(); } else { //MakeReport("The fingerprint was NOT VERIFIED."); } } } } }
//metodo para procesar protected virtual void Process(DPFP.Sample Sample) { #region process byte[] objeto; short consec = 1; DataSet ds = new DataSet(); DPFP.Template Template2; try { // Draw fingerprint sample image. DrawPicture(ConvertSampleToBitmap(Sample)); // Process the sample and create a feature set for the enrollment purpose. DPFP.FeatureSet features = ExtractFeatures(Sample, DPFP.Processing.DataPurpose.Verification); //GENERA BMP DE LA HUELLA //Bitmap huella = ConvertSampleToBitmap(Sample); //huella.Save("c:\\temp\\huellas\\dedoIzq07UareU.bmp"); // Check quality of the sample and start verification if it's good // TODO: move to a separate task if (features != null) { ds = ObtenerTabla(); if (ds == null) { SetStatus("No se pudo optener informaciĆ³n de las huellas registradas."); return; } foreach (DataRow row in ds.Tables[0].Rows) { objeto = (byte[])row["TEMPLATE"]; DPFP.Template comparar = new DPFP.Template(); comparar.DeSerialize(objeto); Template = comparar; #region CODIGO DE PRUEBAS //FileStream fs = new FileStream("C:\\Temp\\huellas\\ansi.dat", FileMode.Open, FileAccess.Read); //objeto = new byte[fs.Length]; //fs.Read(objeto, 0, System.Convert.ToInt32(fs.Length)); //fs.Close(); ////MemoryStream a = new MemoryStream(objeto); //DPFP.Template comparar = new DPFP.Template(); //comparar.DeSerialize(objeto); //Template = comparar; #endregion // Compare the feature set with our template DPFP.Verification.Verification.Result result = new DPFP.Verification.Verification.Result(); if (Template == null) { SetStatus("No se puedo crear el template"); } Verificator.Verify(features, Template, ref result); if (result.Verified) { SetStatus("Identidad Verificada."); capturado = true; identificado = true; if (completo == "1") { estado = row["ESTADO"].ToString(); municipio = row["MUNICIPIO"].ToString(); cereso = row["CERESO"].ToString(); ano = row["ANO"].ToString(); folio = row["FOLIO"].ToString(); } RegistrarDatos(consec); consec++; Stop(); Application.Exit(); } else { capturado = true; identificado = false; } } } } catch (Exception ex) { throw; } Application.Exit(); #endregion }
public void OnComplete(object Control, DPFP.FeatureSet FeatureSet, ref DPFP.Gui.EventHandlerStatus Status) { DPFP.Verification.Verification ver = new DPFP.Verification.Verification(); DPFP.Verification.Verification.Result res = new DPFP.Verification.Verification.Result(); //string conStr = "Data Source=.; Initial Catalog=Registration; Integrated Security=true"; //SqlConnection con = new SqlConnection(conStr); //SqlCommand cmd = new SqlCommand("Select FingerPrintData from FingerPrints where Id = 11", con); //con.Open(); //byte[] userFingerPrintData = new byte[0]; //using (con) //{ // userFingerPrintData = cmd.ExecuteScalar() as byte[]; //} //byte[] fingerPrintCode = new StudentDAC().GetFingerCodeById(2); List<Guardian> guardians = new GuardianDAC().SelectAllGuardians(); if (guardians != null && guardians.Count > 0) { foreach (var item in guardians) { ver = new DPFP.Verification.Verification(); res = new DPFP.Verification.Verification.Result(); DPFP.Template temp = new DPFP.Template(); if (item.FingerCode != null) { temp.DeSerialize(item.FingerCode); if (temp != null) { // Compare feature set with particular template. ver.Verify(FeatureSet, temp, ref res); if (res.Verified) { guardiansTakeAwayForm.guardian = item; this.Close(); break; } } } } } if (!res.Verified) Status = DPFP.Gui.EventHandlerStatus.Failure; }
public static DPFP.Template ProcessDBTemplate(byte[] _data) { DPFP.Template _template = null; Stream _ms = new MemoryStream(_data); _template = new DPFP.Template(); //deserialize _template.DeSerialize(_ms); return _template; }
public void OnComplete(object Control, DPFP.FeatureSet FeatureSet, ref DPFP.Gui.EventHandlerStatus Status) { DPFP.Verification.Verification ver = new DPFP.Verification.Verification(); DPFP.Verification.Verification.Result res = new DPFP.Verification.Verification.Result(); string conStr = "Data Source=.; Initial Catalog=Registration; Integrated Security=true"; SqlConnection con = new SqlConnection(conStr); SqlCommand cmd = new SqlCommand("Select FingerPrintData from FingerPrints where Id = 6", con); con.Open(); byte[] userFingerPrintData = new byte[0]; using (con) { userFingerPrintData = cmd.ExecuteScalar() as byte[]; } DPFP.Template temp = new DPFP.Template(); temp.DeSerialize(userFingerPrintData); if (temp != null) { // Compare feature set with particular template. ver.Verify(FeatureSet, temp, ref res); Data.IsFeatureSetMatched = res.Verified; Data.FalseAcceptRate = res.FARAchieved; } // Compare feature set with all stored templates. foreach (DPFP.Template template in Data.Templates) { // Get template from storage. //if (template != null) { // // Compare feature set with particular template. // ver.Verify(FeatureSet, template, ref res); // Data.IsFeatureSetMatched = res.Verified; // Data.FalseAcceptRate = res.FARAchieved; // if (res.Verified) // break; // success //} } if (!res.Verified) Status = DPFP.Gui.EventHandlerStatus.Failure; Data.Update(); }