You are on page 1of 17

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.dll
2. DbRecord.cs
3. EnrollmentName.cs
4. Finger print scanner
5. C# visual Studio 2008
6. 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

Press once on C#
2008

Press once on Start

Step 2 Start new program
Press once on File

Press once on New
Project

ITE College West
EC5004PA Integrated Security System Design

1

Lab 1 Step 3 Name the program as “Fingerprint Biometrics” Press once on Windows Form Applications Set the name as Fingerprint Biometrics Click on OK Step 4 Change the size of the Form properties Properties of Form1 Text: Fingerprint Biometrics Size : 712. 497 ITE College West EC5004PA Integrated Security System Design 2 .

23 Size : 75. 23 Text: ITE College West EC5004PA Integrated Security System Design 3 . 8 Location: 368.Lab 1 Step 5 Design the Form according to the graphic user interface below: Properties of Properties of Properties of Properties of groupBox button1 button2 button3 Name: groupBox1 Name: btnEnroll Name: btnStop Name: btnExit Location: 12. 23 Size : 75. 90 Location: 619. 210 Size : 160. 23 Text: Operations Text: Enroll Text: Stop Text: Exit Properties of Properties of Properties of PictureBox1 PictureBox2 PictureBox3 Name: FingerPrint1 Name: FingerPrint2 Name: FingerPrint3 BorderStyle: Fixed3D BorderStyle: Fixed3D BorderStyle: Fixed3D Location: 202. 8 Location: 534. 210 SizeMode: SizeMode: SizeMode: Properties of Label Name: lblMessage AutoSize: False BorderStyle: FixedSingle Location: 10. 210 Size : 160. 124 Size : 75. 12 Location: 16. 431 Size : 184. 8 Size : 160. 32 Location: 97. 221 Size : 684.

dll ITE College West EC5004PA Integrated Security System Design 4 .dll into the program Right click on the reference click on Add reference click on Browse and look for the ftrSDKHelper8.Lab 1 Step 6 Load the ftrSDKHelper8.

Lab 1 Step 7 Add the object DbRecord.cs into the program. 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 ITE College West EC5004PA Integrated Security System Design 5 .

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.Lab 1 Step 7 Add the object EnrollmentName. ITE College West EC5004PA Integrated Security System Design 6 .cs into the program.

For /// enrollment operation this is DbRecord. otherwise to disable</param> delegate void EnableControlsCallback(bool bEnable). private bool m_bExit. //Consist library Finger Print Scanner Step 8b coding.IO.SDKHelper.Lab 1 Step 8a coding. /// <summary> /// The type of this parameter is depending from current operation. /// <summary> /// This delegate enables asynchronous calls for setting /// the text property on a status control. /// </summary> /// <param name="bEnable">true to enable buttons. /// </summary> private Object m_OperationObj. /// <summary> /// This delegate enables asynchronous calls for setting /// the Enable property on a buttons. //Consist library for IO Exception using Futronic. ITE College West EC5004PA Integrated Security System Design 7 . /// <summary> /// Contain reference for current operation object /// </summary> private FutronicSdkBase m_Operation. using System. /// </summary> /// <param name="text"></param> delegate void SetTextCallback(string text).

this.OK. Step 8c coding. /// <summary> /// This delegate enables asynchronous calls for setting /// the Image property on a PictureBox control.\nCan not create database folder". MessageBoxButtons. Application will be close. } catch (IOException) { MessageBox. /// /// /// /// <summary> This int allows the program to count the number of finger print template has been captured. try { m_DatabaseDir = GetDatabaseDir(). </summary> int FingerPrintNum = 1. "Initialization failed.Lab 1 /// <summary> /// A directory name to write user's information. } ITE College West EC5004PA Integrated Security System Design 8 . MessageBoxIcon.Show(this.Text. return. /// </summary> /// <param name="hBitmap">the instance of Bitmap class</param> delegate void SetImageCallback(Bitmap hBitmap). /// </summary> private String m_DatabaseDir.Exclamation).

