Upload
morylex
View
16
Download
1
Embed Size (px)
DESCRIPTION
lectura biometrico
Citation preview
Lab 1
Lab 1: Biometrics (Finger Print Enrollment)
Objective : To allow students to make use of the futronic SDK(Soft ware development kit) to program a GUI(Graphic User Interface) to allow enrollment of finger print of the user into the database.
Items required for the lab:1. ftrSDKHelper8.dll2. DbRecord.cs3. EnrollmentName.cs4. Finger print scanner5. C# visual Studio 20086. PC with Windows OS
The program developed will be used for all subsequent Job Sheets.
Students are to save their programs and keep them safe.
Step 1 Run C# program
Step 2 Start new program
ITE College West 1EC5004PA Integrated Security System Design
Press once on Start
Press once on C# 2008
Press once on File
Press once on New Project
Lab 1
Step 3 Name the program as “Fingerprint Biometrics”
Step 4 Change the size of the Form properties
ITE College West 2EC5004PA Integrated Security System Design
Press once on Windows Form Applications
Set the name as Fingerprint Biometrics
Click on OK
Properties of Form1Text: Fingerprint BiometricsSize : 712, 497
Lab 1
Step 5 Design the Form according to the graphic user interface below:
ITE College West 3EC5004PA Integrated Security System Design
Properties of groupBoxName: groupBox1Location: 12, 12Size : 184, 124Text: Operations
Properties of button1Name: btnEnrollLocation: 16, 32Size : 75, 23Text: Enroll
Properties of button2Name: btnStopLocation: 97, 90Size : 75, 23Text: Stop
Properties of button3Name: btnExitLocation: 619, 431Size : 75, 23Text: Exit
Properties of PictureBox1Name: FingerPrint1BorderStyle: Fixed3DLocation: 202, 8Size : 160, 210SizeMode: StretchImage
Properties of PictureBox2Name: FingerPrint2BorderStyle: Fixed3DLocation: 368, 8Size : 160, 210SizeMode: StretchImage
Properties of PictureBox3Name: FingerPrint3BorderStyle: Fixed3DLocation: 534, 8Size : 160, 210SizeMode: StretchImage
Properties of LabelName: lblMessageAutoSize: FalseBorderStyle: FixedSingleLocation: 10, 221Size : 684, 23Text:
Lab 1
Step 6 Load the ftrSDKHelper8.dll into the program
ITE College West 4EC5004PA Integrated Security System Design
Right click on the reference
click on Add reference
click on Browse and look for the ftrSDKHelper8.dll
Lab 1
Step 7 Add the object DbRecord.cs into the program.
ITE College West 5EC5004PA Integrated Security System Design
Right click on Fingerprint Biometrics
Left Click on the Add
Left Click on the Existing Item
Browse through the harddisk to find the programs for DbRecord.cs
Lab 1
Step 7 Add the object EnrollmentName.cs into the program.
ITE College West 6EC5004PA Integrated Security System Design
Right click on Fingerprint Biometrics
Left Click on the Add
Left Click on the Existing Item
Browse through the harddisk to find the programs for EnrollmentName.cs
Lab 1
Step 8a coding.
Step 8b coding.
ITE College West 7EC5004PA Integrated Security System Design
using System.IO; //Consist library for IO Exceptionusing Futronic.SDKHelper; //Consist library Finger Print Scanner
private bool m_bExit;
/// <summary> /// The type of this parameter is depending from current operation. For /// enrollment operation this is DbRecord. /// </summary> private Object m_OperationObj;
/// <summary> /// Contain reference for current operation object /// </summary> private FutronicSdkBase m_Operation;
/// <summary> /// This delegate enables asynchronous calls for setting /// the text property on a status control. /// </summary> /// <param name="text"></param> delegate void SetTextCallback(string text);
/// <summary> /// This delegate enables asynchronous calls for setting /// the Enable property on a buttons. /// </summary> /// <param name="bEnable">true to enable buttons, otherwise to disable</param> delegate void EnableControlsCallback(bool bEnable);
Lab 1
Step 8c coding.
ITE College West 8EC5004PA Integrated Security System Design
/// <summary> /// A directory name to write user's information. /// </summary> private String m_DatabaseDir;
/// <summary> /// This delegate enables asynchronous calls for setting /// the Image property on a PictureBox control. /// </summary> /// <param name="hBitmap">the instance of Bitmap class</param> delegate void SetImageCallback(Bitmap hBitmap);
/// <summary> /// This int allows the program to count the number of finger print /// template has been captured. /// </summary>
int FingerPrintNum = 1;
try { m_DatabaseDir = GetDatabaseDir(); } catch (IOException) { MessageBox.Show(this, "Initialization failed. Application will be close.\nCan not create database folder", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; }
Lab 1
Step 8d. Coding for GetDatabaseDir() function.
Step 8e. At the solution explorer, double click on the Form1.cs
ITE College West 9EC5004PA Integrated Security System Design
/// <summary> /// Get the database directory. /// </summary> /// <returns>returns the database directory.</returns>
public static String GetDatabaseDir() { String szDbDir; szDbDir = Path.Combine(Directory.GetCurrentDirectory(), "Database");
//Create the directory of the database at the Bin folder of the program. if (!Directory.Exists(szDbDir)) { Directory.CreateDirectory(szDbDir);
//Create the directory of the database at the Bin folder }
return szDbDir; }
Double click on the Form1.cs
Lab 1
Step 8f. Double click on the enroll button to type the coding for enrollment.
Step 8g. Type the coding onto the indicated field.
ITE College West 10EC5004PA Integrated Security System Design
Double click on the Enroll button to doing program the Enroll button.
FingerPrint1.BackgroundImage = null;FingerPrint2.BackgroundImage = null;FingerPrint3.BackgroundImage = null; DbRecord User = new DbRecord(); // Get user name EnrollmentName frmName = new EnrollmentName(); frmName.ShowDialog( this ); if (frmName.DialogResult != DialogResult.OK ) { return; } if( frmName.UserName.Length == 0) { MessageBox.Show( this, "You must enter a username.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation ); return; } // Try creat the file for user's information if( isUserExists(frmName.UserName) ) { DialogResult nResponse; nResponse = MessageBox.Show("User already exists. Do you want replace it?", "C# example for Futronic SDK", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (nResponse == DialogResult.No) return; }
Lab 1
Step 8h. Program the function isUserExists, EnableControls, OnPutOn, SetStatusText,
ITE College West 11EC5004PA Integrated Security System Design
else { try { CreateFile(frmName.UserName); } catch (DirectoryNotFoundException) {
MessageBox.Show(this, "Can not create file to save an user's information.", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
return; } catch (IOException ) { MessageBox.Show(this, String.Format("Bad user name '{0}'.", frmName.UserName), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; }}User.UserName = frmName.UserName;
m_OperationObj = User;
if (m_Operation != null){
m_Operation.Dispose(); m_Operation = null;}
m_Operation = new FutronicEnrollment();
// Set control propertiesm_Operation.FakeDetection = true;m_Operation.FFDControl = true;m_Operation.FARN = 166;((FutronicEnrollment)m_Operation).MIOTControl = true;((FutronicEnrollment)m_Operation).MaxModels = 3;
EnableControls(false);
// register eventsm_Operation.OnPutOn += new OnPutOnHandler(this.OnPutOn);m_Operation.OnTakeOff += new OnTakeOffHandler(this.OnTakeOff);m_Operation.UpdateScreenImage += new UpdateScreenImageHandler(this.UpdateScreenImage);m_Operation.OnFakeSource += new OnFakeSourceHandler(this.OnFakeSource);((FutronicEnrollment)m_Operation).OnEnrollmentComplete += new OnEnrollmentCompleteHandler(this.OnEnrollmentComplete);
// start enrollment process((FutronicEnrollment)m_Operation).Enrollment();
Lab 1
OnTakeOff, UpdateScreenImage, OnFakeSource, OnEnrollmentComplete.
ITE College West 12EC5004PA Integrated Security System Design
protected bool isUserExists(String UserName){
String szFileName;szFileName = Path.Combine(m_DatabaseDir, UserName );return File.Exists(szFileName);
}
private void EnableControls(bool bEnable){
// Do not change the state control during application closing.if (m_bExit)
return;if (this.InvokeRequired){EnableControlsCallback d = new EnableControlsCallback(this.EnableControls);this.Invoke(d, new object[] { bEnable });}else{
btnEnroll.Enabled = bEnable;btnStop.Enabled = !bEnable;
}}
private void OnPutOn(FTR_PROGRESS Progress){
this.SetStatusText("Place thumb/finger on device.");}
private void SetStatusText(String text){
// Do not change the state control during application closing.if( m_bExit )
return;
if( this. lblMessage.InvokeRequired ){
SetTextCallback d = new SetTextCallback(this.SetStatusText);this.Invoke( d, new object[] { text } );
} else {
this. lblMessage.Text = text; this.Update();
}}
private void OnTakeOff(FTR_PROGRESS Progress){
this.SetStatusText("Remove thumb/finger from device");}
private void UpdateScreenImage(Bitmap hBitmap){
// Do not change the state control during application closing.
Lab 1
ITE College West 13EC5004PA Integrated Security System Design
private void OnTakeOff(FTR_PROGRESS Progress){
this.SetStatusText("Remove thumb/finger from device");}
private void UpdateScreenImage(Bitmap hBitmap){
// Do not change the state control during application closing.
private bool OnFakeSource(FTR_PROGRESS Progress){
if( m_bExit )return true;
DialogResult result;result = MessageBox.Show("Fake source detected. Do you want continue process?",
"C# example for Futronic SDK",MessageBoxButtons.YesNo, MessageBoxIcon.Question
Lab 1
Step 8h. On solution explorer double click on the Form1.cs.
ITE College West 14EC5004PA Integrated Security System Design
private bool OnFakeSource(FTR_PROGRESS Progress){
if( m_bExit )return true;
DialogResult result;result = MessageBox.Show("Fake source detected. Do you want continue process?",
"C# example for Futronic SDK",MessageBoxButtons.YesNo, MessageBoxIcon.Question
Lab 1
Step 8i. Double click on the Stop button.
Step 8j. Coding for the Stop button.
Step 8k, Double click on the Form1.cs in solution explorer.
Step 8l Double click on the Exit button.
ITE College West 15EC5004PA Integrated Security System Design
Double click on the Form1.cs
Double click on the Stop button
m_Operation.OnCalcel();
Double click on the Form1.cs
Lab 1
Step 8m Programming for the Exit button.
Step 9. Build the solution by keying F5, and run debug by pressing F6.
Step 10: When there is no error, test your program with the Finger Print Scanner.
Step 11: Save your project.
Conclusion
ITE College West 16EC5004PA Integrated Security System Design
Double click on the Exit button
base.Hide();m_bExit = true;this.Close();
Lab 1
1. State what these program codes do
codes What they doSetStatusText(“Hello”)
Close()
String szFileName; szFileName = Path.Combine(m_DatabaseDir, UserName); File.Create(szFileName).Close(); File.Delete(szFileName);
FingerPrint1.BackgroundImage = null;
MessageBox.Show(“Welcome”)
szDbDir = Path.Combine(Directory.GetCurrentDirectory(), "Database");
szMessage.Append("Enrollment process failed.");szMessage.Append("Error description: ");
2. State 2 problems faced when trying to enroll fingerprint.
ITE College West 17EC5004PA Integrated Security System Design