Esempio n. 1
0
        private void FrmPrincipal_Load(object sender, EventArgs e)
        {
            timer1.Enabled     = true;
            button1.Enabled    = false;
            button2.Enabled    = false;
            buttonAll.Enabled  = false;
            buttonView.Enabled = false;
            List <string> _items = new List <string>();

            dynamic at = new AttendanceTable().All();

            Dictionary <string, int> uniquedate = new Dictionary <string, int>();

            if (at != null)
            {
                foreach (var attendance in at)
                {
                    if (!uniquedate.ContainsKey(attendance.date_taken.ToString()))
                    {
                        _items.Add(attendance.date_taken.ToString());
                        uniquedate.Add(attendance.date_taken.ToString(), 1);
                    }
                }
            }

            comboBoxDate.DataSource = _items;
        }
        private void button1_Click(object sender, EventArgs e)
        {
            dynamic attendanceAll = new AttendanceTable().Delete();

            //dynamic studentred = new StudentTable().Delete();

            MessageBox.Show("Staff Deleted Successfully");
            dataGridView1.Refresh();
        }
        private void AllStudentRecord_Load(object sender, EventArgs e)
        {
            List <string[]> items         = new List <string[]>();
            dynamic         attendanceAll = new AttendanceTable().All();

            if (attendanceAll != null)
            {
                foreach (var attendance in attendanceAll)
                {
                    string studentName = new StudentTable().GetStudentName(attendance.matric_number.ToString());
                    items.Add(new string[] { studentName, attendance.matric_number.ToString() });
                }
            }



            // Convert to DataTable.
            DataTable table = ConvertListToDataTable(items);

            dataGridView1.DataSource = table;
        }
Esempio n. 4
0
        private void buttonView_Click(object sender, EventArgs e)
        {
            List <string[]> items            = new List <string[]>();
            string          dateTime         = comboBoxDate.SelectedItem.ToString();
            dynamic         attendanceByDate = new AttendanceTable().All(where : String.Format("date_taken='{0}'", dateTime));

            if (attendanceByDate != null)
            {
                foreach (var attendance in attendanceByDate)
                {
                    string studentName = new StudentTable().GetStudentName(attendance.matric_number.ToString());
                    items.Add(new string[] { studentName, attendance.matric_number.ToString() });
                }
            }



            // Convert to DataTable.
            DataTable table = ConvertListToDataTable(items);

            dataGridView1.DataSource = table;
        }
Esempio n. 5
0
        void FrameGrabber(object sender, EventArgs e)
        {
            label3.Text = "0";
            //label4.Text = "";
            NamePersons.Add("");


            //Get the current frame form capture device
            currentFrame = grabber.QueryFrame().Resize(320, 240, Emgu.CV.CvEnum.INTER.CV_INTER_CUBIC);

            //Convert it to Grayscale
            gray = currentFrame.Convert <Gray, Byte>();

            //Face Detector
            MCvAvgComp[][] facesDetected = gray.DetectHaarCascade(face, 1.2, 10, Emgu.CV.CvEnum.HAAR_DETECTION_TYPE.DO_CANNY_PRUNING,
                                                                  new Size(20, 20));

            //Action for each element detected
            foreach (MCvAvgComp f in facesDetected[0])
            {
                t      = t + 1;
                result = currentFrame.Copy(f.rect).Convert <Gray, byte>().Resize(100, 100, Emgu.CV.CvEnum.INTER.CV_INTER_CUBIC);
                //draw the face detected in the 0th (gray) channel with blue color
                currentFrame.Draw(f.rect, new Bgr(Color.Gray), 2);


                if (trainingImages.ToArray().Length != 0)
                {
                    //TermCriteria for face recognition with numbers of trained images like maxIteration
                    MCvTermCriteria termCrit = new MCvTermCriteria(ContTrain, 0.001);

                    //Eigen face recognizer
                    EigenObjectRecognizer recognizer = new EigenObjectRecognizer(
                        trainingImages.ToArray(),
                        labels.ToArray(),
                        3000,
                        ref termCrit);

                    name = recognizer.Recognize(result);
                    textBoxMatricNumber.Text = name;


                    //Draw the label for each face detected and recognized
                    currentFrame.Draw(name, ref font, new Point(f.rect.X - 2, f.rect.Y - 2), new Bgr(Color.Green));
                }

                NamePersons[t - 1] = name;
                NamePersons.Add("");

                if (name == textBoxMatricNumber.Text)
                {
                    AttendanceTable attendanceTable = new AttendanceTable();
                    string          date            = DateTime.Today.ToShortDateString();
                    string          matricNumber    = name;

                    if (attendanceTable.AlreadyTaken(date, matricNumber) == false)
                    {
                        attendanceTable.TakeAttendance(date, matricNumber);
                        labelAttendance.Text = "Last Attendance Taken: " +
                                               new StudentTable().GetStudentName(matricNumber);
                    }
                    else
                    {
                        MessageBox.Show("Attendance Already Taken");
                    }
                }
                else
                {
                    MessageBox.Show("User not found");
                }



                //Set the number of faces detected on the scene
                label3.Text = facesDetected[0].Length.ToString();

                /*
                 * //Set the region of interest on the faces
                 *
                 * gray.ROI = f.rect;
                 * MCvAvgComp[][] eyesDetected = gray.DetectHaarCascade(
                 * eye,
                 * 1.1,
                 * 10,
                 * Emgu.CV.CvEnum.HAAR_DETECTION_TYPE.DO_CANNY_PRUNING,
                 * new Size(20, 20));
                 * gray.ROI = Rectangle.Empty;
                 *
                 * foreach (MCvAvgComp ey in eyesDetected[0])
                 * {
                 *  Rectangle eyeRect = ey.rect;
                 *  eyeRect.Offset(f.rect.X, f.rect.Y);
                 *  currentFrame.Draw(eyeRect, new Bgr(Color.Blue), 2);
                 * }
                 */
            }
            t = 0;

            //Names concatenation of persons recognized
            for (int nnn = 0; nnn < facesDetected[0].Length; nnn++)
            {
                names = names + NamePersons[nnn] + ", ";
                talk.SelectVoiceByHints(VoiceGender.Female);
                talk.Speak("Attendance Taken Successfully For " + names);
            }
            //Show the faces procesed and recognized
            imageBoxFrameGrabber.Image = currentFrame;
            label4.Text = names;
            names       = "";
            //Clear the list(vector) of names
            NamePersons.Clear();
        }