Exemplo n.º 1
0
 /// <summary>
 /// 根据错误代码获取错误信息
 /// </summary>
 /// <param name="nErrorCode"></param>
 /// <returns></returns>
 public string GetErrorStr(int nErrorCode)
 {
     return(Fingerdll.ZAZErr2Strt(nErrorCode));
 }
Exemplo n.º 2
0
        /// <summary>
        /// 获取指纹
        /// </summary>
        /// <param name="buffer">指纹在设备中临时存放位置 1 2</param>
        /// <returns></returns>
        public bool GetFinger(int buffer = 1)
        {
            TimeOut = 20;
            int ret = 0;

            byte[] ImgData = new byte[Image_Size];
            int[]  ImgLen  = new int[1];
            int    iBuffer = buffer;

BEIG1:
            ret = Fingerdll.ZAZGetImage(hHandle, nDevAddr);  //获取图象
            if (ret == 0)
            {
                ShowInfomation("获取图像成功...");
            }
            else if (ret == 2)
            {
                //超时判断
                ShowInfomation("等待手指平放在传感器上-" + TimeOut.ToString() + "秒");
                if (TimeOut < 0)
                {
                    ShowInfomation("等待超时");
                    return(false);
                }
                TimeOut--;
                Thread.Sleep(1000);
                goto BEIG1;
            }
            else
            {
                ShowInfomation(Fingerdll.ZAZErr2Strt(ret));
                return(false);
            }

            //////////////////////////////////////////////////////////////////////////
            //不涉及图像,下面可以省略
            /****************上传图像*********/

            ShowInfomation("正在上传图像请等待...");
            ret = Fingerdll.ZAZUpImage(hHandle, nDevAddr, ImgData, ImgLen);  //上传图象
            if (ret != 0)
            {
                ShowInfomation(Fingerdll.ZAZErr2Strt(ret));
                return(false);
            }
            //strFile = System.Windows.Forms.Application.StartupPath + "\\ZAZFinger.bmp";
            string strFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "ZAZFinger.bmp");

            ret = Fingerdll.ZAZImgData2BMP(ImgData, strFile);
            if (ret != 0)
            {
                ShowInfomation(Fingerdll.ZAZErr2Strt(ret));
                return(false);
            }
            ShowImage(strFile);
            //ret = Fingerdll.ZAZShowFingerData(fpbmp.Handle, ref ImgData[0]);
            //////////////////////////////////////////////////////////////////////////
            /****************生成特征 *********/
            ret = Fingerdll.ZAZGenChar(hHandle, nDevAddr, iBuffer);  //生成模板
            if (ret != 0)
            {
                ShowInfomation(Fingerdll.ZAZErr2Strt(ret));
                return(false);
            }
            else
            {
                ShowInfomation("生成指纹特征" + buffer.ToString());
            }
            Thread.Sleep(10);
