Beispiel #1
0
        private void btnIdentify_Click(object sender, EventArgs e)
        {
            UFD_STATUS ufd_res;
            UFM_STATUS ufm_res;

            // Input finger data
            byte[] Template = new byte[MAX_TEMPLATE_SIZE];
            int    TemplateSize;

            // DB data
            byte[][] DBTemplate     = null;
            int[]    DBTemplateSize = null;
            int[]    DBSerial       = null;
            int      DBTemplateNum;
            //
            int MatchIndex;

            ufd_res = m_Database.GetTemplateListWithSerial(out DBTemplate, out DBTemplateSize, out DBTemplateNum, out DBSerial);
            if (ufd_res != UFD_STATUS.OK)
            {
                UFDatabase.GetErrorString(ufd_res, out m_strError);
                tbxMessage.AppendText("UFD_GetTemplateListWithSerial: " + m_strError + "\r\n");
                return;
            }

            if (!ExtractTemplate(Template, out TemplateSize))
            {
                return;
            }

            DrawCapturedImage(m_Scanner);

            Cursor.Current = Cursors.WaitCursor;
            ufm_res        = m_Matcher.Identify(Template, TemplateSize, DBTemplate, DBTemplateSize, DBTemplateNum, 5000, out MatchIndex);
            Cursor.Current = this.Cursor;
            if (ufm_res != UFM_STATUS.OK)
            {
                UFMatcher.GetErrorString(ufm_res, out m_strError);
                tbxMessage.AppendText("UFMatcher Identify: " + m_strError + "\r\n");
                return;
            }

            if (MatchIndex != -1)
            {
                tbxMessage.AppendText("Identification succeed (Serial = " + DBSerial[MatchIndex] + ")\r\n");
            }
            else
            {
                tbxMessage.AppendText("Identification failed\r\n");
            }
        }
        private void btnIdentify_Click(object sender, EventArgs e)
        {
            UFScanner  Scanner;
            UFS_STATUS ufs_res;
            UFM_STATUS ufm_res;

            byte[] Template = new byte[MAX_TEMPLATE_SIZE];
            int    TemplateSize;
            int    EnrollQuality;
            int    MatchIndex;

            if (!GetGetCurrentScanner(out Scanner))
            {
                return;
            }
            Scanner.ClearCaptureImageBuffer();

            tbxMessage.AppendText("Place Finger\r\n");

            ufs_res = Scanner.CaptureSingleImage();
            if (ufs_res != UFS_STATUS.OK)
            {
                UFScanner.GetErrorString(ufs_res, out m_strError);
                tbxMessage.AppendText("UFScanner CaptureSingleImage: " + m_strError + "\r\n");
                return;
            }

            switch (this.cbScanTemplateType.SelectedIndex)
            {
            case 0:
                Scanner.nTemplateType = 2001;
                break;

            case 1:
                Scanner.nTemplateType = 2002;
                break;

            case 2:
                Scanner.nTemplateType = 2003;
                break;
            }

            ufs_res = Scanner.Extract(Template, out TemplateSize, out EnrollQuality);
            if (ufs_res == UFS_STATUS.OK)
            {
                DrawCapturedImage(Scanner);
            }
            else
            {
                UFScanner.GetErrorString(ufs_res, out m_strError);
                tbxMessage.AppendText("UFScanner Extract: " + m_strError + "\r\n");
                return;
            }

            switch (this.cbMatchTemplateType.SelectedIndex)
            {
            case 0:
                m_Matcher.nTemplateType = 2001;
                break;

            case 1:
                m_Matcher.nTemplateType = 2002;
                break;

            case 2:
                m_Matcher.nTemplateType = 2003;
                break;
            }

            Cursor.Current = Cursors.WaitCursor;
            //*
            ufm_res = m_Matcher.Identify(Template, TemplateSize, m_template, m_template_size, m_template_num, 5000, out MatchIndex);
            //ufm_res = m_Matcher.IdentifyMT(Template, TemplateSize, m_template, m_template_size, m_template_num, 5000, out MatchIndex);

            /*/
             * {
             *      byte[,] Template2 = new byte[m_template_num, MAX_TEMPLATE_SIZE];
             *      int i, j;
             *      for (j = 0; j < m_template_num; j++) {
             *              for (i = 0; i < m_template_size[j]; i++) {
             *                      Template2[j,i] = m_template[j][i];
             *              }
             *      }
             *      ufm_res = m_Matcher.Identify(Template, TemplateSize, m_template, m_template_size, m_template_num, 5000, out MatchIndex);
             * }
             * //*/
            Cursor.Current = this.Cursor;
            if (ufm_res != UFM_STATUS.OK)
            {
                UFMatcher.GetErrorString(ufm_res, out m_strError);
                tbxMessage.AppendText("UFMatcher Identify: " + m_strError + "\r\n");
                return;
            }

            if (MatchIndex != -1)
            {
                tbxMessage.AppendText("Identification succeed (No." + (MatchIndex + 1) + ")\r\n");
            }
            else
            {
                tbxMessage.AppendText("Identification failed\r\n");
            }
        }
        private void btnIdentify_Click(object sender, EventArgs e)
        {
            UFScanner  Scanner;
            UFS_STATUS ufs_res;
            UFM_STATUS ufm_res;

            byte[] Template = new byte[MAX_TEMPLATE_SIZE];
            int    TemplateSize;
            int    EnrollQuality;
            int    MatchIndex;

            byte[][] template_all;
            int[]    templateSize_all;
            int[]    nindex;
            int      i, j = 0, nMaxTemplateNum = 0;

            template_all     = new byte[MAX_TEMPLATE_NUM * 2][];
            templateSize_all = new int[MAX_TEMPLATE_NUM * 2];
            nindex           = new int[MAX_TEMPLATE_NUM * 2];

            for (i = 0; i < m_template_num * 2; i++)
            {
                template_all[i]     = new byte[MAX_TEMPLATE_SIZE];
                templateSize_all[i] = 0;
            }

            for (i = 0; i < m_template_num * 2; i++)
            {
                if (i < m_template_num)
                {
                    if (m_template_size1[i] != 0)
                    {
                        System.Array.Copy(m_template1[i], 0, template_all[j], 0, m_template_size1[i]);
                        templateSize_all[j] = m_template_size1[i];
                        nindex[j]           = i;
                        j++;
                    }
                }
                else
                {
                    if (m_template_size2[i - m_template_num] != 0)
                    {
                        System.Array.Copy(m_template2[i - m_template_num], 0, template_all[j], 0, m_template_size2[i - m_template_num]);
                        templateSize_all[j] = m_template_size2[i - m_template_num];
                        nindex[j]           = i - m_template_num;
                        j++;
                    }
                }
            }

            nMaxTemplateNum = j;

            if (!GetGetCurrentScanner(out Scanner))
            {
                return;
            }
            Scanner.ClearCaptureImageBuffer();

            tbxMessage.AppendText("Place Finger\r\n");

            ufs_res = Scanner.CaptureSingleImage();
            if (ufs_res != UFS_STATUS.OK)
            {
                UFScanner.GetErrorString(ufs_res, out m_strError);
                tbxMessage.AppendText("UFScanner CaptureSingleImage: " + m_strError + "\r\n");
                return;
            }

            switch (this.cbScanTemplateType.SelectedIndex)
            {
            case 0:
                Scanner.nTemplateType = 2001;
                break;

            case 1:
                Scanner.nTemplateType = 2002;
                break;

            case 2:
                Scanner.nTemplateType = 2003;
                break;
            }

            ufs_res = Scanner.ExtractEx(MAX_TEMPLATE_SIZE, Template, out TemplateSize, out EnrollQuality);
            if (ufs_res == UFS_STATUS.OK)
            {
                DrawCapturedImage(Scanner);
            }
            else
            {
                UFScanner.GetErrorString(ufs_res, out m_strError);
                tbxMessage.AppendText("UFScanner ExtractEx: " + m_strError + "\r\n");
                return;
            }

            switch (this.cbScanTemplateType.SelectedIndex)
            {
            case 0:
                m_Matcher.nTemplateType = 2001;
                break;

            case 1:
                m_Matcher.nTemplateType = 2002;
                break;

            case 2:
                m_Matcher.nTemplateType = 2003;
                break;
            }

            Cursor.Current = Cursors.WaitCursor;
            //*
            ufm_res = m_Matcher.Identify(Template, TemplateSize, template_all, templateSize_all, nMaxTemplateNum, 5000, out MatchIndex);
            //ufm_res = m_Matcher.IdentifyMT(Template, TemplateSize, template_all, templateSize_all, nMaxTemplateNum, 5000, out MatchIndex);

            /*/
             * {
             *      byte[,] Template2 = new byte[m_template_num, MAX_TEMPLATE_SIZE];
             *      int i, j;
             *      for (j = 0; j < m_template_num; j++) {
             *              for (i = 0; i < m_template_size[j]; i++) {
             *                      Template2[j,i] = m_template[j][i];
             *              }
             *      }
             *      ufm_res = m_Matcher.Identify(Template, TemplateSize, m_template, m_template_size, m_template_num, 5000, out MatchIndex);
             * }
             * //*/
            Cursor.Current = this.Cursor;
            if (ufm_res != UFM_STATUS.OK)
            {
                UFMatcher.GetErrorString(ufm_res, out m_strError);
                tbxMessage.AppendText("UFMatcher Identify: " + m_strError + "\r\n");
                return;
            }

            if (MatchIndex != -1)
            {
                tbxMessage.AppendText("Identification succeed (Match Index." + MatchIndex + ") (Match Serial." + nindex[MatchIndex] % nMaxTemplateNum + ") (ID." + m_UserID[nindex[MatchIndex]] + ")\r\n");
            }
            else
            {
                tbxMessage.AppendText("Identification failed\r\n");
            }
        }
