Beispiel #1
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);
        }
Beispiel #2
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;
            }
        }