Combine(Directory. //Create the directory of the database at the Bin folder of the program.Lab 1 Step 8d. double click on the Form1.Exists(szDbDir)) { Directory. At the solution explorer. } Step 8e.GetCurrentDirectory().cs ITE College West EC5004PA Integrated Security System Design 9 . szDbDir = Path.CreateDirectory(szDbDir). Coding for GetDatabaseDir() function. //Create the directory of the database at the Bin folder } return szDbDir.cs Double click on the Form1. "Database"). </summary> <returns>returns the database directory. if (!Directory.</returns> public static String GetDatabaseDir() String szDbDir. /// /// /// /// { <summary> Get the database directory.

if (frmName.Question). return. } ITE College West EC5004PA Integrated Security System Design 10 .Show( this. "C# example for Futronic SDK". nResponse = MessageBox.BackgroundImage = null. MessageBoxIcon. } // Try creat the file for user's information if( isUserExists(frmName.OK.UserName. Do you want replace it?".YesNo. Double click on the Enroll button to doing program the Step 8g. // Get user name EnrollmentName frmName = new EnrollmentName(). "You must enter a username.Text. FingerPrint2. FingerPrint3.". MessageBoxButtons. FingerPrint1.ShowDialog( this ).Length == 0) { MessageBox. Type the coding onto the indicated field.Exclamation ). DbRecord User = new DbRecord(). frmName.BackgroundImage = null. } if( frmName. if (nResponse == DialogResult.No) return.Show("User already exists. MessageBoxButtons. MessageBoxIcon.DialogResult != DialogResult.UserName) ) { DialogResult nResponse. Double click on the enroll button to type the coding for enrollment.BackgroundImage = null. this.OK ) { return.Lab 1 Step 8f.