Beispiel #4
0
        public string GetCardID()
        {
            try
            {
                Log("Start Get Card ID");
                byte[][] DBTemplate     = null;
                int[]    DBTemplateSize = null;
                int[]    DBSerial       = null;
                int      DBTemplateNum;
                int      nMatchIndex;
                // Initialize scanners
                UFS_STATUS ufs_res = new UFS_STATUS();
                int        nScannerNumber;

                ufs_res = m_ScannerManager.Init();

                nScannerNumber = m_ScannerManager.Scanners.Count;

                if (nScannerNumber <= 0)
                {
                    strLastError = "There are no suprema scanner";
                    Log(strLastError);
                    return("");
                }

                m_Scanner = m_ScannerManager.Scanners[0];

                // Database
                m_Database = new UFDatabase();

                if (m_szConnectionString != null)
                {
                    m_ufd_res = m_Database.Open(m_szConnectionString, "", "");
                }

                // Create matcher
                m_Matcher = new UFMatcher();
                if (!ExtractTemplate(m_bTemplate1, out m_nTemplateSize1))
                {
                    m_ScannerManager.Uninit();
                    m_Database.Close();
                    return("");
                }

                m_ScannerManager.Uninit();
                //Identify      loyee fingerprint :GetTemplateListWithSerial
                m_ufd_res = m_Database.GetTemplateListWithSerial(out DBTemplate, out DBTemplateSize, out DBTemplateNum, out DBSerial);
                //Identify employee fingerprint :Identify
                m_ufm_res = m_Matcher.Identify(m_bTemplate1, m_nTemplateSize1, DBTemplate, DBTemplateSize, DBTemplateNum, 5000, out nMatchIndex);
                string m_strUserID    = "";
                int    m_nFingerIndex = 0;
                string memo           = "";
                int    x = 0;
                if (nMatchIndex >= 0 && DBSerial != null)
                {
                    m_ufd_res = m_Database.GetDataBySerial(DBSerial[nMatchIndex], out m_strUserID, out m_nFingerIndex, m_bTemplate1, out m_nTemplateSize1, null, out x, out memo);
                }
                else
                {
                    m_strUserID = "";
                }

                if (m_ufm_res != UFM_STATUS.OK)
                {
                    return("");
                }

                Log(m_strUserID.Replace('\0', ' ').Trim());
                return(m_strUserID.Replace('\0', ' ').Trim());
            }
            catch (Exception ex)
            {
                strLastError = "Unkown Error Happened:\n" + ex.Message;
                Log(strLastError);
                return("");
            }
        }
