Example #1
0
        private void Exit()
        {
            ObjFpReader.pisLedControl(contextId, ObjFpReader.PISFP_ALLLED, ObjFpReader.PISFP_LED_OFF);

            ObjFpReader.pisCloseDevice(contextId);
            ObjFpReader.pisDestroyContext(contextId);
        }
Example #2
0
        private void Exit()
        {
            StopFlag = true;

            if (deviceCompany == ObjFpReader.PRODUCT_HYSOON || deviceCompany == ObjFpReader.PRODUCT_TAIWAN)
            {
                ObjFpReader.pisLedControl(contextId, ObjFpReader.PISFP_BKLED, ObjFpReader.PISFP_LED_OFF);
            }

            ObjFpReader.pisCloseDevice(contextId);
            ObjFpReader.pisDestroyContext(contextId);
            gbxFpReader.Enabled = false;
            btnInit.Enabled     = true;
            cbbDevice.Enabled   = true;
        }
Example #3
0
        private void Enroll()
        {
            //超过 10 枚指纹,不再注册
            if (fpDataList.Count > 9)
            {
                txtInfo.Text = Pub.GetResText(formCode, "MsgOverRegister", "");
                return;
            }

            int vnRet;
            int flag = 1;
            //控制设备灯
            int temp_DeviceCompany = deviceCompany;

            if (temp_DeviceCompany == ObjFpReader.PRODUCT_HYSOON)
            {
                ObjFpReader.pisLedControl(contextId, ObjFpReader.PISFP_ALLLED, ObjFpReader.PISFP_LED_OFF);
                ObjFpReader.pisLedControl(contextId, ObjFpReader.PISFP_BKLED, ObjFpReader.PISFP_LED_ON);
            }
            else if (temp_DeviceCompany == ObjFpReader.PRODUCT_TAIWAN)
            {
                ObjFpReader.pisLedControl(contextId, ObjFpReader.PISFP_BKLED, ObjFpReader.PISFP_LED_ON);
            }

            if (StopFlag)
            {
                StopFlag = false;
            }
            int  isCheckFp = 0, fpArea = 0;
            int  fpExtractCount        = 0;
            int  continuosFpPressCount = 0;
            bool doubleCheckFlag       = true;

            ObjFpReader.CaptureFpStatus capFpStatus = ObjFpReader.CaptureFpStatus.CapFp_Init;
            while (!StopFlag)
            {
                Application.DoEvents();
                vnRet = ObjFpReader.pisCapture(contextId, imageBuffer);
                if (vnRet == ObjFpReader.PISFP_ERR_NOT_CONNECT_DEV)
                {
                    ErrorDescription(ObjFpReader.ENROLL_PROC, ObjFpReader.CAPTURE_FUNC, vnRet);

                    ObjFpReader.pisCloseDevice(contextId);

                    vnRet = ObjFpReader.pisOpenDevice(contextId, devIdList[cbbDevice.SelectedIndex]);
                    System.Threading.Thread.Sleep(1000);
                    continue;
                }
                else if (vnRet != ObjFpReader.PISFP_OK)
                {
                    ErrorDescription(ObjFpReader.ENROLL_PROC, ObjFpReader.CAPTURE_FUNC, vnRet);
                    ObjFpReader.pisLedControl(contextId, ObjFpReader.PISFP_ALLLED, ObjFpReader.PISFP_LED_OFF);
                    return;
                }

                DrawFpImage();

                vnRet = ObjFpReader.pisCheckFp(contextId, imageBuffer, imageWidth, imageHeight, imageRes, ref isCheckFp, ref fpArea);

                //初始化
                if (capFpStatus == ObjFpReader.CaptureFpStatus.CapFp_Init)
                {
                    if (isCheckFp != 0)
                    {
                        txtInfo.Text = Pub.GetResText(formCode, "MsgLeaveFinger", "");;
                        continue;
                    }
                    else
                    {
                        capFpStatus           = ObjFpReader.CaptureFpStatus.CapFp_WaitPressFinger;
                        continuosFpPressCount = 0;
                    }
                }

                //等待手指按下时的操作
                if (capFpStatus == ObjFpReader.CaptureFpStatus.CapFp_WaitPressFinger)
                {
                    if (isCheckFp == 0)
                    {
                        promptPressFinger(fpExtractCount + 1);
                        if (continuosFpPressCount < 2)
                        {
                            continuosFpPressCount = 0;
                            continue;
                        }
                    }

                    continuosFpPressCount++;
                    if (fpArea > 80 && continuosFpPressCount > maxContinuosFpPressCount)
                    {
                        capFpStatus = ObjFpReader.CaptureFpStatus.CapFp_GoodFpCaptured;
                    }
                }

                //处理获取到的图片
                if (capFpStatus == ObjFpReader.CaptureFpStatus.CapFp_GoodFpCaptured)
                {
                    // 使用最大指纹图像提取指纹
                    if (ObjFpReader.pisProcess(contextId, imageBuffer, imageWidth, imageHeight, imageRes,
                                               feature[fpExtractCount]) != ObjFpReader.PISFP_OK)
                    {
                        ErrorDescription(ObjFpReader.ENROLL_PROC, ObjFpReader.PROCESS_FUNC, vnRet);
                        //
                        return;
                    }


                    //检查指纹数据是否已经存在
                    if (doubleCheckFlag == true)
                    {
                        int identifiedID = 0;
                        vnRet = ObjFpReader.pisIdentify(contextId, feature[fpExtractCount],
                                                        ref identifiedID, updatedTemplate, ref updatedFlag);

                        if (vnRet == ObjFpReader.PISFP_OK)
                        {
                            txtInfo.Text = string.Format(Pub.GetResText(formCode, "MsgExist", ""), txtEmpNo.Text, identifiedID);
                            return;
                        }
                    }

                    fpExtractCount++;


                    continuosFpPressCount = 0;

                    if (flag >= 3)
                    {
                        flag = 1;
                    }
                    if (fpExtractCount == 3)
                    {
                        break;
                    }
                    else
                    {
                        capFpStatus = ObjFpReader.CaptureFpStatus.CapFp_PromptTakeoffFinger;
                    }
                }

                //获取图片后手指的操作提示
                if (capFpStatus == ObjFpReader.CaptureFpStatus.CapFp_PromptTakeoffFinger)
                {
                    //检测指纹是否合格

                    int sum = 0;
                    for (int i = 0; i < 57344; i++)
                    {
                        sum += int.Parse(imageBuffer[i].ToString());
                    }

                    if (isCheckFp != 0)
                    {
                        txtInfo.Text = Pub.GetResText(formCode, "MsgLeaveFinger", "");
                        capFpStatus  = ObjFpReader.CaptureFpStatus.CapFp_Init;
                        continue;
                    }

                    // capFpStatus = ObjFpReader.CaptureFpStatus.CapFp_WaitPressFinger;
                }
            }

            if (temp_DeviceCompany == ObjFpReader.PRODUCT_HYSOON || temp_DeviceCompany == ObjFpReader.PRODUCT_TAIWAN)
            {
                ObjFpReader.pisLedControl(contextId, ObjFpReader.PISFP_BKLED, ObjFpReader.PISFP_LED_OFF);
            }

            if (StopFlag == true)
            {
                txtInfo.Text = Pub.GetResText(formCode, "MsgStop", "");

                return;
            }

            //生成模板
            vnRet = ObjFpReader.pisCreateTemplate(contextId, feature[0], feature[1], feature[2], template);
            if (vnRet != ObjFpReader.PISFP_OK)
            {
                ErrorDescription(ObjFpReader.ENROLL_PROC, ObjFpReader.CREATE_TEMPLATE_FUNC, vnRet);
                //txtInfo.Text = Pub.GetResText(formCode, "MsgCreateTemplate", "");
                return;
            }

            ////写出到文件
            //using (var fs = new FileStream(string.Format("{0}.dat", txtEmpNo.Text), FileMode.Create))
            //{
            //    fs.Write(template, 0, template.Length);
            //}

            //添加进识别
            vnRet = ObjFpReader.pisAddTptArray(contextId, fpDataList.Count + 1, template);
            if (vnRet != ObjFpReader.PISFP_OK)
            {
                ErrorDescription(ObjFpReader.ENROLL_PROC, ObjFpReader.ADD_TPT_ARRAY_FUNC, vnRet);
                return;
            }

            //保存到数据库
            if (SaveFpDataToDB(template))
            {
                fpDataList.Add(template);
            }

            txtInfo.Text = string.Format(Pub.GetResText(formCode, "MsgRegisterSuccess", ""), txtEmpNo.Text, fpDataList.Count);
        }