BEIG2:
            if (ret == 0)
            {                                                   //超时判断
                string strTemp;
                ret = Fingerdll.ZAZGetImage(hHandle, nDevAddr); //获取图象
                ShowInfomation("等待手指拿开-");
                // if (timeout < 0)
                // { ShowInfomation("等待超时"); return 0; }
                // timeout--;
                // Thread.Sleep(10);
                goto BEIG2;
            }
            else if (ret == 1)
            {
                ShowInfomation(Fingerdll.ZAZErr2Strt(ret));
                return(false);
            }
            return(true);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 生成指纹图像
        /// </summary>
        /// <returns></returns>
        public bool GetFingerImage(UInt32 nDevAddr, int iBuffer)
        {
            byte[] ImgData = new byte[Image_Size];
            int[]  ImgLen  = new int[1];
            int    timeout = 0;

            //while (Ret == 2)
            //{
            //    Ret = Fingerdll.ZAZGetImage(hHandle, nDevAddr);  //获取图象
            //    this.MessageStr = "请将手指平放在传感器上...";
            //    Thread.Sleep(100);
            //    timeout++;
            //    if (timeout > 100)
            //        return false;
            //}

            Ret = Fingerdll.ZAZGetImage(hHandle, nDevAddr);  //获取图象
            if (Ret == 2)
            {
                this.MessageStr = "请将手指平放在传感器上...";
            }
            else if (Ret == 0)
            {
                this.MessageStr = "获取图像成功...";
                if (IsUsb)
                {
                    this.MessageStr = "正在上传图像请等待...";
                    Ret             = Fingerdll.ZAZUpImage(hHandle, nDevAddr, ImgData, ImgLen); //上传图象
                    if (Ret != 0)
                    {
                        this.MessageStr = Fingerdll.ZAZErr2Strt(Ret);
                        return(false);
                    }
                    string strFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "ZAZFinger.bmp");
                    Ret = Fingerdll.ZAZImgData2BMP(ImgData, strFile);
                    if (Ret != 0)
                    {
                        this.MessageStr = Fingerdll.ZAZErr2Strt(Ret);
                        return(false);
                    }
                    FileStream pFileStream = new FileStream(strFile, FileMode.Open, FileAccess.Read);
                    this.CurrentImage = Image.FromStream(pFileStream);
                    return(true);
                }

                //////////////////////////////////////////////////////////////////////////
                /****************生成特征 *********/
                Ret = Fingerdll.ZAZGenChar(hHandle, nDevAddr, iBuffer);  //生成模板
                if (Ret != 0)
                {
                    this.MessageStr = Fingerdll.ZAZErr2Strt(Ret);
                    return(false);
                }
                else
                {
                    this.MessageStr = "生成指纹特征" + iBuffer.ToString();
                }
BEIG2:
                if (ret == 0)
                {                                                               //超时判断
                    Ret             = Fingerdll.ZAZGetImage(hHandle, nDevAddr); //获取图象
                    this.MessageStr = "等待手指拿开-";
                    goto BEIG2;
                }
                if (Ret == 1)
                {
                    this.MessageStr = Fingerdll.ZAZErr2Strt(Ret);
                    return(false);
                }
            }
            else
            {
                this.MessageStr = Fingerdll.ZAZErr2Strt(ret);
            }
            return(false);
        }
Exemplo n.º 4
0
        /// <summary>
        /// 注册指纹
        /// </summary>
        /// <returns></returns>
        public bool RegistFinger(int fingerId)
        {
            this.FingerId = fingerId;
            int    devce_usb = 0;
            UInt32 nDevAddr  = 0xffffffff;
            int    ImgLen    = 0;
            string strFile   = "";
            string sPath     = "";
            int    iBuffer   = 0;
            int    timeout   = 20; //定义等待超时
            int    m_Addr    = 1;  //本例将指纹存储在设备库位置1中

            if (this.Status == false)
            {
                this.MessageStr = "请先打开设备";
                return(false);
            }
            //获取指纹图像  4.上传指纹图像(可省略) 5.显示指纹图像(可省略)  6.生成特征A
            if (!ZAZGenChar1)
            {
                if (GetFingerImage(nDevAddr, 1))
                {
                    ZAZGenChar1 = true;
                }
                else
                {
                    return(false);
                }
            }
            //获取指纹图像  8.上传指纹图像(可省略) 9.显示指纹图像(可省略) 10.生成特征B
            if (!ZAZGenChar2)
            {
                if (GetFingerImage(nDevAddr, 2))
                {
                    ZAZGenChar2 = true;
                }
                else
                {
                    return(false);
                }
            }
            /****************合成模板*********/
            Ret = Fingerdll.ZAZRegModule(hHandle, nDevAddr);  //合并特征
            if (ret != 0)
            {
                this.MessageStr = Fingerdll.ZAZErr2Strt(ret);
                return(false);
            }
            else
            {
                this.MessageStr = "合成指纹模板成功";
            }

            //本例以存在在指纹设备库中进行
            ret = Fingerdll.ZAZStoreChar(hHandle, nDevAddr, 1, this.FingerId);    //存放模板
            if (ret != 0)
            {
                this.MessageStr = Fingerdll.ZAZErr2Strt(ret);
                return(false);
            }
            else
            {
                this.MessageStr = "存储指纹成功";
                return(true);
            }
        }