示例#1
0
 private void frmTouch_FormClosed(object sender, FormClosedEventArgs e)
 {
     if (fThread != null)
     {
         fThread.Abort();
     }
     OpticalDriver.mxCancelGetImage(0);
 }
示例#2
0
        //
        private void GetImage_Thread()
        {
            string strFileName = "d:\\";
            int    lRV         = 0;

            byte[] FingerBuf = new byte[304 * 256]; //图像缓冲区

            try
            {
                //获取图像
                label1.Text = "获取指纹图像,请按手指......";
                lRV         = OpticalDriver.mxGetImage(0, FingerBuf, 0, 1);
                if (lRV != 0)
                {
                    label1.Text = GetErrorInfo(lRV);
                    return;
                }
                else
                {
                    label1.Text  = "获取指纹图像成功";
                    strFileName += "image.bmp";
                    //图像数据流保存成bmp
                    OpticalDriver.mxSaveBMP(strFileName, FingerBuf, 256, 304);
                    //显示图像
                    pictureBox1.Image = Image.FromFile(strFileName);
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(this, e.Message, "异常");
            }
            finally
            {
                lRV = OpticalDriver.mxCancelGetImage(0);
                // EnabledButton(true); ;
            }
        }
示例#3
0
        //采集指纹
        private void clsTouch()
        {
            int lRV = 0;

            byte[] FingerBuf = new byte[304 * 256]; //图像缓冲区
            byte[] tzBuf1    = new byte[345];
            byte[] tzBuf2    = new byte[345];
            byte[] tzBuf3    = new byte[345];
            byte[] mbBuf     = new byte[345];

            //  EnabledButton(false);
            try
            {
                //获取指纹特征1
                label2.Text = "注册指纹,请按3次手指......";
                lRV         = OpticalDriver.mxGetImage(0, FingerBuf, 0, 1);
                if (lRV != 0)
                {
                    label2.Text = GetErrorInfo(lRV);
                    return;
                }
                //图像数据流保存成bmp
                OpticalDriver.mxSaveBMP("imageTz1.bmp", FingerBuf, 256, 304);
                //显示图像
                this.pictureBox2.Image = Image.FromFile("imageTz1.bmp");
                lRV = OpticalDriver.mxGetTzBase64(FingerBuf, tzBuf1);
                if (lRV != 0)
                {
                    label2.Text      = "获取指纹特征1失败";
                    btnTouch.Enabled = true;
                    return;
                }

                //获取指纹特征2
                label2.Text = "请按第2次手指......";
                lRV         = OpticalDriver.mxGetImage(0, FingerBuf, 0, 1);
                if (lRV != 0)
                {
                    label2.Text = GetErrorInfo(lRV);
                    return;
                }
                //图像数据流保存成bmp
                OpticalDriver.mxSaveBMP("imageTz2.bmp", FingerBuf, 256, 304);
                //显示图像
                this.pictureBox2.Image = Image.FromFile("imageTz2.bmp");
                lRV = OpticalDriver.mxGetTzBase64(FingerBuf, tzBuf2);
                if (lRV != 0)
                {
                    label2.Text      = "获取指纹特征2失败";
                    btnTouch.Enabled = true;
                    return;
                }

                //获取指纹特征3
                label2.Text = "请按第3次手指......";
                lRV         = OpticalDriver.mxGetImage(0, FingerBuf, 0, 1);
                if (lRV != 0)
                {
                    label2.Text = GetErrorInfo(lRV);
                    return;
                }
                //图像数据流保存成bmp
                OpticalDriver.mxSaveBMP("imageTz3.bmp", FingerBuf, 256, 304);
                //显示图像
                this.pictureBox2.Image = Image.FromFile("imageTz3.bmp");
                lRV = OpticalDriver.mxGetTzBase64(FingerBuf, tzBuf3);
                if (lRV != 0)
                {
                    label2.Text      = "获取指纹特征3失败";
                    btnTouch.Enabled = true;
                    return;
                }

                //合并模板
                lRV = OpticalDriver.mxGetMBBase64(tzBuf1, tzBuf2, tzBuf3, mbBuf);
                if (lRV != 0)
                {
                    label2.Text      = "合并模板失败";
                    btnTouch.Enabled = true;
                    return;
                }
                else
                {
                    //内存保存到本地文件
                    File.WriteAllBytes("Touch.dat", mbBuf);
                    label2.Text      = "注册指纹成功";
                    btnTouch.Enabled = true;
                }
            }
            catch (Exception e)
            {
                btnTouch.Enabled = true;
                //   MessageBox.Show(this, e.Message, "异常");
            }
            finally
            {
                btnTouch.Enabled = true;
                lRV = OpticalDriver.mxCancelGetImage(0);
                // EnabledButton(true); ;
            }
        }
示例#4
0
        private void VerifyFinger_Thread()
        {
            while (true)
            {
                int    lRV         = 0;
                byte[] FingerBuf   = new byte[304 * 256]; //图像缓冲区
                byte[] tzBuf       = new byte[345];
                byte[] mbBuf       = new byte[345];
                string strFileName = "";
                try
                {
                    lRV = OpticalDriver.mxGetImage(0, FingerBuf, 5000, 1);
                    if (lRV != 0)
                    {
                        // label1.Text = GetErrorInfo(lRV);
                    }
                    else
                    {
                        strFileName += "image1.bmp";
                        //图像数据流保存成bmp
                        OpticalDriver.mxSaveBMP(strFileName, FingerBuf, 256, 304);
                        //显示图像
                        // this.pictureBox1.Image = Image.FromFile(strFileName);
                        lRV = OpticalDriver.mxGetTzBase64(FingerBuf, tzBuf);
                        if (lRV != 0)
                        {
                            label1.Text = "获取指纹特征失败";
                            // return;
                        }
                        DataSet XiangMu4 = null;
                        if (!clsFormStatic.frmTouch1.sBanji.Equals(""))
                        {
                            threadT = new Thread(new ThreadStart(threadA));
                            threadT.Start();
                            SqlParameter jj = new SqlParameter("@BanjiID", clsFormStatic.frmTouch1.sBanji);
                            XiangMu4 = new SqlFile.clsSql().RunProcedure(sSqlTouch, "chaxunyundongyuanzhiwenxinxipipeibanji", new IDataParameter[] { jj }, "db");
                            if (frmLoading1.InvokeRequired)                  //判断是否有其他线程想访问
                            {
                                Action act = () => { frmLoading1.Close(); }; //封装一个窗体关闭的方法
                                frmLoading1.Invoke(act);                     //在拥有该控件的线程上执行该方法
                            }
                            if (threadT != null)
                            {
                                threadT.Abort();//关闭进程释
                            }
                            threadT1 = new Thread(new ThreadStart(threadB));
                            threadT1.Start();
                        }

                        int i;
                        if (XiangMu4 != null)
                        {
                            for (i = 0; i < XiangMu4.Tables[0].Rows.Count; i++)
                            {
                                if (XiangMu4.Tables[0].Rows[i][2].ToString().Equals("") == false)
                                {
                                    mbBuf = (byte[])XiangMu4.Tables[0].Rows[i][2];
                                    //验证指纹
                                    lRV = OpticalDriver.mxFingerMatchBase64(mbBuf, tzBuf, 3);
                                    if (lRV == 0)
                                    {
                                        label1.Text       = "  指纹比对成功!";
                                        lblNumber.Text    = XiangMu4.Tables[0].Rows[i][0].ToString();
                                        lblName.Text      = XiangMu4.Tables[0].Rows[i][1].ToString();
                                        pictureBox1.Image = Image.FromFile(strFileName);
                                        SelectImage(XiangMu4.Tables[0].Rows[i][0].ToString());
                                        goto gg;
                                    }
                                }
                                if (XiangMu4.Tables[0].Rows[i][3].ToString().Equals("") == false)
                                {
                                    mbBuf = (byte[])XiangMu4.Tables[0].Rows[i][3];
                                    //验证指纹
                                    lRV = OpticalDriver.mxFingerMatchBase64(mbBuf, tzBuf, 3);
                                    if (lRV == 0)
                                    {
                                        label1.Text       = "  指纹比对成功!";
                                        lblNumber.Text    = XiangMu4.Tables[0].Rows[i][0].ToString();
                                        lblName.Text      = XiangMu4.Tables[0].Rows[i][1].ToString();
                                        pictureBox1.Image = Image.FromFile(strFileName);
                                        SelectImage(XiangMu4.Tables[0].Rows[i][0].ToString());
                                        goto gg;
                                    }
                                }
                                if (XiangMu4.Tables[0].Rows[i][4].ToString().Equals("") == false)
                                {
                                    mbBuf = (byte[])XiangMu4.Tables[0].Rows[i][4];
                                    //验证指纹
                                    lRV = OpticalDriver.mxFingerMatchBase64(mbBuf, tzBuf, 3);
                                    if (lRV == 0)
                                    {
                                        label1.Text       = "  指纹比对成功!";
                                        lblNumber.Text    = XiangMu4.Tables[0].Rows[i][0].ToString();
                                        lblName.Text      = XiangMu4.Tables[0].Rows[i][1].ToString();
                                        pictureBox1.Image = Image.FromFile(strFileName);
                                        SelectImage(XiangMu4.Tables[0].Rows[i][0].ToString());
                                        goto gg;
                                    }
                                }
                                if (XiangMu4.Tables[0].Rows[i][5].ToString().Equals("") == false)
                                {
                                    mbBuf = (byte[])XiangMu4.Tables[0].Rows[i][5];
                                    //验证指纹
                                    lRV = OpticalDriver.mxFingerMatchBase64(mbBuf, tzBuf, 3);
                                    if (lRV == 0)
                                    {
                                        label1.Text       = "  指纹比对成功!";
                                        lblNumber.Text    = XiangMu4.Tables[0].Rows[i][0].ToString();
                                        lblName.Text      = XiangMu4.Tables[0].Rows[i][1].ToString();
                                        pictureBox1.Image = Image.FromFile(strFileName);
                                        SelectImage(XiangMu4.Tables[0].Rows[i][0].ToString());
                                        goto gg;
                                    }
                                }
                            }
                        }
                        if (frmLoading1.InvokeRequired)                  //判断是否有其他线程想访问
                        {
                            Action act = () => { frmLoading1.Close(); }; //封装一个窗体关闭的方法
                            frmLoading1.Invoke(act);                     //在拥有该控件的线程上执行该方法
                        }
                        if (threadT1 != null)
                        {
                            threadT1.Abort();//关闭进程释
                        }
                        threadT = new Thread(new ThreadStart(threadA));
                        threadT.Start();
                        DataSet XiangMu2 = new SqlFile.clsSql().RunProcedure(sSqlTouch, "chaxunyundongyuanzhiwenxinxipipei", new IDataParameter[] { }, "db");
                        if (frmLoading1.InvokeRequired)                  //判断是否有其他线程想访问
                        {
                            Action act = () => { frmLoading1.Close(); }; //封装一个窗体关闭的方法
                            frmLoading1.Invoke(act);                     //在拥有该控件的线程上执行该方法
                        }
                        if (threadT != null)
                        {
                            threadT.Abort();//关闭进程释
                        }
                        threadT = new Thread(new ThreadStart(threadB));
                        threadT.Start();
                        for (i = 0; i < XiangMu2.Tables[0].Rows.Count; i++)
                        {
                            if (XiangMu2.Tables[0].Rows[i][2].ToString().Equals("") == false)
                            {
                                mbBuf = (byte[])XiangMu2.Tables[0].Rows[i][2];
                                //验证指纹
                                lRV = OpticalDriver.mxFingerMatchBase64(mbBuf, tzBuf, 3);
                                if (lRV == 0)
                                {
                                    label1.Text       = "  指纹比对成功!";
                                    lblNumber.Text    = XiangMu2.Tables[0].Rows[i][0].ToString();
                                    lblName.Text      = XiangMu2.Tables[0].Rows[i][1].ToString();
                                    pictureBox1.Image = Image.FromFile(strFileName);
                                    SelectImage(XiangMu2.Tables[0].Rows[i][0].ToString());
                                    break;
                                }
                            }
                            if (XiangMu2.Tables[0].Rows[i][3].ToString().Equals("") == false)
                            {
                                mbBuf = (byte[])XiangMu2.Tables[0].Rows[i][3];
                                //验证指纹
                                lRV = OpticalDriver.mxFingerMatchBase64(mbBuf, tzBuf, 3);
                                if (lRV == 0)
                                {
                                    label1.Text       = "  指纹比对成功!";
                                    lblNumber.Text    = XiangMu2.Tables[0].Rows[i][0].ToString();
                                    lblName.Text      = XiangMu2.Tables[0].Rows[i][1].ToString();
                                    pictureBox1.Image = Image.FromFile(strFileName);
                                    SelectImage(XiangMu2.Tables[0].Rows[i][0].ToString());
                                    break;
                                }
                            }
                            if (XiangMu2.Tables[0].Rows[i][4].ToString().Equals("") == false)
                            {
                                mbBuf = (byte[])XiangMu2.Tables[0].Rows[i][4];
                                //验证指纹
                                lRV = OpticalDriver.mxFingerMatchBase64(mbBuf, tzBuf, 3);
                                if (lRV == 0)
                                {
                                    label1.Text       = "  指纹比对成功!";
                                    lblNumber.Text    = XiangMu2.Tables[0].Rows[i][0].ToString();
                                    lblName.Text      = XiangMu2.Tables[0].Rows[i][1].ToString();
                                    pictureBox1.Image = Image.FromFile(strFileName);
                                    SelectImage(XiangMu2.Tables[0].Rows[i][0].ToString());
                                    break;
                                }
                            }
                            if (XiangMu2.Tables[0].Rows[i][5].ToString().Equals("") == false)
                            {
                                mbBuf = (byte[])XiangMu2.Tables[0].Rows[i][5];
                                //验证指纹
                                lRV = OpticalDriver.mxFingerMatchBase64(mbBuf, tzBuf, 3);
                                if (lRV == 0)
                                {
                                    label1.Text       = "  指纹比对成功!";
                                    lblNumber.Text    = XiangMu2.Tables[0].Rows[i][0].ToString();
                                    lblName.Text      = XiangMu2.Tables[0].Rows[i][1].ToString();
                                    pictureBox1.Image = Image.FromFile(strFileName);
                                    SelectImage(XiangMu2.Tables[0].Rows[i][0].ToString());
                                    break;
                                }
                            }
                        }

                        if (i == XiangMu2.Tables[0].Rows.Count)
                        {
                            label1.Text            = "指纹比对失败";
                            this.pictureBox1.Image = Image.FromFile(strFileName);
                            lblNumber.Text         = "Null";
                            lblName.Text           = "Null";
                            lblClass.Text          = "Null";
                            lblImage.Visible       = true;
                            pictureBox2.Image      = null;
                        }
                        else
                        {
                            pictureBox1.Image = Image.FromFile(strFileName);
                        }
                        gg :;
                        if (frmLoading1.InvokeRequired)                  //判断是否有其他线程想访问
                        {
                            Action act = () => { frmLoading1.Close(); }; //封装一个窗体关闭的方法
                            frmLoading1.Invoke(act);                     //在拥有该控件的线程上执行该方法
                        }
                        if (threadT1 != null)
                        {
                            threadT1.Abort();//关闭进程释
                        }
                    }
                }
                catch (Exception e)
                {
                    //  MessageBox.Show(this, e.Message, "异常");
                }
                finally
                {
                    lRV = OpticalDriver.mxCancelGetImage(0);
                    btnSelect.Enabled = true;
                    fThread.Abort();
                    // EnabledButton(true); ;
                }
            }
        }