Example #4
0
        private void OpenDev(int index)
        {
            string vDevId = string.Empty;
            int    vnRet;

            if (!GetDevIdFromListIndex(index, ref vDevId))
            {
                MessageBoxEx.Show(Pub.GetResText(formCode, "MsgNoDevice", ""));
            }
            vnRet = ObjFpReader.pisCreateContext(ref contextId);
            if (vnRet != ObjFpReader.PISFP_OK)
            {
                ErrorDescription(ObjFpReader.INIT_PROC, ObjFpReader.CREATE_CONTEXT_FUNC, vnRet);
            }

            txtInfo.Text = Pub.GetResText(formCode, "MsgOpenDevice", "");

            vnRet = ObjFpReader.pisOpenDevice(contextId, vDevId);
            if (vnRet != ObjFpReader.PISFP_OK)
            {
                ObjFpReader.pisDestroyContext(contextId);
                ErrorDescription(ObjFpReader.INIT_PROC, ObjFpReader.OPEN_DEVICE_FUNC, vnRet);
                return;
            }

            vnRet = ObjFpReader.pisGetDeviceInfo(contextId, ObjFpReader.PISFP_PARAM_KIND_COMPANY, ref deviceCompany);
            if (vnRet != ObjFpReader.PISFP_OK)
            {
                deviceCompany = ObjFpReader.PRODUCT_PEFIS;
            }

            fpAreaTh       = 18;
            noCheckCountTh = 20;
            int temp_DeviceCompany = deviceCompany;

            if (temp_DeviceCompany == ObjFpReader.PRODUCT_HYSOON || temp_DeviceCompany == ObjFpReader.PRODUCT_TAIWAN)
            {
                ObjFpReader.pisLedControl(contextId, ObjFpReader.PISFP_BKLED, ObjFpReader.PISFP_LED_ON);
                fpAreaTh       = 17;
                noCheckCountTh = 20;
            }


            byte[] engineInfo = new byte[1024];
            vnRet = ObjFpReader.pisGetInfo(contextId, ref engineInfo[0], ref imageWidth, ref imageHeight, ref imageRes,
                                           ref featureSize, ref templateSize);

            if (temp_DeviceCompany == ObjFpReader.PRODUCT_HYSOON || temp_DeviceCompany == ObjFpReader.PRODUCT_TAIWAN)
            {
                ObjFpReader.pisLedControl(contextId, ObjFpReader.PISFP_BKLED, ObjFpReader.PISFP_LED_OFF);
            }

            if (vnRet != ObjFpReader.PISFP_OK)
            {
                ObjFpReader.pisDestroyContext(contextId);
                ErrorDescription(ObjFpReader.INIT_PROC, ObjFpReader.GET_INFO_FUNC, vnRet);
                return;
            }

            picFpImage.Width  = imageWidth;
            picFpImage.Height = imageHeight;
            picFpImage.Image  = null;

            imageBuffer     = new byte[picFpImage.Width * picFpImage.Height];
            feature[0]      = new byte[featureSize];
            feature[1]      = new byte[featureSize];
            feature[2]      = new byte[featureSize];
            template        = new byte[templateSize];
            updatedTemplate = new byte[templateSize];
            rawImgBuffer    = new byte[ObjFpReader.IMPORT_RAW_IMAGE_WIDTH * ObjFpReader.IMPORT_RAW_IMAGE_HEIGHT];

            memset(imageBuffer, 0x55, picFpImage.Width * picFpImage.Height);

            vnRet = ObjFpReader.pisSetMatchParameter(contextId, ObjFpReader.PISFP_DEFAULT_ROTATION_RANGE, ObjFpReader.PISFP_DEFAULT_THRESHOLD);
            if (vnRet != ObjFpReader.PISFP_OK)
            {
                ObjFpReader.pisDestroyContext(contextId);
                ErrorDescription(ObjFpReader.INIT_PROC, ObjFpReader.GET_INFO_FUNC, vnRet);
                return;
            }

            StopFlag            = true;
            gbxFpReader.Enabled = true;

            GetDbFingerData(txtEmpNo.Text, txtFingerNo.Text);
            EnrollImport();
            txtInfo.Text    = Pub.GetResText(formCode, "MsgInitSuccess", "");
            btnInit.Enabled = false;
        }
