Beispiel #1
0
        public bool Close()
        {
            var iError = m_FPM.CloseDevice();

            if (iError == (Int32)SGFPMError.ERROR_NONE)
            {
                return(true);
            }
            return(false);
        }
Beispiel #2
0
        private void InitializeDevice()
        {
            m_FPM = new SGFingerPrintManager();

            Int32           error;
            SGFPMDeviceName device_name = SGFPMDeviceName.DEV_AUTO;
            Int32           device_id   = (Int32)SGFPMPortAddr.USB_AUTO_DETECT;

            m_SecurityLevel = SGFPMSecurityLevel.NORMAL;

            m_DeviceOpened = false;


            error = m_FPM.Init(device_name);
            if (error != (Int32)SGFPMError.ERROR_NONE)
            {
                error = m_FPM.InitEx(m_ImageWidth, m_ImageHeight, m_Dpi);
            }

            if (error == (Int32)SGFPMError.ERROR_NONE)
            {
                m_FPM.CloseDevice();
                error = m_FPM.OpenDevice(device_id);
            }
            else
            {
                throw new ApplicationException("Unable to initialize scanner. Kindly check the connection");
            }

            if (error == (Int32)SGFPMError.ERROR_NONE)
            {
                SGFPMDeviceInfoParam pInfo = new SGFPMDeviceInfoParam();
                m_FPM.GetDeviceInfo(pInfo);
                m_ImageWidth  = pInfo.ImageWidth;
                m_ImageHeight = pInfo.ImageHeight;
                m_Dpi         = pInfo.ImageDPI;
                serialNo      = pInfo.DeviceID;
            }

            error = m_FPM.SetTemplateFormat(SGFPMTemplateFormat.ISO19794);
            error = m_FPM.GetMaxTemplateSize(ref max_template_size);

            if (device_name != SGFPMDeviceName.DEV_UNKNOWN)
            {
                error = m_FPM.OpenDevice(device_id);
                if (error == (Int32)SGFPMError.ERROR_NONE)
                {
                    m_DeviceOpened = true;
                }
            }
        }
Beispiel #3
0
 public void FormEnroll_Closing(object sender, FormClosingEventArgs e)
 {
     fpm.CloseDevice();
     new FormMain().Show();
 }
Beispiel #4
0
        private void button4_Click(object sender, EventArgs e)
        {
            Int32           error;
            SGFPMDeviceName device_name = SGFPMDeviceName.DEV_UNKNOWN;
            Int32           device_id   = (Int32)SGFPMPortAddr.USB_AUTO_DETECT;

            m_DeviceOpened = false;

            // Get device name
            if (comboBox2.Text == "DEV_FDU03 : 0")
            {
                device_name = SGFPMDeviceName.DEV_FDU03;
            }

            else if (comboBox2.Text == "Auto Selection")
            {
                device_name = SGFPMDeviceName.DEV_AUTO;
            }

            if (device_name != SGFPMDeviceName.DEV_UNKNOWN)
            {
                error = m_FPM.Init(device_name);

                if (error == (Int32)SGFPMError.ERROR_NONE)
                {
                    m_FPM.CloseDevice();
                    error = m_FPM.OpenDevice(device_id);
                }

                if (error == (Int32)SGFPMError.ERROR_NONE)
                {
                    SGFPMDeviceInfoParam pInfo = new SGFPMDeviceInfoParam();
                    m_FPM.GetDeviceInfo(pInfo);
                    m_ImageWidth  = pInfo.ImageWidth;
                    m_ImageHeight = pInfo.ImageHeight;
                }
            }
            else
            {
                error = m_FPM.InitEx(m_ImageWidth, m_ImageHeight, m_Dpi);
            }

            if (error == (Int32)SGFPMError.ERROR_NONE)
            {
                EnableButtons(true);
                textBox5.Text = "Initialization Success";
            }
            else
            {
                EnableButtons(false);
                textBox5.Text = "Init() Error " + error;
                return;
            }

            if (m_useAnsiTemplate)
            {
                // Set template format to ANSI 378
                error = m_FPM.SetTemplateFormat(SGFPMTemplateFormat.ANSI378);
            }
            else
            {
                // Set template format to ISO 19794-2
                error = m_FPM.SetTemplateFormat(SGFPMTemplateFormat.ISO19794);
            }

            // Get Max template size
            Int32 max_template_size = 0;

            error = m_FPM.GetMaxTemplateSize(ref max_template_size);

            m_RegMin1 = new Byte[max_template_size];
            m_RegMin2 = new Byte[max_template_size];
            m_VrfMin  = new Byte[max_template_size];

            // OpenDevice if device is selected
            if (device_name != SGFPMDeviceName.DEV_UNKNOWN)
            {
                error = m_FPM.OpenDevice(device_id);
                if (error == (Int32)SGFPMError.ERROR_NONE)
                {
                    m_DeviceOpened = true;
                }
                else
                {
                    textBox4.Text = "OpenDevice() Error : " + error;
                    EnableButtons(false);
                }
            }
        }
Beispiel #5
0
        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();
            }
        }
Beispiel #6
0
        ///////////////////////
        // Initialize SGFingerprint manage with device name
        // Init(), OpenDeice()
        private void btnOpenDevice_Click(object sender, EventArgs e)
        {
            if (btnInitDevice.Text == "Initialize Device")
            {
                if (m_FPM.NumberOfDevice == 0)
                {
                    StatusBars.Text = "Please Plug Device And Then Click On Load Device";
                    return;
                }
                if (cmbDeviceName.SelectedIndex == -1)
                {
                    return;
                }
                Int32           iError;
                SGFPMDeviceName device_name;
                Int32           device_id;

                Int32   numberOfDevices = cmbDeviceName.Items.Count;
                Int32   deviceSelected  = cmbDeviceName.SelectedIndex;
                Boolean autoSelection   = (deviceSelected == (numberOfDevices - 1)); // Last index

                if (autoSelection)
                {
                    // Order of search: Hamster IV(HFDU04) -> Plus(HFDU03) -> III (HFDU02)
                    device_name = SGFPMDeviceName.DEV_AUTO;

                    device_id = (Int32)(SGFPMPortAddr.USB_AUTO_DETECT);
                }
                else
                {
                    device_name = m_DevList[deviceSelected].DevName;
                    device_id   = m_DevList[deviceSelected].DevID;
                }

                iError = m_FPM.Init(device_name);
                iError = m_FPM.OpenDevice(device_id);

                iError = m_FPM.Init(device_name);
                iError = m_FPM.OpenDevice(device_id);
                if (iError == (Int32)SGFPMError.ERROR_NONE)
                {
                    SGFPMDeviceInfoParam pInfo = new SGFPMDeviceInfoParam();
                    Int32 iError2 = m_FPM.GetDeviceInfo(pInfo);

                    if (iError2 == (Int32)SGFPMError.ERROR_NONE)
                    {
                        m_ImageWidth  = pInfo.ImageWidth;
                        m_ImageHeight = pInfo.ImageHeight;
                    }

                    StatusBars.Text = "Device Initialization Success";

                    btnInitDevice.Text = "Close Device";
                }
                else
                {
                    DisplayError("OpenDevice()", iError);
                }
            }
            else
            {
                m_FPM.CloseDevice();
                btnInitDevice.Text = "Open Device";

                btnInitDevice.Text = "Device Close";
            }
        }