Exemple #1
0
        private void DoCapture()
        {
            int nRet = zkfperrdef.ZKFP_ERR_OK;

            while (!m_bThreadStop)
            {
                if (m_bCapture)
                {
                    m_cbfpTemplate = 2048;
                    nRet           = ZKFPControl.AcquireFingerprint(m_hDevice, m_FpImage, m_cbFpImage, m_fpTemplate, ref m_cbfpTemplate);
                    if (nRet == zkfperrdef.ZKFP_ERR_OK)
                    {
                        if (m_cbFpImage > 0 && m_cbfpTemplate > 0)
                        {
                            mRegFPTemps[0]   = m_fpTemplate;
                            mcbRegFPTemps[0] = m_cbfpTemplate;
                            //int i= SendMessage(FingerHandle, MESSAGE_CAPTURED_OK, IntPtr.Zero, IntPtr.Zero);
                            this.setImage();
                        }
                    }
                }
                Thread.Sleep(200);
            }
        }
Exemple #2
0
        private void Init()
        {
            //打开设备
            //步骤1 Init
            //步骤2 GetDeviceCount()
            //步骤3 如果设备数>=1,才OpenDevice
            //步骤4 DBInit
            int nRet = zkfperrdef.ZKFP_ERR_OK;

            if (IntPtr.Zero != m_hDevice)
            {
                MessageBox.Show("设备已打开!");
                return;
            }

            if (!m_bInit)
            {
                if (nRet != ZKFPControl.Init())
                {
                    MessageBox.Show("初始化失败!");
                }
                m_bInit = true;
            }

            if (ZKFPControl.GetDeviceCount() <= 0)
            {
                MessageBox.Show("未找到设备!");
                return;
            }

            m_hDevice = ZKFPControl.OpenDevice(0);
            if (IntPtr.Zero == m_hDevice)
            {
                MessageBox.Show("设备打开失败!");
                return;
            }

            //byte[] paramValue = new byte[64];
            //int cbParamValue = 64;
            //byte[] HUNAMEFENGLIN = System.Text.Encoding.Default.GetBytes("HNFL2017");
            //if (0 == ZKFPControl.GetParameter(m_hDevice, 1104, paramValue, ref cbParamValue))
            //{
            //    if (!paramValue.SequenceEqual(HUNAMEFENGLIN))
            //    {
            //        //ZKFPControl.CloseDevice(m_hDevice);
            //       // m_hDevice = IntPtr.Zero;
            //        textBox.Text = "FwName != HNFL2017";

            //    }
            //}
            //byte[] paramValue1 = new byte[64];
            //int cbParamValue1 = 64;
            //if(0 == ZKFPControl.GetFwName(m_hDevice, paramValue1, cbParamValue1))
            //{
            //    MessageBox.Show(System.Text.Encoding.Default.GetString(paramValue1));
            //    //if (!paramValue1.SequenceEqual(HUNAMEFENGLIN))
            //    //{
            //    //    //ZKFPControl.CloseDevice(m_hDevice);
            //    //    //m_hDevice = IntPtr.Zero;
            //    //    MessageBox.Show("FwName != HNFL2017");

            //    //}
            //}
            m_hDBCache = ZKFPControl.DBInit();
            if (m_hDBCache == IntPtr.Zero)
            {
                MessageBox.Show("设备初始化失败!");
                return;
            }
            int size = 4;

            byte[] width  = new byte[4];
            byte[] height = new byte[4];
            ZKFPControl.GetParameter(m_hDevice, 1, width, ref size);
            m_Width = BitConverter.ToInt32(width, 0);
            //m_Width =Convert .ToInt32( System.Text.Encoding.Default.GetString(width));
            size = 4;
            ZKFPControl.GetParameter(m_hDevice, 2, height, ref size);
            m_Height = BitConverter.ToInt32(height, 0);
            //m_Height =Convert .ToInt32( System.Text.Encoding.Default.GetString(width));

            m_FpImage     = new byte[m_Width * m_Height];
            m_cbFpImage   = m_Width * m_Height;
            m_fpTemplate  = new byte[2048];
            m_bThreadStop = false;
            Thread captureThread = new Thread(new ThreadStart(DoCapture));

            captureThread.IsBackground = true;
            captureThread.Start();
            mRegFPTemps[0] = new byte[2048];
            mRegFPTemps[1] = new byte[2048];
            mRegFPTemps[2] = new byte[2048];
            m_bCapture     = true;
        }