0% found this document useful (0 votes)
54 views14 pages

F LOWCHART

The document contains 10 appendices that describe the flow and user interface of a facial recognition software system. Appendix 1 shows the overall system flowchart. The remaining appendices describe specific screens and functions such as the login page, splash screen, main menu, registering and modifying personnel, deleting personnel, viewing reports, logging out, and the source code.

Uploaded by

gentle
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
54 views14 pages

F LOWCHART

The document contains 10 appendices that describe the flow and user interface of a facial recognition software system. Appendix 1 shows the overall system flowchart. The remaining appendices describe specific screens and functions such as the login page, splash screen, main menu, registering and modifying personnel, deleting personnel, viewing reports, logging out, and the source code.

Uploaded by

gentle
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 14

APPENDIX 1: SYSTEM FLOWCHART

Start

Splash Screen

Login

Main Menu

Register Modify Delete Report Logout


Personnel Personnel Personnel

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

Register Modify Delete Report Logout


Personnel Personnel Personnel

End Select

Close
Datab
ase

Stop

25
APPENDIX 5: REGISTER PERSONNEL

Start

Open
Datab
ase

Enter Personnel
Registration
Details

All Field are


Is any Field Empty Yes
Required to
? Proceed

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

Click on Log out

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();
}

private void Form1_Load(object sender, EventArgs e)


{

txtCascadeFile.Text = Application.StartupPath + "\\


haarcascade_frontalface_default.xml";
face = new HaarCascade(txtCascadeFile.Text);
btnTrain.Enabled = false;
trainingImgs = new List<Image<Gray, byte>>();
trainingNames = new List<string>();
Application.Idle += new EventHandler(FrameGrabber);
current = null;
filePath = string.Empty;
btnDetect.Enabled = false;
chkboxDetectFaces.Enabled = false;
scale = Double.Parse(txtScale.Text);
epsilon = Double.Parse(txtEpsilon.Text);
minNeighbors = Int32.Parse(txtMinNeighbors.Text);
}

private void btnGrabber_Click(object sender, EventArgs e)


{
if (btnGrabber.Text == "View Webcam")
{
grab = new Capture();
grab.QueryFrame();

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;
}

private void FrameGrabber(object sender, EventArgs args)


{
if (btnGrabber.Text == "View Webcam") return;

current = grab.QueryFrame().Resize(300, 250,


Emgu.CV.CvEnum.INTER.CV_INTER_CUBIC);

if (chkboxDetectFaces.Checked == true)
{
Image<Gray, byte> grayScale = current.Convert<Gray, byte>();

MCvAvgComp[][] detected = grayScale.DetectHaarCascade(face, scale,


minNeighbors, Emgu.CV.CvEnum.HAAR_DETECTION_TYPE.DO_CANNY_PRUNING, new Size(20, 20));
foreach (MCvAvgComp d in detected[0])
{
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(), 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();
}

private void btnTrain_Click(object sender, EventArgs e)


{

//if (txtName.Text == "")


//{
// MessageBox.Show("Please Enter your name in the Text Field");
// this.Width = 930;
// return;

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])
{

train = current.Copy(d.rect).Convert<Gray, byte>().Resize(100, 100,


Emgu.CV.CvEnum.INTER.CV_INTER_CUBIC);
picTraining.Image = train.ToBitmap();
//frmadd hab = new frmadd();
//hab.imgpic.Image = train.ToBitmap();
name = Program.kip.txtname.Text.Trim(); //"Mariam";
//Interaction.InputBox("Please enter a name for this person.",
Application.ProductName);

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();

//OleDbCommand cmd = new OleDbCommand();

//cmd.Connection = con;

//cmd.CommandText = "INSERT INTO sRecord VALUES ('" + sName + "','" +


matric + "','" + grade + "','" + level + "','" + course + "')";

//cmd.ExecuteNonQuery();

33
//con.Close();
//MessageBox.Show("Student Details Captured and Saved Successfully");

//this.Close();
//end
}

private void lstTraining_SelectedIndexChanged(object sender, EventArgs e)


{

if (trainingImgs.Count > 0)
{
if (lstTraining.SelectedIndex == -1) lstTraining.SelectedIndex =
lstTraining.Items.Count - 1;
picTraining.Image =
trainingImgs[lstTraining.SelectedIndex].ToBitmap();
}
else picTraining.Image = null;
}

private void btnLoad_Click(object sender, EventArgs e)


{
DialogResult result = openFileDialog1.ShowDialog();
if (result != DialogResult.OK) return;
filePath = openFileDialog1.FileName;
btnDetect.Enabled = true;
btnTrain.Enabled = true;
current = new Image<Bgr, byte>(filePath).Resize(300, 250,
INTER.CV_INTER_CUBIC);
picWebCam.Image = current.ToBitmap();
}

private void lstTraining_DoubleClick(object sender, EventArgs e)


{
if (lstTraining.SelectedIndex == -1) return;
DialogResult result = MessageBox.Show("Are you sure you wish to delete
this entry?", "Delete?", MessageBoxButtons.YesNo);
if (result == DialogResult.Yes)
{
int index = lstTraining.SelectedIndex;
trainingImgs.RemoveAt(index);
trainingNames.RemoveAt(index);
if (trainingImgs.Count > 0) lstTraining.SelectedIndex =
trainingImgs.Count - 1;

lstTraining.Items.RemoveAt(index);

}
//else do nothing
}

private void btnDetect_Click(object sender, EventArgs e)


{
current = new Image<Bgr, byte>(filePath).Resize(300, 250,
INTER.CV_INTER_CUBIC);
Image<Gray, byte> grayScale = current.Convert<Gray, byte>();

MCvAvgComp[][] detected = grayScale.DetectHaarCascade(face, scale,


minNeighbors, Emgu.CV.CvEnum.HAAR_DETECTION_TYPE.DO_CANNY_PRUNING, new Size(20, 20));
foreach (MCvAvgComp d in detected[0])

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();
}

private void btnBrowseHAAR_Click(object sender, EventArgs e)


{
DialogResult result = openFileDialog1.ShowDialog();
if (result != DialogResult.OK) return;
txtCascadeFile.Text = openFileDialog1.FileName;
face = new HaarCascade(txtCascadeFile.Text);
}

private void txtScale_Leave(object sender, EventArgs e)


{
try
{
double tmp = Double.Parse(txtScale.Text);
if (tmp <= 1)
{
throw new Exception("The scale must be greater than 1!");
}
scale = tmp;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
txtScale.Text = "" + scale;
}
}

35

You might also like