private void Identify() { GriauleFingerprintLibrary.DataTypes.FingerprintTemplate testTemplate = null; try { if ((_template != null) && (_template.Size > 0)) { fingerPrint.IdentifyPrepare(_template); IGRDal dl = DalFactory.GetDal(GrConnector.AccessDal); IDataReader dataReader = dl.GetTemplates(); using (dataReader) { while (dataReader.Read()) { int tempId = Convert.ToInt32(dataReader["ID"]); byte[] buff = (byte[])dataReader["template"]; int quality = Convert.ToInt32(dataReader["quality"]); testTemplate = new GriauleFingerprintLibrary.DataTypes.FingerprintTemplate(); testTemplate.Size = buff.Length; testTemplate.Buffer = buff; testTemplate.Quality = quality; int score; if (Identify(testTemplate, out score)) { SetMatchBar(score, Color.SeaGreen); SetStatusMessage("Template Matched"); DisplayImage(_template, true); return; } else { SetMatchBar(score, Color.LightCoral); SetStatusMessage("Template Unmatched"); } } SetMatchBar(0, Color.Gray); SetStatusMessage("Template Unmatched"); } } } catch (FingerprintException ge) { if (ge.ErrorCode == -8) { System.IO.FileStream dumpTemplate = System.IO.File.Create(@".\Dumptemplate.gt"); System.IO.StreamWriter stWriter = new System.IO.StreamWriter(dumpTemplate); stWriter.WriteLine(BitConverter.ToString(testTemplate.Buffer, 0)); stWriter.Close(); } } catch { } }
void refFingercore_onImage(object source, GriauleFingerprintLibrary.Events.ImageEventArgs ie) { rawImage = ie.RawImage; SetImage(ie.RawImage.Image); stepCount++; //ExtractTemplate(); try { _template = new GriauleFingerprintLibrary.DataTypes.FingerprintTemplate(); int ret = (int)refFingercore.Enroll(ie.RawImage, ref _template, GrTemplateFormat.GR_FORMAT_DEFAULT, FingerprintConstants.GR_DEFAULT_CONTEXT); if (ret >= FingerprintConstants.GR_ENROLL_SUFFICIENT) { //IGRDal dl = DalFactory.GetDal(GrConnector.AccessDal); //dl.SaveTemplate(template); if (ret == FingerprintConstants.GR_ENROLL_SUFFICIENT) { SetStatusMessage("Sufficient quality value."); PerformStep(QualityTemplate.SUF, Color.YellowGreen); } else if (ret == FingerprintConstants.GR_ENROLL_GOOD) { SetStatusMessage("Good quality value."); PerformStep(QualityTemplate.GOOD, Color.MediumSeaGreen); } else if (ret == FingerprintConstants.GR_ENROLL_VERY_GOOD) { IGRDal dl = DalFactory.GetDal(GrConnector.AccessDal); dl.SaveTemplate(_template); PerformStep(QualityTemplate.VERYGOOD, Color.SeaGreen); this.DialogResult = DialogResult.OK; this.Close(); } else if (ret == FingerprintConstants.GR_ENROLL_MAX_LIMIT_REACHED) { IGRDal dl = DalFactory.GetDal(GrConnector.AccessDal); dl.SaveTemplate(_template); this.DialogResult = DialogResult.OK; this.Close(); } EnableOk(); } else { // WriteLog("The Template does not reach a good quality value"); SetStatusMessage("Please put your finger again"); PerformStep(QualityTemplate.INSF, Color.LightCoral); } } catch { } System.Threading.Thread.Sleep(100); }
private void enrollToolStripMenuItem1_Click(object sender, EventArgs e) { try { if (_template == null) { MessageBox.Show("Error, Null template"); return; } IGRDal dl = DalFactory.GetDal(GrConnector.AccessDal); dl.SaveTemplate(_template); } catch { } }
private void button2_Click(object sender, EventArgs e) { VerifyDialog verify = new VerifyDialog(); if (verify.ShowDialog(this) == DialogResult.OK) { int verifyCode = Convert.ToInt32(verify.VerifyCode); if ((_template != null) && (_template.Size > 0)) { try { fingerPrint.IdentifyPrepare(_template); IGRDal dl = DalFactory.GetDal(GrConnector.AccessDal); IDataReader dataReader = dl.GetTemplate(verifyCode); using (dataReader) { while (dataReader.Read()) { int tempId = Convert.ToInt32(dataReader["ID"]); byte[] buff = (byte[])dataReader["template"]; GriauleFingerprintLibrary.DataTypes.FingerprintTemplate testTemplate = new GriauleFingerprintLibrary.DataTypes.FingerprintTemplate(); testTemplate.Size = buff.Length; testTemplate.Buffer = buff; int score; if (Identify(testTemplate, out score)) { // WriteLog(string.Format("Fingerprint matched, ID:{0} - Score: {1}", tempId, score)); DisplayImage(_template, true); return; } } // WriteLog("Fingerprint not found."); } } catch { } } else { // WriteLog("Must acquire a finger print image and extract a template, before verify within the database"); } } }
private void btnOk_Click(object sender, EventArgs e) { try { IGRDal dl = DalFactory.GetDal(GrConnector.AccessDal); dl.SaveTemplate(_template); this.DialogResult = DialogResult.OK; this.Close(); } catch { this.DialogResult = DialogResult.Abort; this.Close(); } }
private void clearDBToolStripMenuItem_Click(object sender, EventArgs e) { IGRDal dl = DalFactory.GetDal(GrConnector.AccessDal); dl.DeleteTemplate(); }