public bool CheckIfReaderIsOnline(CaptureResult captureResult, Reader activeReader) { if (captureResult.ResultCode == Constants.ResultCode.DP_FAILURE || captureResult.ResultCode == Constants.ResultCode.DP_INVALID_DEVICE) { Constants.ResultCode test = activeReader.GetStatus(); if (test == Constants.ResultCode.DP_INVALID_DEVICE) { Id = Id + "FAILED"; Ambassador.AddMessage(new MSignal(this, MSignal.SIGNAL.DEVICE_FAILURE)); Console.WriteLine(captureResult.ResultCode); return(false); } } return(true); }
private void deviceThread() { STATE state = STATE.IDLE; COMMAND com = COMMAND.NONE; List <FingerTemplate> templates = new List <FingerTemplate>(); byte[] image = null; Int32 iError = 1; int enrollCount = 0; int quality = 50; iError = m_FPM.Init(devName); iError = m_FPM.OpenDevice(devId); GetInfo(); try { while (true) { cancelToken.Token.ThrowIfCancellationRequested(); if (state == STATE.IDLE) { com = queue.Take(cancelToken.Token); } else { // non blocking take if (queue.Count > 0) { com = queue.Take(); } } switch (com) { case COMMAND.LIVECAPTURE_START: state = STATE.TEST; break; case COMMAND.ENROLLMENT_START: state = STATE.GETFINGER; enrollCount = 0; templates.Clear(); break; case COMMAND.SINGLECAPTURE_START: state = STATE.GETSINGLE; break; case COMMAND.SINGLECAPTURE_STOP: case COMMAND.LIVECAPTURE_STOP: case COMMAND.ENROLLMENT_STOP: state = STATE.IDLE; break; } com = COMMAND.NONE; switch (state) { case STATE.TEST: SendBaseMessage("Please, touch the scanner"); // iError = m_FPM.SetLedOn(false); image = new Byte[m_ImageWidth * m_ImageHeight]; try { iError = m_FPM.GetImageEx(image, TIMEOUT_CAPTURE, 0, ENROLL_QUALITY); } catch (Exception ex) { } if (iError == (Int32)SGFPMError.ERROR_NONE) { OnBiometricsCaptured(new FingerImageSG(_BSPCode, image, m_ImageWidth, m_ImageHeight)); } else if (iError == (Int32)SGFPMError.ERROR_TIME_OUT) { OnBiometricsCaptured(null); Thread.Sleep(TIMEOUT_AFTER_CAPTURE); } else if ((iError != (Int32)SGFPMError.ERROR_INVALID_PARAM) && (iError != (Int32)SGFPMError.ERROR_LINE_DROPPED)) { state = STATE.OFFLINE; Ambassador.AddMessage(new MSignal(this, MSignal.SIGNAL.DEVICE_FAILURE)); } break; case STATE.GETSINGLE: SendBaseMessage("Please, touch the scanner"); image = new Byte[m_ImageWidth * m_ImageHeight]; state = STATE.GETSINGLEIMAGE; break; case STATE.GETSINGLEIMAGE: // iError = m_FPM.SetLedOn(false); image = new Byte[m_ImageWidth * m_ImageHeight]; iError = m_FPM.GetImageEx(image,TIMEOUT_CAPTURE,0,ENROLL_QUALITY); if (iError == 0) { OnSingleCaptured(new FingerImageSG(_BSPCode,image,m_ImageWidth,m_ImageHeight)); image = new Byte[m_ImageWidth * m_ImageHeight]; state = STATE.SINGLELIFT; } else if (iError == (Int32)SGFPMError.ERROR_TIME_OUT) { Thread.Sleep(TIMEOUT_AFTER_CAPTURE); } else if ((iError != (Int32)SGFPMError.ERROR_INVALID_PARAM) && (iError != (Int32)SGFPMError.ERROR_LINE_DROPPED)) { state = STATE.OFFLINE; Ambassador.AddMessage(new MSignal(this,MSignal.SIGNAL.DEVICE_FAILURE)); } break; case STATE.SINGLELIFT: // iError = m_FPM.SetLedOn(false); iError = m_FPM.GetImageEx(image,10,0,ENROLL_QUALITY); if (iError != 0) { state = STATE.GETSINGLE; } else { Thread.Sleep(TIMEOUT_AFTER_CAPTURE); } break; case STATE.GETFINGER: SendBaseMessage("Please, touch the scanner"); image = new Byte[m_ImageWidth * m_ImageHeight]; state = STATE.GETIMAGE; break; case STATE.GETIMAGE: // iError = m_FPM.SetLedOn(false); iError = m_FPM.GetImageEx(image,10,0,ENROLL_QUALITY); if (iError == 0) { enrollCount++; FingerImageSG fingerImage = new FingerImageSG(_BSPCode,image,m_ImageWidth,m_ImageHeight); TemplateSG tmpl = Extract(fingerImage) as TemplateSG; templates.Add(tmpl); OnBiometricsCaptured(fingerImage); OnSendProgressMessage((enrollCount) * 33); if (enrollCount < 3) { state = STATE.GETEMPTY; } else { state = STATE.FINISHENROLL; } } else if (iError == (Int32)SGFPMError.ERROR_TIME_OUT) { Thread.Sleep(TIMEOUT_AFTER_CAPTURE); } else if ((iError != (Int32)SGFPMError.ERROR_INVALID_PARAM) && (iError != (Int32)SGFPMError.ERROR_LINE_DROPPED)) { state = STATE.OFFLINE; Ambassador.AddMessage(new MSignal(this,MSignal.SIGNAL.DEVICE_FAILURE)); } break; case STATE.GETEMPTY: SendBaseMessage("Please, lift your finger up"); image = new Byte[m_ImageWidth * m_ImageHeight]; state = STATE.GETEMPTYIMAGE; break; case STATE.GETEMPTYIMAGE: // iError = m_FPM.SetLedOn(false); iError = m_FPM.GetImageEx(image,10,0,ENROLL_QUALITY); if (iError != 0) { state = STATE.GETFINGER; } else { Thread.Sleep(TIMEOUT_AFTER_CAPTURE); } break; case STATE.FINISHENROLL: state = STATE.IDLE; foreach (var template in templates) { bool matched = false; m_FPM.MatchTemplate((template as TemplateSG).Bytes,(templates[templates.Count - 1] as TemplateSG).Bytes,SGFPMSecurityLevel.NORMAL,ref matched); if (!matched) { SendPopUpMessage("Can't create template, please repeat"); OnBiometricsEnrolled(null); OnSendProgressMessage(0); } OnSendProgressMessage(100); } SendPopUpMessage("Successfully registered"); OnBiometricsEnrolled(templates.ToList()); // return new copy of list break; default: break; } } } catch (Exception ex) { log.Error(ex.Message); m_FPM.CloseDevice(); } }
private void OnSingleCaptured(FingerImageSG image) { Ambassador.AddMessage(new MBiometricsSingleCaptured(this, image)); }
private void OnBiometricsEnrolled(List <FingerTemplate> templates) { Ambassador.AddMessage(new MBiometricsEnrolled(this, templates)); }
private void OnSendProgressMessage(int progress) { Ambassador.AddMessage(MUpdateProgress.Set(this, progress)); }
private void SendPopUpMessage(String msg) { Ambassador.AddMessage(new MShowText(this, msg, MShowText.TYPE.POPUP)); }
private void SendBaseMessage(String msg) { Ambassador.AddMessage(new MShowText(this, msg)); }
private void OnBiometricsCaptured(FingerImage image) { Ambassador.AddMessage(new MBiometricsLiveCaptured(this, image)); }
private void deviceThread() { STATE state = STATE.IDLE; COMMAND com = COMMAND.NONE; byte[] image = null; byte[][] resultFeat = null; byte[][] imageStack = null; byte[][] FingerFeat = null; int firstEnrollCount = 0, secondEnrollCount = 0; int status = 0; BioNetACSDLL._AlgoInit(); Thread.Sleep(1000); var error = BioNetACSDLL._OpenNetAccessDeviceByUSN(name); if (error != 1) { throw new Exception("Can't open device"); } int uniqueUsbKey = BioNetACSDLL._GetUSBKey(); int imageSize = BioNetACSDLL._GetImgSize(); int imageWidth = BioNetACSDLL._GetImgWidth(); int imageHeight = BioNetACSDLL._GetImgSize() / BioNetACSDLL._GetImgWidth(); FingerFeat = new byte[MAX_FEATURE][]; for (int i = 0; i < MAX_FEATURE; i++) { FingerFeat[i] = new byte[BioNetACSDLL._GetFeatSize()]; } try { while (true) { cancelToken.Token.ThrowIfCancellationRequested(); if (state == STATE.IDLE) { com = queue.Take(cancelToken.Token); } else { // non blocking take if (queue.Count > 0) { com = queue.Take(); } } switch (com) { case COMMAND.LIVECAPTURE_START: state = STATE.TEST; break; case COMMAND.SINGLECAPTURE_START: state = STATE.GETSINGLE; break; case COMMAND.ENROLLMENT_START: state = STATE.GETFINGER_1; resultFeat = new byte[2][]; for (int i = 0; i < 2; i++) { resultFeat[i] = new byte[BioNetACSDLL._GetFeatSize()]; } imageStack = new byte[ENROLL_IMAGES * 2][]; for (int i = 0; i < ENROLL_IMAGES * 2; i++) { imageStack[i] = new byte[imageSize]; } firstEnrollCount = 0; secondEnrollCount = 0; resultBios.Clear(); break; case COMMAND.LIVECAPTURE_STOP: case COMMAND.SINGLECAPTURE_STOP: case COMMAND.ENROLLMENT_STOP: state = STATE.IDLE; break; } com = COMMAND.NONE; if (uniqueUsbKey != BioNetACSDLL._GetUSBKey()) { if (state != STATE.OFFLINE) { state = STATE.OFFLINE; Ambassador.AddMessage(new MSignal(this, MSignal.SIGNAL.DEVICE_FAILURE)); } } switch (state) { case STATE.TEST: image = new byte[imageSize]; status = BioNetACSDLL._GetNetAccessImage(image); switch (status) { // not connected case -1: state = STATE.OFFLINE; SendBaseMessage("Scanner is not connected"); break; case 0: SendBaseMessage("Please, touch the scanner"); break; default: break; } OnBiometricsCaptured(new FingerImageIB(image,imageWidth,imageHeight)); break; case STATE.GETSINGLE: SendBaseMessage("Please, touch the scanner"); image = new byte[imageSize]; status = BioNetACSDLL._GetNetAccessImage(image); switch (status) { // not connected case -1: SendPopUpMessage("Scanner is not connected"); break; case 0: break; case 1: int qual = BioNetACSDLL._GetIBQualityScore(image); if (qual > NEEDED_QUALITY) { goto default; } SendPopUpMessage("Image quality " + qual + " not enough, keep finger on scanner"); OnBiometricsCaptured(new FingerImageIB(image,imageWidth,imageHeight)); break; default: OnSingleCaptured(new FingerImageIB(image,imageWidth,imageHeight)); state = STATE.LIFTSINGLE; break; } break; case STATE.LIFTSINGLE: image = new byte[imageSize]; status = BioNetACSDLL._GetNetAccessImage(image); BioNetACSDLL._ControlTOUCH(false); switch (status) { // not connected case -1: SendPopUpMessage("Scanner is not connected"); break; case 0: state = STATE.GETSINGLE; break; default: //SendPopUpMessage("Please, remove finger from the scanner"); break; } break; case STATE.GETFINGER_1: image = new byte[imageSize]; state = STATE.GETIMAGE_1; BioNetACSDLL._ChangeGain(0); break; case STATE.GETIMAGE_1: status = BioNetACSDLL._GetNetAccessImageByManual(image); switch (status) { // not connected case -1: SendPopUpMessage("Scanner is not connected"); break; case 0: SendBaseMessage("Please, touch the scanner"); break; case 1: int qual = BioNetACSDLL._GetIBQualityScore(image); if (qual > NEEDED_QUALITY) { goto default; } SendPopUpMessage("Image quality " + qual + " not enough, keep finger on scanner"); OnBiometricsCaptured(new FingerImageIB(image,imageWidth,imageHeight)); break; default: Array.Copy(image,imageStack[firstEnrollCount],imageSize); OnBiometricsCaptured(new FingerImageIB(image,imageWidth,imageHeight)); firstEnrollCount++; OnSendProgressMessage((firstEnrollCount) * 22); state = STATE.GETEMPTY_1; break; } break; case STATE.GETEMPTY_1: image = new byte[imageSize]; status = BioNetACSDLL._GetNetAccessImage(image); switch (status) { // not connected case -1: SendPopUpMessage("Scanner is not connected"); break; case 0: if (firstEnrollCount < 3) { state = STATE.GETFINGER_1; } else { int singeEnrolResult = BioNetACSDLL._Enroll_SingleTemplate( (byte[])imageStack[0],(byte[])imageStack[1],(byte[])imageStack[2], (byte[])FingerFeat[0],(byte[])FingerFeat[1],(byte[])FingerFeat[2], resultFeat[0]); if (singeEnrolResult < 1) { state = STATE.GETEMPTY_2; } else { state = STATE.IDLE; resultBios.Add(new TemplateIB(resultFeat[0])); SendPopUpMessage("Successfully registered"); OnBiometricsEnrolled(resultBios.ToList()); } } break; default: SendPopUpMessage("Please, remove finger from the scanner"); break; } break; case STATE.GETFINGER_2: image = new byte[imageSize]; state = STATE.GETIMAGE_2; break; case STATE.GETIMAGE_2: status = BioNetACSDLL._GetNetAccessImageByManual(image); switch (status) { // not connected case -1: SendPopUpMessage("Scanner is not connected"); break; case 0: SendBaseMessage("Please, touch the scanner"); break; case 1: int qual = BioNetACSDLL._GetIBQualityScore(image); if (qual > NEEDED_QUALITY) { goto default; } SendPopUpMessage("Image quality " + qual + " not enough, keep finger on scanner"); OnBiometricsCaptured(new FingerImageIB(image, imageWidth, imageHeight)); break; default: Array.Copy(image, imageStack[secondEnrollCount], imageSize); OnBiometricsCaptured(new FingerImageIB(image, imageWidth, imageHeight)); secondEnrollCount++; OnSendProgressMessage(66 + (secondEnrollCount) * 11); state = STATE.GETEMPTY_2; break; } break; case STATE.GETEMPTY_2: image = new byte[imageSize]; status = BioNetACSDLL._GetNetAccessImage(image); switch (status) { // not connected case -1: SendPopUpMessage("Scanner is not connected"); break; case 0: if (secondEnrollCount < 3) { state = STATE.GETFINGER_2; } else { int multiEnrollResult = BioNetACSDLL._Enroll_MultiTemplate( (byte[])FingerFeat[0], (byte[])FingerFeat[1], (byte[])FingerFeat[2], (byte[])imageStack[3], (byte[])imageStack[4], (byte[])imageStack[5], resultFeat[0], resultFeat[1]); if (multiEnrollResult > 0) { state = STATE.IDLE; resultBios.Add(new TemplateIB(resultFeat[0])); resultBios.Add(new TemplateIB(resultFeat[1])); SendPopUpMessage("Successfully registered"); OnBiometricsEnrolled(resultBios.ToList()); } else { state = STATE.IDLE; SendPopUpMessage("Can't create template, please repeat"); OnBiometricsEnrolled(null); } } break; default: SendPopUpMessage("Please, remove finger from the scanner"); break; } break; case STATE.OFFLINE: break; } } } catch { BioNetACSDLL._CloseNetAccessDevice(); } }
private void deviceThread() { isThreadFinalized = false; /// int enrollCount = 0; stateCallBack = new BioAPI.GUI_STATE_CALLBACK(DeviceHi.GuiStateCallback); streamingCallBack = new BioAPI.GUI_STREAMING_CALLBACK(DeviceHi.GuiStreamingCallback); List <FingerTemplate> templates = new List <FingerTemplate>(); STATE state = STATE.IDLE; COMMAND com = COMMAND.NONE; int BirHandle = 0; int intsize = Marshal.SizeOf(typeof(IntPtr)); uint res; bioapi_data unitcontroldata; bioapi_bir bir = new bioapi_bir(); int[] enrollmentBirHandle = new int[3]; int verifyEnrollBirHandle = 0; byte enrollState = BioAPI.NO_PURPOSE_AVAILABLE; unitcontroldata.Data = Marshal.AllocHGlobal(4 * intsize); try { online = true; while (true) { cancelToken.Token.ThrowIfCancellationRequested(); if (state == STATE.IDLE) { com = queue.Take(cancelToken.Token); } else { // non blocking take if (queue.Count > 0) { com = queue.Take(); } } switch (com) { case COMMAND.LIVECAPTURE_START: state = STATE.STARTTEST; break; case COMMAND.ENROLLMENT_START: state = STATE.GETFINGER; enrollCount = 0; enrollState = BioAPI.PURPOSE_ENROLL; templates.Clear(); break; case COMMAND.SINGLECAPTURE_START: state = STATE.GETSINGLE; break; case COMMAND.SINGLECAPTURE_STOP: case COMMAND.LIVECAPTURE_STOP: case COMMAND.ENROLLMENT_STOP: BioAPI.Cancel(handle); state = STATE.IDLE; break; } com = COMMAND.NONE; switch (state) { case STATE.IDLE: Detach(); break; case STATE.STARTTEST: SendBaseMessage("Please, place finger on scanner"); state = STATE.TEST; break; case STATE.TEST: Attach(); res = BioAPI.Capture(handle, BioAPI.PURPOSE_VERIFY, ref BirHandle, CaptureTimeout); if (res == 0) { bioapi_input_bir captured_bir_data = new bioapi_input_bir(); int processed_bir = 0; GCHandle tmpgch = GCHandle.Alloc(BirHandle, GCHandleType.Pinned); captured_bir_data.Form = BioAPI.BIR_HANDLE_INPUT; captured_bir_data.InputBIR.BIRinBSP = tmpgch.AddrOfPinnedObject(); BioAPI.Process(handle, ref captured_bir_data, ref processed_bir); BioAPI.FreeBIRHandle(handle, BirHandle); tmpgch.Free(); BioAPI.GetBIRFromHandle(handle, processed_bir, ref bir); OnBiometricsCaptured(new FingerImageHi(bir)); Thread.Sleep(300); BioAPI.Free(bir.BiometricData.Data); BioAPI.Free(bir.SecurityBlock.Data); } else { if (((res & (uint)BioAPI.Error.TIMEOUT_EXPIRED) == (uint)BioAPI.Error.TIMEOUT_EXPIRED) || ((res & (uint)BioAPI.Error.USER_CANCELLED) == (uint)BioAPI.Error.USER_CANCELLED)) { // _log.Info(res.ToString() + " test capture error"); OnBiometricsCaptured(null); } else { online = false; state = STATE.OFFLINE; Ambassador.AddMessage(new MSignal(this, MSignal.SIGNAL.DEVICE_FAILURE)); } } break; case STATE.GETSINGLE: //SendBaseMessage("Please, select finger to enroll or place a finger on the FV scanner"); state = STATE.GETSINGLEIMAGE; break; case STATE.GETSINGLEIMAGE: Attach(); res = BioAPI.Capture(handle,BioAPI.PURPOSE_VERIFY,ref BirHandle,CaptureTimeout); if (res == 0) { bioapi_input_bir captured_bir_data = new bioapi_input_bir(); int processed_bir = 0; GCHandle tmpgch = GCHandle.Alloc(BirHandle,GCHandleType.Pinned); captured_bir_data.Form = BioAPI.BIR_HANDLE_INPUT; captured_bir_data.InputBIR.BIRinBSP = tmpgch.AddrOfPinnedObject(); BioAPI.Process(handle,ref captured_bir_data,ref processed_bir); BioAPI.FreeBIRHandle(handle,BirHandle); tmpgch.Free(); BioAPI.GetBIRFromHandle(handle,processed_bir,ref bir); Detach(); FingerImageHi catchedImage = new FingerImageHi(bir); OnSingleCaptured(catchedImage); Thread.Sleep(300); BioAPI.Free(bir.BiometricData.Data); BioAPI.Free(bir.SecurityBlock.Data); } else { if (((res & (uint)BioAPI.Error.TIMEOUT_EXPIRED) == (uint)BioAPI.Error.TIMEOUT_EXPIRED) || ((res & (uint)BioAPI.Error.USER_CANCELLED) == (uint)BioAPI.Error.USER_CANCELLED)) { // _log.Info(res.ToString() + " getsingleimage capture error"); } else { online = false; state = STATE.OFFLINE; Ambassador.AddMessage(new MSignal(this,MSignal.SIGNAL.DEVICE_FAILURE)); } } break; case STATE.GETFINGER: SendBaseMessage("Please, place a finger on the FV scanner"); state = STATE.GETIMAGE; break; case STATE.GETIMAGE: Attach(); res = BioAPI.Capture(handle,enrollState,ref BirHandle,CaptureTimeout); if (res == 0) { bioapi_input_bir captured_bir_data = new bioapi_input_bir(); GCHandle tmpgch = GCHandle.Alloc(BirHandle,GCHandleType.Pinned); captured_bir_data.Form = BioAPI.BIR_HANDLE_INPUT; captured_bir_data.InputBIR.BIRinBSP = tmpgch.AddrOfPinnedObject(); if (enrollState == BioAPI.PURPOSE_ENROLL) { res = BioAPI.CreateTemplate(handle,ref captured_bir_data,ref enrollmentBirHandle[enrollCount]); enrollCount++; if (enrollCount == 2) { enrollState = BioAPI.PURPOSE_VERIFY; } } else if (enrollState == BioAPI.PURPOSE_VERIFY) { res = BioAPI.Process(handle,ref captured_bir_data,ref verifyEnrollBirHandle); enrollCount++; } tmpgch.Free(); BioAPI.GetBIRFromHandle(handle,BirHandle,ref bir); OnBiometricsCaptured(new FingerImageHi(bir)); BioAPI.Free(bir.BiometricData.Data); BioAPI.Free(bir.SecurityBlock.Data); OnSendProgressMessage(enrollCount * 33); if (enrollCount < 3) { state = STATE.GETEMPTY; } else { int FMRAchieved = 0; byte matchResult = 0; GCHandle gcverify,gcenroll; bioapi_input_bir verify_input_bir = new bioapi_input_bir(); verify_input_bir.Form = BioAPI.BIR_HANDLE_INPUT; gcverify = GCHandle.Alloc(verifyEnrollBirHandle,GCHandleType.Pinned); verify_input_bir.InputBIR.BIRinBSP = gcverify.AddrOfPinnedObject(); bioapi_input_bir enroll_input_bir = new bioapi_input_bir(); enroll_input_bir.Form = BioAPI.BIR_HANDLE_INPUT; gcenroll = GCHandle.Alloc(enrollmentBirHandle[0],GCHandleType.Pinned); enroll_input_bir.InputBIR.BIRinBSP = gcenroll.AddrOfPinnedObject(); res = BioAPI.VerifyMatch(handle,2072,ref verify_input_bir,ref enroll_input_bir,ref matchResult,ref FMRAchieved); gcenroll.Free(); if ((res == 0) && (matchResult != 0)) { enroll_input_bir.Form = BioAPI.BIR_HANDLE_INPUT; gcenroll = GCHandle.Alloc(enrollmentBirHandle[1],GCHandleType.Pinned); enroll_input_bir.InputBIR.BIRinBSP = gcenroll.AddrOfPinnedObject(); res = BioAPI.VerifyMatch(handle,2072,ref verify_input_bir,ref enroll_input_bir,ref matchResult,ref FMRAchieved); gcenroll.Free(); } gcverify.Free(); if ((res == 0) && (matchResult != 0)) { res = BioAPI.GetBIRFromHandle(handle,enrollmentBirHandle[1],ref bir); TemplateHi template = new TemplateHi(bir); BioAPI.Free(bir.BiometricData.Data); BioAPI.Free(bir.SecurityBlock.Data); templates.Add(template); state = STATE.FINISHENROLL; } else { state = STATE.FINISHENROLL; BioAPI.FreeBIRHandle(handle,enrollmentBirHandle[1]); } BioAPI.FreeBIRHandle(handle,enrollmentBirHandle[0]); BioAPI.FreeBIRHandle(handle,verifyEnrollBirHandle); } } else if (((res & (uint)BioAPI.Error.TIMEOUT_EXPIRED) == (uint)BioAPI.Error.TIMEOUT_EXPIRED) || ((res & (uint)BioAPI.Error.USER_CANCELLED) == (uint)BioAPI.Error.USER_CANCELLED)) { // _log.Info(res.ToString() + " getimage capture error"); } else { online = false; state = STATE.OFFLINE; for (int i = 0; i < enrollCount; i++) { BioAPI.FreeBIRHandle(handle,enrollmentBirHandle[i]); } Ambassador.AddMessage(new MSignal(this,MSignal.SIGNAL.DEVICE_FAILURE)); } break; case STATE.GETEMPTY: SendPopUpMessage("Please remove finger from scanner"); Attach(); res = BioAPI.Capture(handle,BioAPI.PURPOSE_ENROLL,ref BirHandle,CaptureTimeout); if (res != 0) { state = STATE.GETFINGER; } else { BioAPI.FreeBIRHandle(handle,BirHandle); } break; case STATE.GETEMPTYIMAGE: break; case STATE.FINISHENROLL: state = STATE.IDLE; if (templates.Count() > 0) { SendPopUpMessage("Successfully registered"); OnBiometricsEnrolled(templates.ToList()); } else { SendPopUpMessage("Registration failed"); OnBiometricsEnrolled(null); } break; default: break; } } } catch (Exception e) { _log.Error(e.Message); } finally { Detach(); isThreadFinalized = true; } }
private void deviceThread() { STATE state = STATE.IDLE; COMMAND com = COMMAND.NONE; try { //TODO: Add your device initialization here InitDevice(); while (true) { // This block is common for all plugins // Check the thread cancelation, then try to get command from queue // If nothing should be done (IDLE state) - block on queueTaking // If not - check for new command and go to main logic cancelToken.Token.ThrowIfCancellationRequested(); if (state == STATE.IDLE) { com = queue.Take(cancelToken.Token); } else { // non blocking take if (queue.Count > 0) { com = queue.Take(); } } switch (com) { case COMMAND.LIVECAPTURE_START: state = STATE.LIVECAPTURE; break; case COMMAND.ENROLLMENT_START: state = STATE.ENROLL; break; case COMMAND.SINGLECAPTURE_START: state = STATE.SINGLECAPTURE; break; case COMMAND.LIVECAPTURE_STOP: case COMMAND.ENROLLMENT_STOP: case COMMAND.SINGLECAPTURE_STOP: state = STATE.IDLE; break; default: break; } com = COMMAND.NONE; switch (state) { case STATE.LIVECAPTURE: Thread.Sleep(100); Ambassador.AddMessage(new MBiometricsLiveCaptured(this, new FingerImageFake())); break; case STATE.SINGLECAPTURE: Thread.Sleep(500); Ambassador.AddMessage(new MBiometricsSingleCaptured(this, new FingerImageFake())); state = STATE.IDLE; break; case STATE.ENROLL: Ambassador.AddMessage(new MBiometricsSingleCaptured(this, new FingerImageFake())); Ambassador.AddMessage(new MBiometricsEnrolled(this, new List <FingerTemplate>() { new TemplateFake(new byte[0]) })); state = STATE.IDLE; break; case STATE.IDLE: default: break; } } } catch { } finally { CleanUp(); } }