Example #5
0
        private void Verify()
        {
            int vnRet;
            //控制设备灯
            int temp_DeviceCompany = deviceCompany;

            if (temp_DeviceCompany == ObjFpReader.PRODUCT_HYSOON)
            {
                ObjFpReader.pisLedControl(contextId, ObjFpReader.PISFP_ALLLED, ObjFpReader.PISFP_LED_OFF);
                ObjFpReader.pisLedControl(contextId, ObjFpReader.PISFP_BKLED, ObjFpReader.PISFP_LED_ON);
            }
            else if (temp_DeviceCompany == ObjFpReader.PRODUCT_TAIWAN)
            {
                ObjFpReader.pisLedControl(contextId, ObjFpReader.PISFP_BKLED, ObjFpReader.PISFP_LED_ON);
            }

            if (StopFlag)
            {
                StopFlag = false;
            }
            int  isCheckFp = 0, fpArea = 0;
            bool doubleCheckFlag = true;

            ObjFpReader.CaptureFpStatus capFpStatus = ObjFpReader.CaptureFpStatus.CapFp_Init;
            while (!StopFlag)
            {
                Application.DoEvents();
                memset(feature[0], 0x00, featureSize);
                memset(updatedTemplate, 0x00, templateSize);

                vnRet = ObjFpReader.pisCapture(contextId, imageBuffer);
                if (vnRet == ObjFpReader.PISFP_ERR_NOT_CONNECT_DEV)
                {
                    ErrorDescription(ObjFpReader.VERIFY_PROC, ObjFpReader.CAPTURE_FUNC, vnRet);

                    ObjFpReader.pisCloseDevice(contextId);

                    vnRet = ObjFpReader.pisOpenDevice(contextId, devIdList[cbbDevice.SelectedIndex]);
                    System.Threading.Thread.Sleep(1000);
                    continue;
                }
                else if (vnRet != ObjFpReader.PISFP_OK)
                {
                    ErrorDescription(ObjFpReader.VERIFY_PROC, ObjFpReader.CAPTURE_FUNC, vnRet);
                    ObjFpReader.pisLedControl(contextId, ObjFpReader.PISFP_ALLLED, ObjFpReader.PISFP_LED_OFF);
                    return;
                }

                DrawFpImage();

                vnRet        = ObjFpReader.pisCheckFp(contextId, imageBuffer, imageWidth, imageHeight, imageRes, ref isCheckFp, ref fpArea);
                txtInfo.Text = string.Empty;
                //初始化
                if (capFpStatus == ObjFpReader.CaptureFpStatus.CapFp_Init)
                {
                    if (isCheckFp != 0)
                    {
                        txtInfo.Text = Pub.GetResText(formCode, "MsgLeaveFinger", "");
                        continue;
                    }
                    else
                    {
                        capFpStatus = ObjFpReader.CaptureFpStatus.CapFp_WaitPressFinger;
                    }
                }

                //等待手指按下时的操作
                if (capFpStatus == ObjFpReader.CaptureFpStatus.CapFp_WaitPressFinger)
                {
                    if (isCheckFp == 0)
                    {
                        continue;
                    }

                    if (fpArea > 80)
                    {
                        capFpStatus = ObjFpReader.CaptureFpStatus.CapFp_GoodFpCaptured;
                    }
                }

                //处理获取到的图片
                if (capFpStatus == ObjFpReader.CaptureFpStatus.CapFp_GoodFpCaptured)
                {
                    // 使用最大指纹图像提取指纹
                    if (ObjFpReader.pisProcess(contextId, imageBuffer, imageWidth, imageHeight, imageRes,
                                               feature[0]) != ObjFpReader.PISFP_OK)
                    {
                        continue;
                    }

                    //检查fpdata是否已经存在
                    if (doubleCheckFlag == true)
                    {
                        int identifiedID = 0;
                        vnRet = ObjFpReader.pisIdentify(contextId, feature[0],
                                                        ref identifiedID, updatedTemplate, ref updatedFlag);

                        if (vnRet == ObjFpReader.PISFP_OK)
                        {
                            txtInfo.Text = string.Format("{0} - {1}", txtEmpNo.Text, identifiedID);
                        }
                        else
                        {
                            if (isCheckFp != 0)
                            {
                                txtInfo.Text = Pub.GetResText(formCode, "MsgFPunregistered", "");
                            }
                        }
                        //txtInfo.Text = string.Empty;
                        if (isCheckFp == 0)
                        {
                            capFpStatus = ObjFpReader.CaptureFpStatus.CapFp_Init;
                        }
                        continue;
                    }
                }
            }

            if (temp_DeviceCompany == ObjFpReader.PRODUCT_HYSOON || temp_DeviceCompany == ObjFpReader.PRODUCT_TAIWAN)
            {
                ObjFpReader.pisLedControl(contextId, ObjFpReader.PISFP_BKLED, ObjFpReader.PISFP_LED_OFF);
            }

            if (StopFlag == true)
            {
                txtInfo.Text = Pub.GetResText(formCode, "MsgStop", "");

                return;
            }
        }