m_Operation.OnFakeSource += new OnFakeSourceHandler(this. return. SetStatusText.Text. this.UserName). ((FutronicEnrollment)m_Operation).Format("Bad user name '{0}'. m_Operation.UpdateScreenImage). } catch (IOException ) { MessageBox.OnPutOn += new OnPutOnHandler(this. ((FutronicEnrollment)m_Operation).FakeDetection = true.OnEnrollmentComplete += new OnEnrollmentCompleteHandler(this.OnTakeOff += new OnTakeOffHandler(this.UserName).Exclamation).Text. ((FutronicEnrollment)m_Operation).OK.MaxModels = 3.UserName = frmName. MessageBoxButtons. if (m_Operation != null) { m_Operation.UserName. OnPutOn. EnableControls. EnableControls(false). this. m_OperationObj = User. MessageBoxIcon. // Set control properties m_Operation.OnFakeSource). m_Operation.MIOTControl = true. } m_Operation = new FutronicEnrollment(). String.".UpdateScreenImage += new UpdateScreenImageHandler(this. MessageBoxButtons.OnTakeOff).OnEnrollmentComplete). m_Operation = null.Lab 1 else { try { CreateFile(frmName. "Can not create file to save an user's information.Exclamation). Program the function isUserExists.Enrollment().FARN = 166. } catch (DirectoryNotFoundException) { MessageBox. return.OnPutOn).OK. // register events m_Operation. m_Operation. frmName.". } } User. // start enrollment process ((FutronicEnrollment)m_Operation).FFDControl = true. MessageBoxIcon.Show(this.Dispose().Show(this. Step 8h. m_Operation. ITE College West EC5004PA Integrated Security System Design 11 .

SetStatusText). lblMessage.Exists(szFileName).Invoke(d. OnEnrollmentComplete. if( this. } else if (FingerPrintNum == 3) else {{ if (FingerPrint3.Invoke(d. { } // Do not change the state control during application closing.Text = text.Enabled = !bEnable. this.InvokeRequired) this.Lab 1 OnTakeOff. UserName ).Image = hBitmap.Image = hBitmap. private//void EnableControls(bool if (m_bExit) { return.Update(). } this. this.SetStatusText("Place thumb/finger on device.").Invoke(d.UpdateScreenImage).InvokeRequired) } { SetImageCallbacktext) d = new SetImageCallback(this. } szFileName = Path. new object[] { dbEnable }). new object[] { text } ). FingerPrint1. new object[] { hBitmap }). btnStop. } } else else { { btnEnroll. EC5004PA Integrated Security System Design } } } . return File.UpdateScreenImage). lblMessage. private void SetStatusText(String this.UpdateScreenImage). SetImageCallback = new SetImageCallback(this.Combine(m_DatabaseDir. if (FingerPrint2. FingerPrint2.InvokeRequired ) } { SetTextCallback d = new SetTextCallback(this. { this.InvokeRequired) if (FingerPrint1.Image = hBitmap. { if (this. SetImageCallback d = new SetImageCallback(this. 12 FingerPrintNum = 1. // Do not change the state control during application closing.InvokeRequired) { { EnableControlsCallback d = new EnableControlsCallback(this.SetStatusText("Remove thumb/finger from device"). UpdateScreenImage. }private void UpdateScreenImage(Bitmap hBitmap) { Do not change the state bEnable) control during application closing. private void Progress) protected boolOnTakeOff(FTR_PROGRESS isUserExists(String UserName) {{ this. if (m_bExit) if (FingerPrintNum == 1) return. } } } } private void OnPutOn(FTR_PROGRESS Progress) else if (FingerPrintNum == 2) { { this. else ) if( m_bExit { return. } this.EnableControls). new object[] { hBitmap }).Invoke( d. FingerPrintNum++. new object[] { hBitmap }). } } else { ITE College WestFingerPrint3. FingerPrintNum++.Enabled = bEnable. String szFileName. OnFakeSource.Invoke(d.

ToString() ). this.Close().Question return (result == DialogResult. User.Append("Enrollment failed. if (!User.Cannot save user’s information to file " + szFileName. MessageBoxIcon. EC5004PA Integrated Security System Design File.Lab 1 private bool OnFakeSource(FTR_PROGRESS Progress) { if( m_bExit ) return true. ITE College szFileName = Path. MessageBoxIcon.Append(((FutronicEnrollment)m_Operation).SdkRetCode2Message(nRetCode)).Exclamation). User.Delete(szFileName). szMessage. szMessage. this.SetStatusText( szMessage.YesNo. private void OnEnrollmentComplete(bool bSuccess.MessageBoxButtons. result = MessageBox.Template. "C# example for Futronic SDK".Append("Error description: ").Combine(m_DatabaseDir.Append("Enrollment of fingerprint successful"). UserName).Save(szFileName) ) { MessageBox.Append("Quality: "). File. ). } protected void CreateFile(String UserName) { String West szFileName. int nRetCode ) { StringBuilder szMessage = new StringBuilder(). } 13 .Create(szFileName).").ToString() ).UserName ). // Set template into user's information and save it DbRecord User = (DbRecord)m_OperationObj. szMessage.SetStatusText(szMessage.OK. String szFileName = Path.Quality.ToString() ).Template = ((FutronicEnrollment)m_Operation). } m_OperationObj = null. "C# example for Futronic SDK". } DialogResult result.Combine(m_DatabaseDir. MessageBoxButtons. } } else { szMessage. EnableControls(true).Show("Fake source detected. Do you want continue process?".Append(FutronicSdkBase. if (bSuccess) { // set status string szMessage.No).Show( "Error . szMessage.

cs. On solution explorer double click on the Form1. ITE College West EC5004PA Integrated Security System Design 14 .Lab 1 Step 8h.

cs in solution explorer.cs Step 8i. Coding for the Stop button.cs Step 8l Double click on the Exit button. Double click on the Stop button. Double click on the Form1. Double click on the Stop button Step 8j. ITE College West EC5004PA Integrated Security System Design 15 .Lab 1 Double click on the Form1. m_Operation. Step 8k.OnCalcel(). Double click on the Form1.

base. Build the solution by keying F5. Conclusion ITE College West EC5004PA Integrated Security System Design 16 .Close().Hide(). Step 11: Save your project. m_bExit = true. test your program with the Finger Print Scanner. Step 10: When there is no error. and run debug by pressing F6. this. Step 9.Lab 1 Double click on the Exit button Step 8m Programming for the Exit button.

Combine(m_DatabaseDir.Append("Error description: ").Lab 1 1.Combine(Directory. MessageBox. szFileName = Path. File.Show(“Welcome”) szDbDir = Path. File. szMessage."). "Database"). State what these program codes do codes What they do SetStatusText(“Hello”) Close() String szFileName.Close().BackgroundImage = null. ITE College West EC5004PA Integrated Security System Design 17 . FingerPrint1.Append("Enrollment process failed. szMessage.Delete(szFileName). UserName). State 2 problems faced when trying to enroll fingerprint.Create(szFileName).GetCurrentDirectory() . 2.