コード例 #1
0
ファイル: HiBioAPI.cs プロジェクト: sfcheewill/Blm
 public static uint IdentifyMatch(uint BSPHandle, int MaxFMRRequested, ref bioapi_input_bir ProcessedBIR, ref bioapi_identify_population Population, uint TotalNumberOfTemplates, uint MaxNumberOfResults, ref uint NumberOfResults, ref System.IntPtr Candidates, int Timeout)
 {
     return(NativeMethods.BioAPI_IdentifyMatch(BSPHandle, MaxFMRRequested, ref ProcessedBIR, ref Population, TotalNumberOfTemplates, 0, MaxNumberOfResults, ref NumberOfResults, ref Candidates, Timeout));
 }
コード例 #2
0
ファイル: HiBioAPI.cs プロジェクト: sfcheewill/Blm
 public static uint Process(uint BSPHandle, ref bioapi_input_bir CapturedBIR, ref int ProcessedBIR)
 {
     return(NativeMethods.BioAPI_Process(BSPHandle, ref CapturedBIR, IntPtr.Zero, ref ProcessedBIR));
 }
コード例 #3
0
ファイル: HiBioAPI.cs プロジェクト: sfcheewill/Blm
 public static uint VerifyMatch(uint BSPHandle, int MaxFMRRequested, ref bioapi_input_bir ProcessedBIR, ref bioapi_input_bir ReferenceTemplate, ref byte Result, ref int FMRAchieved)
 {
     return(NativeMethods.BioAPI_VerifyMatch(BSPHandle, MaxFMRRequested, ref ProcessedBIR, ref ReferenceTemplate, IntPtr.Zero, ref Result, ref FMRAchieved, IntPtr.Zero));
 }
コード例 #4
0
ファイル: HiBioAPI.cs プロジェクト: sfcheewill/Blm
 public static extern uint BioAPI_Verify(uint BSPHandle, int MaxFMRRequested, ref bioapi_input_bir ReferenceTemplate, byte Subtype, IntPtr AdaptedBIR, System.IntPtr Result, ref int FMRAchieved, IntPtr Payload, int Timeout, IntPtr AuditData);
コード例 #5
0
ファイル: HiBioAPI.cs プロジェクト: sfcheewill/Blm
 public static uint CreateTemplate(uint BSPHandle, ref bioapi_input_bir CapturedBIR, ref int NewTemplate)
 {
     return(NativeMethods.BioAPI_CreateTemplate(BSPHandle, ref CapturedBIR, IntPtr.Zero, IntPtr.Zero, ref NewTemplate, IntPtr.Zero, IntPtr.Zero));
 }
コード例 #6
0
ファイル: HiBioAPI.cs プロジェクト: sfcheewill/Blm
 public static extern uint BioAPI_IdentifyMatch(uint BSPHandle, int MaxFMRRequested, ref bioapi_input_bir ProcessedBIR, ref bioapi_identify_population Population, uint TotalNumberOfTemplates, byte Binning, uint MaxNumberOfResults, ref uint NumberOfResults, ref System.IntPtr Candidates, int Timeout);
コード例 #7
0
ファイル: HiBioAPI.cs プロジェクト: sfcheewill/Blm
 public static extern uint BioAPI_VerifyMatch(uint BSPHandle, int MaxFMRRequested, ref bioapi_input_bir ProcessedBIR, ref bioapi_input_bir ReferenceTemplate, IntPtr AdaptedBIR, ref byte Result, ref int FMRAchieved, IntPtr Payload);
コード例 #8
0
ファイル: HiBioAPI.cs プロジェクト: sfcheewill/Blm
 public static extern uint BioAPI_Process(uint BSPHandle, ref bioapi_input_bir CapturedBIR, IntPtr OutputFormat, ref int ProcessedBIR);
コード例 #9
0
ファイル: HiBioAPI.cs プロジェクト: sfcheewill/Blm
 public static extern uint BioAPI_CreateTemplate(uint BSPHandle, ref bioapi_input_bir CapturedBIR, IntPtr ReferenceTemplate, IntPtr OutputFormat, ref int NewTemplate, IntPtr Payload, IntPtr TemplateUUID);
コード例 #10
0
ファイル: DeviceHi.cs プロジェクト: sfcheewill/Blm
        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;
            }
        }