/// <summary> /// Extract a fingerprint template from a raw fingerprint image /// </summary> /// <param name="image">The image to extract the template from</param> /// <returns></returns> public FingerprintTemplate ExtractTemplate(FingerprintRawImage image) { var template = new FingerprintTemplate(); griauleLibrary.ExtractEx(image, ref template, (GrTemplateFormat)DefaultTemplateFormat); return(template); }
/// <summary> /// Convert System.Drawing.Image to FingerprintTemplate /// </summary> /// <param name="image">image to convert</param> /// <returns>raw image from image</returns> private FingerprintRawImage RawImageFromImage(Image image) { FingerprintRawImage retRawImage = new FingerprintRawImage(); Bitmap bitmapTemp = image as Bitmap; #region paranoia section if (image.Height > Settings.Default.maxImageHeight) { throw new ArgumentOutOfRangeException("image.Height"); } if (image.Width > Settings.Default.maxImageWidth) { throw new ArgumentOutOfRangeException("image.Width"); } #endregion retRawImage.rawImage = new byte[bitmapTemp.Width * bitmapTemp.Height]; for (int y = 0; y < bitmapTemp.Height; y++) { for (int x = 0; x < bitmapTemp.Width; x++) { retRawImage.rawImage[y * bitmapTemp.Width + x] = bitmapTemp.GetPixel(x, y).R; } } retRawImage.width = bitmapTemp.Width; retRawImage.height = bitmapTemp.Height; // Oh, shi~ This f*cken SDK use resolution of scaner, but not image >_< retRawImage.res = Settings.Default.scanerResolution; return(retRawImage); }
public GrEnrollState Enroll(FingerprintRawImage rawImage, ref FingerprintTemplate tpt, GrTemplateFormat tptFormat, int context) { GrEnrollState state; IntPtr zero = IntPtr.Zero; try { int num = 0; int quality = -1; int cb = 0x2710 * Marshal.SizeOf(typeof(byte)); zero = Marshal.AllocHGlobal(cb); IntPtr destination = Marshal.AllocCoTaskMem(rawImage.Width * rawImage.Height); Marshal.Copy(rawImage.RawImage, 0, destination, rawImage.Width * rawImage.Height); num = this.Enroll(destination, rawImage.Width, rawImage.Height, rawImage.Resolution, zero, ref cb, ref quality, (int)tptFormat, context); Marshal.FreeCoTaskMem(destination); zero = Marshal.ReAllocHGlobal(zero, (IntPtr)cb); tpt = new FingerprintTemplate(zero, cb, quality); state = (GrEnrollState)num; } catch (OutOfMemoryException exception) { throw new FingerprintException(-7, exception); } catch (AccessViolationException exception2) { throw new FingerprintException(-113, exception2); } finally { Marshal.FreeHGlobal(zero); } return(state); }
void OnImageFingerprint(object source, ImageEventArgs ie) { rawImage = ie.RawImage; SetImage(ie.RawImage.Image); ExtractTemplate(); }
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 FingerprintTemplate ExtractTemplate(FingerprintRawImage rawImage, int contextId) { FingerprintTemplate _tmpTemplate = null; GriauleCore.ExtractEx(rawImage, ref _tmpTemplate, contextId, GrTemplateFormat.GR_FORMAT_ISO); return(_tmpTemplate); }
/// <summary> /// Verification /// </summary> /// <param name="fingerprint">image of fingerprint to verify</param> /// <param name="card">card</param> /// <returns>true if success, otherwise false</returns> public bool Verify(Image fingerprint, FingerprintCard card) { // The best verification score reached int maxScore = 0; #region paranoia section if (fingerprint == null) { throw new ArgumentNullException("fingerprint"); } if (card == null) { throw new ArgumentNullException("card"); } if (card.FingerprintList == null) { throw new ArgumentNullException("card.FingerprintList"); } if (card.FingerprintList.Count == 0) { throw new ArgumentOutOfRangeException("card.FingerprintList.Count"); } #endregion FingerprintTemplate templateToVerify; FingerprintRawImage rawImageToVerify = RawImageFromImage(fingerprint); templateToVerify = ExtractTemplate(rawImageToVerify); foreach (Image tempImage in card.FingerprintList) { FingerprintTemplate templateTemp; FingerprintRawImage rawImageTemp = RawImageFromImage(tempImage); templateTemp = ExtractTemplate(rawImageTemp); int result; fingerPrintCore.Verify(templateToVerify, templateTemp, out result); if (result > maxScore) { maxScore = result; } } // If success... if (maxScore >= Settings.Default.GriauleMatcherMinScoreToSuccessVerify) { return(true); } // If failed... return(false); }
private FingerprintRawImage ConvertTemplate(byte[] rawFingerprint) { IntPtr _tmpRawImg = Marshal.AllocHGlobal(rawFingerprint.Length); Marshal.Copy(rawFingerprint, 0, _tmpRawImg, rawFingerprint.Length); FingerprintRawImage _rawImg = new FingerprintRawImage(_tmpRawImg, DEFAULT_IMAGE_WIDTH, DEFAULT_IMAGE_HEIGHT, FingerprintConstants.GR_DEFAULT_RES); Marshal.FreeHGlobal(_tmpRawImg); return(_rawImg); }
private void DisplayImage(FingerprintTemplate template, FingerprintRawImage rawImage) { IntPtr hdc = FingerprintCore.GetDC(); IntPtr image = new IntPtr(); FPCore.GetBiometricDisplay(template, rawImage, hdc, ref image, FingerprintConstants.GR_NO_CONTEXT); SetBMapImage(Bitmap.FromHbitmap(image)); FingerprintCore.ReleaseDC(hdc); }
public bool IdentifyPrepareRaw(byte[] toRawMatch, int contextId) { FingerprintRawImage _fpRawImg = ConvertTemplate(toRawMatch); if (_fpRawImg != null) { var template = ExtractTemplate(_fpRawImg, contextId); GriauleCore.IdentifyPrepare(template, contextId); return(true); } return(false); }
public void SaveRawImageToFile(FingerprintRawImage rawImage, string fileName, GrCaptureImageFormat imageFormat) { try { IntPtr destination = Marshal.AllocCoTaskMem(rawImage.Width * rawImage.Height); Marshal.Copy(rawImage.RawImage, 0, destination, rawImage.Width * rawImage.Height); this.SaveRawImageToFile(destination, rawImage.Width, rawImage.Height, fileName, imageFormat); Marshal.FreeCoTaskMem(destination); } catch (OutOfMemoryException exception) { FingerprintException exception2 = new FingerprintException(-7, exception); throw exception2; } }
public void GetHandlerFromRawImage(FingerprintRawImage rawImage, IntPtr hdc, ref IntPtr image) { try { IntPtr destination = Marshal.AllocCoTaskMem(rawImage.Width * rawImage.Height); Marshal.Copy(rawImage.RawImage, 0, destination, rawImage.Width * rawImage.Height); this.GetHandlerFromRawImage(destination, rawImage.Width, rawImage.Height, hdc, ref image); Marshal.FreeCoTaskMem(destination); } catch (OutOfMemoryException exception) { FingerprintException exception2 = new FingerprintException(-7, exception); throw exception2; } }
public void GetBiometricDisplay(FingerprintTemplate tptQuery, FingerprintRawImage rawImage, IntPtr hdc, ref IntPtr handle, int matchContext) { try { IntPtr destination = Marshal.AllocCoTaskMem(rawImage.Width * rawImage.Height); Marshal.Copy(rawImage.RawImage, 0, destination, rawImage.Width * rawImage.Height); this.GetBiometricDisplay(tptQuery, destination, rawImage.Width, rawImage.Height, rawImage.Resolution, hdc, ref handle, matchContext); Marshal.FreeCoTaskMem(destination); } catch (OutOfMemoryException exception) { FingerprintException exception2 = new FingerprintException(-7, exception); throw exception2; } }
public void ExtractEx(FingerprintRawImage fingerPrintRawImage, ref FingerprintTemplate fingerTemplate, int context, GrTemplateFormat tptFormat) { try { IntPtr destination = Marshal.AllocCoTaskMem(fingerPrintRawImage.Width * fingerPrintRawImage.Height); Marshal.Copy(fingerPrintRawImage.RawImage, 0, destination, fingerPrintRawImage.Width * fingerPrintRawImage.Height); this.ExtractEx(destination, fingerPrintRawImage.Width, fingerPrintRawImage.Height, fingerPrintRawImage.Resolution, ref fingerTemplate, context, (int)tptFormat); Marshal.FreeCoTaskMem(destination); } catch (OutOfMemoryException exception) { FingerprintException exception2 = new FingerprintException(-7, exception); throw exception2; } }
/// <summary> /// Extract template from rawImage /// </summary> /// <param name="rawImage">1-byte per pixel raw image</param> /// <returns>template if success, otherwise it throws exception</returns> private FingerprintTemplate ExtractTemplate(FingerprintRawImage rawImage) { FingerprintTemplate tmpTemplate; // if template already stored in cache if (templateCache.TryGetValue(rawImage, out tmpTemplate)) { return(tmpTemplate); } // otherwise extract template and store it try { tmpTemplate = null; fingerPrintCore.Extract(rawImage, ref tmpTemplate); templateCache.Add(rawImage, tmpTemplate); return(tmpTemplate); } catch { throw new Exception("Unable to extract template!"); } }
public void ExtractEx(FingerprintRawImage fingerPrintRawImage, ref FingerprintTemplate fingerTemplate, GrTemplateFormat tptFormat) { this.ExtractEx(fingerPrintRawImage, ref fingerTemplate, 0, tptFormat); }
public void Extract(FingerprintRawImage fingerPrintRawImage, ref FingerprintTemplate fingerTemplate) { this.Extract(fingerPrintRawImage, ref fingerTemplate, 0); }
public GrEnrollState Enroll(FingerprintRawImage rawImage, ref FingerprintTemplate tpt, GrTemplateFormat tptFormat) { return(this.Enroll(rawImage, ref tpt, tptFormat, 0)); }
public ImageEventArgs(string source, IntPtr rawImage, int width, int height, int res) { this.source = source; this.tRawImage = new FingerprintRawImage(rawImage, width, height, res); }