public static WinBioIdentity AddEnrollment(WinBioSessionHandle session, int unitId, WinBioBiometricSubType subType) { Console.WriteLine("Beginning enrollment of {0}:", subType); WinBio.EnrollBegin(session, subType, unitId); var code = WinBioErrorCode.MoreData; for (var swipes = 1; code != WinBioErrorCode.Ok; swipes++) { WinBioRejectDetail rejectDetail; code = WinBio.EnrollCapture(session, out rejectDetail); switch (code) { case WinBioErrorCode.MoreData: Console.WriteLine("Swipe {0} was good", swipes); break; case WinBioErrorCode.BadCapture: Console.WriteLine("Swipe {0} was bad: {1}", swipes, rejectDetail); break; case WinBioErrorCode.Ok: Console.WriteLine("Enrollment complete with {0} swipes", swipes); break; default: throw new WinBioException(code, "WinBioEnrollCapture failed"); } } Console.WriteLine("Committing enrollment.."); WinBioIdentity identity; var isNewTemplate = WinBio.EnrollCommit(session, out identity); Console.WriteLine(isNewTemplate ? "New template committed." : "Template already existing."); return identity; }
private static extern WinBioErrorCode Verify( WinBioSessionHandle sessionHandle, IntPtr identity, WinBioBiometricSubType subFactor, out int unitId, out bool match, out WinBioRejectDetail rejectDetail);
public static void DeleteTemplate( WinBioSessionHandle sessionHandle, int unitId, WinBioIdentity identity, WinBioBiometricSubType subFactor) { var handle = GCHandle.Alloc(identity.GetBytes(), GCHandleType.Pinned); try { var code = DeleteTemplate(sessionHandle, unitId, handle.AddrOfPinnedObject(), subFactor); WinBioException.ThrowOnError(code, "WinBioDeleteTemplate failed"); } finally { handle.Free(); } }
private void buttonEnroll_Click(object sender, EventArgs e) { WinBioBiometricSubType subType = (WinBioBiometricSubType)comboBoxFp.SelectedIndex; if (subType == WinBioBiometricSubType.Unknown) { Log("Please select a finger index, not Unknown."); return; } ThreadPool.QueueUserWorkItem(delegate { try { Log("Put your finger on sensor..."); WinBioBiometricSubType subFactor; WinBioRejectDetail rejectDetail; while (true) { _unitId = WinBio.Identify(_session, out _identity, out subFactor, out rejectDetail); Log("No. This finger has been enrolled before. Change another one..."); } } catch (WinBioException ex) { Log("OK. This finger not yet be enrolled before."); } try { _identity = AddEnrollment(_session, _unitId, subType); Log(string.Format("Identity: {0}", _identity)); } catch (WinBioException ex) { Log(ex); if (ex.ErrorCode == WinBioErrorCode.DuplicateEnrollment) { Log(string.Format("Please select another finger index or just delete it for a new one.")); } } }); }
public static bool Verify( WinBioSessionHandle sessionHandle, WinBioIdentity identity, WinBioBiometricSubType subFactor, out int unitId, out WinBioRejectDetail rejectDetail) { bool match; var handle = GCHandle.Alloc(identity.GetBytes(), GCHandleType.Pinned); try { var code = Verify(sessionHandle, handle.AddrOfPinnedObject(), subFactor, out unitId, out match, out rejectDetail); WinBioException.ThrowOnError(code, "WinBioVerify failed"); } finally { handle.Free(); } return(match); }
public static int Identify( WinBioSessionHandle sessionHandle, out WinBioIdentity identity, out WinBioBiometricSubType subFactor, out WinBioRejectDetail rejectDetail) { int unitId; var bytes = new byte[WinBioIdentity.Size]; var handle = GCHandle.Alloc(bytes, GCHandleType.Pinned); try { var code = Identify(sessionHandle, out unitId, handle.AddrOfPinnedObject(), out subFactor, out rejectDetail); WinBioException.ThrowOnError(code, "WinBioIdentify failed"); } finally { handle.Free(); } identity = new WinBioIdentity(bytes); return(unitId); }
private static extern WinBioErrorCode DeleteTemplate( WinBioSessionHandle sessionHandle, int unitId, IntPtr identity, WinBioBiometricSubType subFactor);
public static void EnrollBegin(WinBioSessionHandle sessionHandle, WinBioBiometricSubType subType, int unitId) { var code = WinBioEnrollBegin(sessionHandle, subType, unitId); WinBioException.ThrowOnError(code, "WinBioEnrollBegin failed"); }
private extern static WinBioErrorCode WinBioEnrollBegin(WinBioSessionHandle sessionHandle, WinBioBiometricSubType subType, int unitId);
private extern static WinBioErrorCode Identify( WinBioSessionHandle sessionHandle, out int unitId, IntPtr identity, out WinBioBiometricSubType subFactor, out WinBioRejectDetail rejectDetail);
private WinBioIdentity AddEnrollment(WinBioSessionHandle session, int unitId, WinBioBiometricSubType subType) { Log(string.Format("Beginning enrollment of {0}:", subType)); WinBio.EnrollBegin(session, subType, unitId); var code = WinBioErrorCode.MoreData; for (var swipes = 1; code != WinBioErrorCode.Ok; swipes++) { WinBioRejectDetail rejectDetail; code = WinBio.EnrollCapture(session, out rejectDetail); switch (code) { case WinBioErrorCode.MoreData: Log(string.Format("Swipe {0} was good", swipes)); break; case WinBioErrorCode.BadCapture: Log(string.Format("Swipe {0} was bad: {1}", swipes, rejectDetail)); break; case WinBioErrorCode.Ok: Log(string.Format("Enrollment complete with {0} swipes", swipes)); break; default: throw new WinBioException(code, "WinBioEnrollCapture failed"); } } Log(string.Format("Committing enrollment..")); WinBioIdentity identity; var isNewTemplate = WinBio.EnrollCommit(session, out identity); Log(string.Format(isNewTemplate ? "New template committed." : "Template already existing.")); return(identity); }
private WinBioIdentity AddEnrollment(WinBioSessionHandle session, int unitId, WinBioBiometricSubType subType) { WriteLog(string.Format("Beginning enrollment of {0}:", subType)); WinBio.EnrollBegin(session, subType, unitId); var code = WinBioErrorCode.MoreData; WinBioRejectDetail rejectDetail; int good = 0; for (var swipes = 1; code != WinBioErrorCode.Ok; swipes++) { code = WinBio.EnrollCapture(session, out rejectDetail); switch (code) { case WinBioErrorCode.MoreData: WriteLog(string.Format("Swipe {0} was good", swipes)); good++; break; case WinBioErrorCode.BadCapture: WriteLog(string.Format("Swipe {0} was bad: {1}", swipes, rejectDetail)); break; case WinBioErrorCode.Ok: WriteLog(string.Format("Enrollment complete with {0} swipes", swipes)); break; default: throw new WinBioException(code, "WinBioEnrollCapture failed"); } Progress(good); } WriteLog("Committing enrollment.."); bool isNewTemplate; WinBioIdentity identity = null; try { isNewTemplate = WinBio.EnrollCommit(session, out identity); WriteLog(isNewTemplate ? "New template committed." : "Template already existing."); if (!isNewTemplate) { WinBio.Identify(session, out identity, out subType, out rejectDetail); } EnableDisableOk(true); } catch (Exception e) { WriteLog("Error on AddEnrollment. Error:" + e.Message); } return(identity); }