Exemple #1
0
        private void button2_Click(object sender, EventArgs e)
        {
            learn();
            string name;
            int    resultat = 0;

            using (var imageFrame = capture.QuerySmallFrame().ToImage <Bgr, Byte>())
            {
                if (imageFrame != null)
                {
                    var  grayframe  = imageFrame.Convert <Gray, byte>();
                    var  Faces      = cascadeClassifier.DetectMultiScale(grayframe, 1.1, 10, Size.Empty); //the actual face detection happens here
                    var  grayframe2 = grayframe.Resize(300, 500, interpolationType: Inter.Cubic);
                    bool found      = false;
                    foreach (var face in Faces)
                    {
                        imageFrame.Draw(face, new Bgr(Color.BurlyWood), 3); //the detected face(s) is highlighted here using a box that is drawn around it/them
                        FaceRecognizer.PredictionResult pre = recognizer.Predict(grayframe2);

                        MessageBox.Show(pre.Label.ToString());



                        for (int j = 0; j < faces.Count; j++)
                        {
                            if (Int32.Parse(faces[j].cin) == pre.Label)
                            {
                                login.ValidatedEns.cin           = faces[j].cin;
                                login.ValidatedEns.mots_de_passe = faces[j].mots_de_passe;
                                login.ValidatedEns.nom           = faces[j].nom;
                                login.ValidatedEns.prenom        = faces[j].prenom;
                                login.ValidatedEns.mail          = faces[j].mail;
                                login.ValidatedEns.photo         = faces[j].photo;
                                login.ValidatedEns.code_a_bar    = faces[j].code_a_bar;
                                login.ValidatedEns.Année         = faces[j].Année;
                                login.ValidatedEns.NiveauEtud    = faces[j].NiveauEtud;

                                found = true;
                                break;
                            }
                        }
                        if (found)
                        {
                            Accueil_Etudiant ac = new Accueil_Etudiant();
                            ac.Show();
                            break;
                        }
                    }

                    pictureBox2.Image = imageFrame.ToBitmap();
                }
            }
        }
Exemple #2
0
        private void bunifuFlatButton1_Click_1(object sender, EventArgs e)
        {
            etudiant en = new etudiant();

            en.cin           = cin;
            en.mots_de_passe = pass;

            try
            {
                db = new EtudiantLoginDataContext();
                var query = from enseignant in db.etudiants
                            where enseignant.cin == en.cin
                            select enseignant;
                List <etudiant> listeEns = query.ToList <etudiant>();
                if (listeEns.Count == 0)
                {
                    MessageBox.Show("cin introuvable veuillez vérifier !");
                }
                else
                {
                    etudiant enss = listeEns[0];
                    if (enss.mots_de_passe != en.mots_de_passe)
                    {
                        MessageBox.Show("mot de passe incorrect");
                    }
                    else
                    {
                        login.ValidatedEns.cin           = enss.cin;
                        login.ValidatedEns.mots_de_passe = enss.mots_de_passe;
                        login.ValidatedEns.nom           = enss.nom;
                        login.ValidatedEns.prenom        = enss.prenom;
                        login.ValidatedEns.mail          = enss.mail;
                        login.ValidatedEns.photo         = enss.photo;
                        login.ValidatedEns.code_a_bar    = enss.code_a_bar;
                        login.ValidatedEns.NiveauEtud    = enss.NiveauEtud;
                        login.ValidatedEns.Année         = enss.Année;
                        touch.CurrentCamera.Dispose();
                        Accueil_Etudiant ac = new Accueil_Etudiant();
                        ac.Show();
                        this.Hide();
                    }
                }
            }
            catch (SqlException ex)
            {
                MessageBox.Show("Erreur de connection BD " + ex.Message);
            }
        }