// ----------------------------------------------------------------------------------- // Main functions for fingerprint recognition management // ----------------------------------------------------------------------------------- // Initializes GrFinger ActiveX and all necessary utilities. public int InitializeGrFinger()//GrFingerXLib.GrFingerXCtrl grfingerx) { int result = 0; axGrFingerXCtrl = new GrFingerXCtrl(); //axGrFingerXCtrl = grfingerx; ////Create a new Template if (FPTemplate == null) { FPTemplate = new FingerPrintTemplate(); } ////Create a new raw image RawFPImg = new RawFingerPrintImage(); //Initialize library result = axGrFingerXCtrl.Initialize(); if (result < 0) { return(result); } //return (int)axGrFingerXCtrl.CapInitialize(); return(0); }
// Identify current fingerprint on our database public long Identify(ref int score) { GRConstants result; FingerPrintTemplate tptRef; // Checking if template is valid. if (!TemplateIsValid()) { return((long)ERR_INVALID_TEMPLATE); } // Starting identification process and supplying query template. result = (GRConstants)axGrFingerXCtrl.IdentifyPrepare(ref FPTemplate.ImageData, (int)GRConstants.GR_DEFAULT_CONTEXT); // error? if (result < 0) { return((long)result); } // Getting enrolled templates from database. var cmd = "SELECT [MemberFingerPrintID],[MemberID],[FingerPrint1],[FingerPrint2] FROM [MemberFingerPrints]"; using (var r = SqlHelper.ExecuteReader(cmd)) { while (r.Read()) { long readBytes; byte[] temp; if (!r.IsDBNull(2)) { temp = new byte[10000]; readBytes = r.GetBytes(2, 0, temp, 0, temp.Length); tptRef = new FingerPrintTemplate(); System.Array.Copy(temp, 0, tptRef.ImageData, 0, (int)readBytes); // Comparing current template. result = (GRConstants)axGrFingerXCtrl.Identify(ref tptRef.ImageData, ref score, (int)GRConstants.GR_DEFAULT_CONTEXT); // Checking if query template and the reference template match. if (result == GRConstants.GR_MATCH) { //memFP.MemberFingerPrintID = ds.DataReader.GetInt64(0); //memFP.MemberID = ds.DataReader.GetInt64(1); //ds.Dispose(); return(-1); //memFP.MemberID; } } if (!r.IsDBNull(3)) { temp = new byte[10000]; readBytes = r.GetBytes(3, 0, temp, 0, temp.Length); tptRef = new FingerPrintTemplate(); System.Array.Copy(temp, 0, tptRef.ImageData, 0, (int)readBytes); result = (GRConstants)axGrFingerXCtrl.Identify(ref tptRef.ImageData, ref score, (int)GRConstants.GR_DEFAULT_CONTEXT); if (result == GRConstants.GR_MATCH) { //memFP.MemberFingerPrintID = ds.DataReader.GetInt64(0); //memFP.MemberID = ds.DataReader.GetInt64(1); //ds.Dispose(); return(-1); //memFP.MemberID; } } } } //ds.Dispose(); // Closing recordset. return((long)GRConstants.GR_NOT_MATCH); }