Beispiel #5
0
        public bool Enroll(string nUserID, string strUserName, int FingerIndex = 1)
        {
            bool bRet = false;

            try
            {
                //ErrorMessage = "";
                UFS_STATUS ufs_status;
                int        nScannerNumber;

                ufs_status = m_ScannerManager.Init();

                nScannerNumber = m_ScannerManager.Scanners.Count;

                if (nScannerNumber <= 0)
                {
                    strLastError = "There are no suprema scanner";
                    Log(strLastError);
                    return(false);
                }

                m_Scanner = m_ScannerManager.Scanners[0];
                // Open database
                m_Database = new UFDatabase();
                //string szDataSource;
                if (m_szConnectionString != string.Empty)
                {
                    m_ufd_res = m_Database.Open(m_szConnectionString, "", "");
                }
                else
                {
                    return(false);
                }
                if (m_ufd_res != UFD_STATUS.OK)
                {
                    return(false);
                }
                // Create matcher
                m_Matcher = new UFMatcher();
                if (!ExtractTemplate(m_bTemplate1, out m_nTemplateSize1))
                {
                    return(false);
                }
                m_ScannerManager.Uninit();

                #region Check if the finger is used before for other user

                byte[][] DBTemplate     = null;
                int[]    DBTemplateSize = null;
                int[]    DBSerial       = null;
                int      DBTemplateNum;
                int      nMatchIndex;
                string   m_strUserID    = "";
                int      m_nFingerIndex = 0;
                string   memo           = "";
                int      x = 0;

                m_ufd_res = m_Database.GetTemplateListWithSerial(out DBTemplate, out DBTemplateSize, out DBTemplateNum, out DBSerial);
                m_ufm_res = m_Matcher.Identify(m_bTemplate1, m_nTemplateSize1, DBTemplate, DBTemplateSize, DBTemplateNum, 5000, out nMatchIndex);

                if (nMatchIndex >= 0 && DBSerial != null)
                {
                    m_ufd_res = m_Database.GetDataBySerial(DBSerial[nMatchIndex], out m_strUserID, out m_nFingerIndex, m_bTemplate1, out m_nTemplateSize1, null, out x, out memo);
                    if (m_strUserID.Replace('\0', ' ').Trim() != nUserID && m_nFingerIndex == FingerIndex)
                    {
                        strLastError = "This fingerprint is used for another person";
                        Log(strLastError);
                        return(false);
                    }
                }

                #endregion

                m_ufd_res = m_Database.AddData(nUserID.ToString(), FingerIndex, m_bTemplate1, m_nTemplateSize1, null, 0, "");
                if (m_ufd_res == UFD_STATUS.OK)
                {
                    bRet = true;
                }
                else if (m_ufd_res == UFD_STATUS.ERR_SAME_FINGER_EXIST)
                {
                    m_ufd_res = m_Database.UpdateDataByUserInfo(nUserID, FingerIndex, m_bTemplate1, m_nTemplateSize1, null, 0, null);
                    if (m_ufd_res == UFD_STATUS.OK)
                    {
                        bRet = true;
                    }
                }
            }
            catch (Exception ex)
            {
                strLastError = "Unkown Error Happened:\n" + ex.Message;
                Log(strLastError);
            }

            return(bRet);
        }