F LOWCHART
F LOWCHART
Start
Splash Screen
Login
Main Menu
Stop
22
APPEENDIX 3: Login Page
Start
Open
Datab
ase
Input Username,
Password
Is any field
Yes
empty ?
No
Is Field
No
Correct In
Database ?
Yes
Main Menu
Close
Datab
ase
Stop
23
APPENDIX 2: SPLASH SCREEN
Start
Open
Databa
se
Display Splash
Screen
Open
Databa
se
Stop
24
APPENDIX 4: MAIN MENU
Start
Open
Datab
ase
Select option
End Select
Close
Datab
ase
Stop
25
APPENDIX 5: REGISTER PERSONNEL
Start
Open
Datab
ase
Enter Personnel
Registration
Details
No
Display Details
Save to Database
Close
Databas
e
Return
26
APPENDIX 6: MODIFY PERSONNEL
Start
Open
Databas
e
Modify Personnel
Close
Databas
e
Return
27
APPENDIX 7: DELETE PERSONNEL
Start
Open
Databas
e
Delete Personnel
Close
Databas
e
Return
28
APPENDIX 8: REPORT
Start
Open
Databas
e
Display
Personnel
Report
Close
Databas
e
Return
29
APPENDIX 9: LOGOUT
Start
Open
Datab
ase
Main Menu
Are you sure You No
want to Logout?
Yes
Thank you for
using this
software
Welcome Page
Close
Databas
e
Return
30
Appendix 10: Source Code
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.OleDb;
using System.Data.Common;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Emgu.CV;
using Emgu.CV.Structure;
using Emgu.CV.CvEnum;
using Microsoft.VisualBasic;
namespace FacialRecognition
{
public partial class frmface : Form
{
private Capture grab;
private HaarCascade face;
private List<Image<Gray, byte>> trainingImgs;
private List<string> trainingNames;
private Image<Bgr, byte> current;
private string filePath;
private double scale;
private double epsilon;
private int minNeighbors;
private string name;
public frmface()
{
InitializeComponent();
}
31
//btnTrain.Enabled = true;
btnGrabber.Text = "Stop Webcam";
btnLoad.Enabled = false;
btnDetect.Enabled = false;
btnTrain.Enabled = true;
chkboxDetectFaces.Enabled = true;
}
else if (btnGrabber.Text == "Stop Webcam")
{
btnGrabber.Text = "View Webcam";
//btnTrain.Enabled = false;
grab.Dispose();
btnLoad.Enabled = true;
btnTrain.Enabled = false;
chkboxDetectFaces.Enabled = false;
}
if (chkboxDetectFaces.Checked == true)
{
Image<Gray, byte> grayScale = current.Convert<Gray, byte>();
32
//}
//if (txtGrade.Text == "")
//{
// MessageBox.Show("Supply the Grade of the Student");
// return;
//}
if (btnGrabber.Text == "View Webcam")
{
current = new Image<Bgr, byte>(filePath).Resize(300, 250,
INTER.CV_INTER_CUBIC);
}
else
{
current = grab.QueryFrame().Resize(300, 250,
Emgu.CV.CvEnum.INTER.CV_INTER_CUBIC);
}
Image<Gray, byte> train = current.Convert<Gray, byte>();
MCvAvgComp[][] detected = train.DetectHaarCascade(face, scale,
minNeighbors, Emgu.CV.CvEnum.HAAR_DETECTION_TYPE.DO_CANNY_PRUNING, new Size(20, 20));
//20x20 default for faces
if (detected[0].Length < 1)
{
MessageBox.Show("There aren't any faces to train!");
return;
}
foreach (MCvAvgComp d in detected[0])
{
trainingNames.Add(name);
lstTraining.Items.Add(name);
trainingImgs.Add(train);
lstTraining.SelectedIndex = lstTraining.Items.Count - 1;
}
//String sName, matric, grade, level, course;
//sName = txtName.Text.Trim();
//matric = txtMatric.Text.Trim();
//grade = txtGrade.Text.Trim();
//level = txtLevel.Text.Trim();
//course = txtCourse.Text.Trim();
////saving to database
//OleDbConnection con = new
OleDbConnection("Provider=Microsoft.Jet.Oledb.4.0;Data Source=DB.mdb");
//con.Open();
//cmd.Connection = con;
//cmd.ExecuteNonQuery();
33
//con.Close();
//MessageBox.Show("Student Details Captured and Saved Successfully");
//this.Close();
//end
}
if (trainingImgs.Count > 0)
{
if (lstTraining.SelectedIndex == -1) lstTraining.SelectedIndex =
lstTraining.Items.Count - 1;
picTraining.Image =
trainingImgs[lstTraining.SelectedIndex].ToBitmap();
}
else picTraining.Image = null;
}
lstTraining.Items.RemoveAt(index);
}
//else do nothing
}
34
{
current.Draw(d.rect, new Bgr(Color.LawnGreen), 2);
if (trainingImgs.Count > 0)
{
Image<Gray, byte> dFace = current.Copy(d.rect).Convert<Gray,
byte>().Resize(100, 100, Emgu.CV.CvEnum.INTER.CV_INTER_CUBIC);
MCvTermCriteria criteria = new
MCvTermCriteria(trainingImgs.Count, epsilon); //count, epsilon value
EigenObjectRecognizer recognize = new
EigenObjectRecognizer(trainingImgs.ToArray(), trainingNames.ToArray(), 0, ref
criteria);
MCvFont font = new MCvFont(FONT.CV_FONT_HERSHEY_TRIPLEX, 1,
1);
string name = recognize.Recognize(dFace);
current.Draw(name, ref font, new Point(d.rect.X - 2, d.rect.Y
- 20), new Bgr(Color.Red));
}
}
picWebCam.Image = current.ToBitmap();
}
35