public FaceRecognitionLoginForm()
        {
            InitializeComponent();
            HasLoggedOn = false;            //默认未登陆

            var iniMgr = new CIniManager(@"Config\Admin.ini");

            if (!iniMgr.ExistIniFile())            //若配置文件不存在则退出
            {
                MessageBox.Show("缺少配置文件");
                Environment.Exit(Environment.ExitCode);
            }
            if (iniMgr.IniReadValue("FacialSecurity", "Signed") == "false")
            {
                btnLogin.Enabled = false;                //若没注册则没法登陆
            }

            //Load of previus trainned faces and labels for each image

            if (Eigen_Recog.IsTrained)
            {
                message_bar.Text  = "现在可以进行识别登陆!";
                btnSignIn.Visible = false;
            }
            else
            {
                message_bar.Text  = "没有发现存储的用户脸部图像, 请先注册!";
                btnSignIn.Visible = true;
            }
        }
Exemplo n.º 2
0
        //Delete all the old training data by simply deleting the folder

        /*     private void Delete_Data_BTN_Click(object sender, EventArgs e)
         *   {
         *       if (Directory.Exists(Application.StartupPath + "/TrainedFaces/"))
         *       {
         *           Directory.Delete(Application.StartupPath + "/TrainedFaces/", true);
         *           Directory.CreateDirectory(Application.StartupPath + "/TrainedFaces/");
         *           MessageBox.Show("已经成功删除所有原来的用户脸部照片!");
         *       }
         *   }
         */
        #region  钮等响应事件
        private void btnSignIn_Click(object sender, EventArgs e)
        {
            if (textBoxPassword.Text.Trim() == "")
            {
                MessageBox.Show("请输入密码!");
                return;
            }
            else if (textBoxConfirmPassword.Text.Trim() == "")
            {
                MessageBox.Show("请输入确认密码!");
                return;
            }
            else if (textBoxPassword.Text != textBoxConfirmPassword.Text)
            {
                MessageBox.Show("两次输入密码不一致!");
                return;
            }

            //todo::拍照并人脸识别
            ;

            //todo::把密码转换成MD5码放入数据库
            var MD5Obj = new MD5();

            ;

            //改写配置文件
            var iniMgr = new CIniManager(@"Config\Admin.ini");

            iniMgr.IniWriteValue("FacialSecurity", "Signed", "true");

            btnCancel_Click(sender, e);
        }
        private void btnSignIn_Click(object sender, EventArgs e)
        {
            //Stop Camera
            stop_capture();

            //OpenForm
            var signDlg = new SignInForm(this);

            signDlg.Show();

            if (signDlg.DialogResult == DialogResult.OK)
            {
                var iniMgr = new CIniManager(@"Config\Admin.ini");
                if (iniMgr.ExistIniFile() && iniMgr.IniReadValue("FacialSecurity", "Signed") == "true")               //验证配置文件
                {
                    btnLogin.Enabled = true;
                }
            }
        }