123143418-morpokit
-
Upload
juan-pablo-hernandez -
Category
Documents
-
view
76 -
download
8
Transcript of 123143418-morpokit
Company Confidential ___________________________________________________________________________________________________________________________
© MorphoTrak 1 of 33
Morpho Integrator’s Kit 4 Manual Date: 26 March 2009 Revision Date: 28 December 2009 Version: 1.1
Company Confidential ___________________________________________________________________________________________________________________________
© MorphoTrak 2 of 33
Table of Contents
1 OVERVIEW ......................................................................................................................................... 5
2 IMPORTING THE SAGEM.MORPHOKIT COMPONENTS ................................................................ 5
3 IMPORTING THE SAGEM.MORPHOKIT.ACQUISITIONCOMPONENT COMPONENTS ................. 6
4 IMPORTING THE MKIT NAMESPACES TO YOUR PROJECT ......................................................... 7
4.1 VB ........................................................................................................................................................................................................ 7
4.2 C#......................................................................................................................................................................................................... 7
4.3 C++ ...................................................................................................................................................................................................... 8
5 DECLARATION OF SAGEM.MORPHOKIT EVENTS AND CLASS INSTANCES............................. 8
5.1 VB ........................................................................................................................................................................................................ 8
5.2 C#......................................................................................................................................................................................................... 9
5.3 C++ .................................................................................................................................................................................................... 10
6 SAMPLE CODE: SAGEM.MORPHOKIT ACQUISITION EVENTS .................................................. 11
6.1 VB ...................................................................................................................................................................................................... 11
6.2 C#....................................................................................................................................................................................................... 12
6.3 C++ .................................................................................................................................................................................................... 13
7 SAMPLE CODE: ACQUISITION SAGEM.MORPHOKIT ................................................................. 14
7.1 VB ...................................................................................................................................................................................................... 14
7.2 C#....................................................................................................................................................................................................... 15
7.3 C++ .................................................................................................................................................................................................... 16
8 SAMPLE CODE: LOADING FINGERPRINTS INTO THE MATCHER FROM A DATABASE ......... 18
8.1 VB ...................................................................................................................................................................................................... 18
8.2 C#....................................................................................................................................................................................................... 19
Company Confidential ___________________________________________________________________________________________________________________________
© MorphoTrak 3 of 33
8.3 C++ .................................................................................................................................................................................................... 20
9 SAMPLE CODE: IDENTIFY WITH MATCHER................................................................................. 22
9.1 VB ...................................................................................................................................................................................................... 22
9.2 C#....................................................................................................................................................................................................... 22
9.3 C++ .................................................................................................................................................................................................... 22
10 DECLARATION OF SAGEM.MORPHOKIT.ACQUISITIONCOMPONENT CLASS INSTANCES 23
10.1 VB ...................................................................................................................................................................................................... 23
10.2 C#....................................................................................................................................................................................................... 23
10.3 C++ .................................................................................................................................................................................................... 23
11 SAMPLE CODE: ACQUISITION WITH SAGEM.MORPHOKIT.ACQUISITIONCOMPONENT ..... 24
11.1 VB ...................................................................................................................................................................................................... 24
11.2 C#....................................................................................................................................................................................................... 24
11.3 C++ .................................................................................................................................................................................................... 25
12 SAMPLE CODE: MISCELLANEOUS: CREATEGREYSCALEBITMAP ....................................... 26
12.1 VB ...................................................................................................................................................................................................... 26
12.2 C#....................................................................................................................................................................................................... 26
12.3 C++ .................................................................................................................................................................................................... 27
13 SAMPLE CODE: MISCELLANEOUS: CREATE A TEMPLATE FROM AN IMAGE ..................... 28
13.1 VB ...................................................................................................................................................................................................... 28
13.2 C#....................................................................................................................................................................................................... 28
13.3 C++ .................................................................................................................................................................................................... 29
14 EXAMPLE SCREENS: SAGEM.MORPHOKIT – PERSONALISED GRAPHICAL USER INTERFASE ............................................................................................................................................ 30
14.1 Acquisition ........................................................................................................................................................................................ 30
14.2 Enrollment - Consolidation ............................................................................................................................................................. 31
Company Confidential ___________________________________________________________________________________________________________________________
© MorphoTrak 4 of 33
15 EXAMPLE SCREENS: SAGEM.MORPHOKIT.ACQUISITIONCOMPONENT – PREDEFINED GRAPHICAL USER INTERFASE ........................................................................................................... 32
15.1 Acquisition ........................................................................................................................................................................................ 32
15.2 Enrollment ........................................................................................................................................................................................ 33
Company Confidential ___________________________________________________________________________________________________________________________
© MorphoTrak 5 of 33
1 Overview The aim of this manual is to create a guide that is uncomplicated to understand and eases the burden of integrators to understand the default Sagem Manual. MorphoKit 4.0 is a set of DLL’s based on the .Net Framework, and requires .Net Framework 2.0 to be installed; however we recommend .Net Framework 3.5 for increased speed. These DLL’s are Microsoft Windows Vista and Windows 7 compliant in both runtime and development environments. The main goal of these new generation DLL’s are to be more compatible with more development environments like Java and Delphi, and to provide companies the flexibility of customizing their own GUI. There is no longer a need to use the set Sagem GUI, therefore making the visual components fit the style of your software. Those clients that choose to still use the set Sagem GUI can also feel free to do so, by using the Sagem.MorphoKit.AcquisitionComponent.dll.
2 Importing the Sagem.MorphoKit Components In order to be able to access all the MorphoKit classes from your project, it is necessary that the relevant component references are included to your project. Using Microsoft Visual Studio.NET environment, the above mentioned task can be carried out as follows: Copy all dependency DLL’s to your application’s bin\debug folder (Folder where the exe is located): ActiveMKit_Enroll.dll Ecm.dll ImageCompress.dll MORPHO_SDK.dll MORPHO_SDK_IMAGE.dll MorphoKit.dll MSO100.dll MSO_Sprs232.dll MSO_SpUsb.dll Sagem.ImageLibrary.dll Sagem.MorphoKit.AcquisitionComponent.dll Sagem.MorphoKit.dll
From your project node, right-click and select the ‘Add Reference...’ option. A dialog box similar to figure 2.1 will appear. Select the ‘Browse’ and navigate to your bin folder Select ‘Sagem.MorphoKit.dll’ and click ‘OK’
The above mentioned steps will add the Sagem.MorphoKit component reference. This component contains a list of classes that will be used in the acquisition, matching and verification steps. This component allows a user to create and design a personalised graphical user interface. These classes are event driven and ease the integration process.
Company Confidential ___________________________________________________________________________________________________________________________
© MorphoTrak 6 of 33
Figure 2.1
3 Importing the Sagem.MorphoKit.AcquisitionComponent Components In order to be able to access all the MorphoKit classes from your project, it is necessary that the relevant component references are included to your project. Using Microsoft Visual Studio.NET environment, the above mentioned task can be carried out as follows: Copy all dependency DLL’s to your application’s bin\debug folder (where the exe is located): ActiveMKit_Enroll.dll Ecm.dll ImageCompress.dll MORPHO_SDK.dll MORPHO_SDK_IMAGE.dll MorphoKit.dll MSO100.dll MSO_Sprs232.dll MSO_SpUsb.dll Sagem.ImageLibrary.dll Sagem.MorphoKit.AcquisitionComponent.dll Sagem.MorphoKit.dll
Company Confidential ___________________________________________________________________________________________________________________________
© MorphoTrak 7 of 33
From your project node, right-click and select the ‘Add Reference...’ option. A dialog box similar to figure 2.2 will appear. Select the ‘Browse’ and navigate to your bin folder Select ‘Sagem.MorphoKit.dll’ and click ‘OK’
The above mentioned steps will add the Sagem.MorphoKit.AcquisitionComponent component reference. This component contains a list of classes that will be used in the acquisition, matching and verification steps. This component has a set GUI, but unlike MorphoKit 3.1 allows you the flexibility of adding your company logo to the acquisition screen.
Figure 2.2
4 Importing the MKIT namespaces to your project
4.1 VB
Imports Sagem.MorphoKit Imports Sagem.MorphoKit.AcquisitionComponent
4.2 C#
using Sagem.MorphoKit; using Sagem.MorphoKit.AcquisitionComponent;
Company Confidential ___________________________________________________________________________________________________________________________
© MorphoTrak 8 of 33
4.3 C++
using namespace Sagem::MorphoKit; using namespace Sagem::MorphoKit::AcquisitionComponent;
5 Declaration of Sagem.MorphoKit events and class instances Required Namespaces: Sagem.MorphoKit
5.1 VB
Dim i_sID As String
Dim i_iScore As Integer
Dim clsDevice As AcquisitionDevice
Dim clsMatcher As Matcher
Dim clsConsolResult As IConsolidatedAcquisitionResult
Dim clsConvertTemplateFormats As Converter
Dim clsPerson As Candidate
'Initialise Variables
clsDevice = New AcquisitionDevice()
clsMatcher = New Matcher()
clsConvertTemplateFormats = New Converter()
clsPerson = New Candidate(i_sID, i_iScore)
'Create Event Handlers
AddHandler clsDevice.EnrolmentEvent, AddressOf clsDevice_EnrolmentEvent
AddHandler clsDevice.FingerEvent, AddressOf clsDevice_FingerEvent
AddHandler clsDevice.QualityEvent, AddressOf clsDevice_QualityEvent
AddHandler clsDevice.ImageEvent, AddressOf clsDevice_ImageEvent
clsDevice.Display = imgDisplay.Handle()
'Events
Private Sub clsDevice_FingerEvent(ByVal Status As Integer)
End Sub
-----------------------------------------------------------------------------
Private Sub clsDevice_EnrolmentEvent(ByVal CaptureIndex As Integer)
End Sub
-----------------------------------------------------------------------------
Private Sub clsDevice_QualityEvent(ByVal quality As Byte)
End Sub
-----------------------------------------------------------------------------
Private Sub clsDevice_ImageEvent(ByVal buffer As Byte(), ByVal width As Integer, ByVal
height As Integer, ByVal resolution As Integer)
End Sub
-----------------------------------------------------------------------------
Company Confidential ___________________________________________________________________________________________________________________________
© MorphoTrak 9 of 33
5.2 C#
AcquisitionDevice clsDevice = new AcquisitionDevice();
Matcher clsMatcher = new Matcher();
IConsolidatedAcquisitionResult consoResult;
Converter objConvertTemplateFormats = new Converter();
Candidate _person = new Candidate(i_cId, i_iScore);
clsDevice.FingerEvent += new FingerEventHandler(this._device_FingerEvent);
clsDevice.EnrolmentEvent += new EnrolmentEventHandler(this._device_EnrolmentEvent);
clsDevice.QualityEvent += new QualityEventHandler(this._device_QualityEvent);
clsDevice.ImageEvent += new ImageEventHandler(this._device_ImageEvent);
clsDevice.Display = this.pctAquire.Handle;
void _device_FingerEvent(int status)
{
}
void _device_EnrolmentEvent(int captureIndex)
{
}
void _device_QualityEvent(byte quality)
{
}
void _device_ImageEvent(byte[] buffer, int width, int height, int resolution)
{
}
Company Confidential ___________________________________________________________________________________________________________________________
© MorphoTrak 10 of 33
5.3 C++
// Declare Variables
static System::String^ _id = "";
static int _score = 0;
AcquisitionDevice^ clsDevice;
Matcher^ clsMatcher;
IConsolidatedAcquisitionResult^ clsConsolResult;
Candidate^ clsPerson;
Sagem::MorphoKit::Converter^ clsConvertTemplates;
// Initialise Variables
clsDevice = gcnew AcquisitionDevice();
clsMatcher = gcnew Matcher();
clsConvertTemplates = gcnew Sagem::MorphoKit::Converter();
clsPerson = gcnew Candidate(_id, _score);
//Create Event Handlers
clsDevice->FingerEvent += gcnew FingerEventHandler(this, &Form1::device_FingerEvent);
clsDevice->EnrolmentEvent += gcnew EnrolmentEventHandler(this,
&Form1::device_EnrolmentEvent);
clsDevice->QualityEvent += gcnew QualityEventHandler(this, &Form1::device_QualityEvent);
clsDevice->ImageEvent += gcnew ImageEventHandler(this, &Form1::device_ImageEvent);
//Image Handle
clsDevice->Display = this->imgDisplay->Handle;
private: void device_FingerEvent(int status)
{
}
private: void device_EnrolmentEvent(int captureIndex)
{
}
private: void device_QualityEvent(unsigned char quality)
{
}
private: void device_ImageEvent(array<unsigned char,1>^ buffer, int width, int height, int
resolution)
{
}
Company Confidential ___________________________________________________________________________________________________________________________
© MorphoTrak 11 of 33
6 Sample Code: Sagem.MorphoKit Acquisition Events Required Namespaces: Sagem.MorphoKit
6.1 VB
Private Sub clsDevice_FingerEvent(ByVal Status As Integer)
Dim msg As String
msg = ""
Select Case Status
Case FingerEventStatus.NO_FINGER_DETECTED : msg = "Place Finger"
Case FingerEventStatus.MOVE_FINGER_DOWN : msg = "Move Down"
Case FingerEventStatus.MOVE_FINGER_UP : msg = "Move Up"
Case FingerEventStatus.MOVE_FINGER_LEFT : msg = "Move Left"
Case FingerEventStatus.MOVE_FINGER_RIGHT : msg = "Move Right"
Case FingerEventStatus.PRESS_FINGER_HARDER : msg = "Press Harder"
Case FingerEventStatus.REMOVE_FINGER : msg = "Remove Finger"
Case FingerEventStatus.OK : msg = "Acquisition Successful"
End Select
lblAcquisitionStatus.Text = msg
End Sub
Private Sub clsDevice_EnrolmentEvent(ByVal CaptureIndex As Integer)
Select Case CaptureIndex
Case 1
lblMessages.Text = "No Enrolling Number 1, 2 More to go"
Case 2
lblMessages.Text = "No Enrolling Number 2, 1 More to go"
Case 3
lblMessages.Text = "Now Enrolling Number 3, Last One"
End Select
End Sub
Private Sub clsDevice_QualityEvent(ByVal quality As Byte)
Dim _quality As Byte
lblQuality.Text = String.Format("Quality = {0}", quality)
If quality < progressQuality.Maximum Then
_quality = quality
Else
_quality = progressQuality.Maximum
End If
progressQuality.Value = _quality
End Sub
Private Sub clsDevice_ImageEvent(ByVal buffer As Byte(), ByVal width As Integer, ByVal
height As Integer, ByVal resolution As Integer)
End Sub
Company Confidential ___________________________________________________________________________________________________________________________
© MorphoTrak 12 of 33
6.2 C#
void _device_FingerEvent(int status)
{
String msg = "";
switch ((FingerEventStatus)status)
{
case FingerEventStatus.NO_FINGER_DETECTED: msg = "Place Finger"; break;
case FingerEventStatus.MOVE_FINGER_DOWN: msg = "Move Down"; break;
case FingerEventStatus.MOVE_FINGER_UP: msg = "Move Up"; break;
case FingerEventStatus.MOVE_FINGER_LEFT: msg = "Move Left"; break;
case FingerEventStatus.MOVE_FINGER_RIGHT: msg = "Move Right"; break;
case FingerEventStatus.PRESS_FINGER_HARDER: msg = "Press Harder"; break;
case FingerEventStatus.REMOVE_FINGER: msg = "Remove Finger"; break;
case FingerEventStatus.OK: msg = "Acquisition Successful"; break;
}
this.lblStatus.Text = msg;
}
void _device_EnrolmentEvent(int captureIndex)
{
switch (captureIndex)
{
case 1:
lblMessages.Text = "Now enrolling number 1 \n2 More to go";
break;
case 2:
lblMessages.Text = "Now enrolling number 2 \n1 More to go";
break;
case 3:
lblMessages.Text = "Now enrolling number 3 \nLast One";
break;
default:
lblMessages.Text = "Error";
break;
}
}
void _device_QualityEvent(byte quality)
{
this.textQuality.Text = String.Format("live quality = {0}", quality);
this.progressQuality.Value = quality < this.progressQuality.Maximum ? quality :
this.progressQuality.Maximum;
}
void device_ImageEvent(byte[] buffer, int width, int height, int resolution)
{
}
Company Confidential ___________________________________________________________________________________________________________________________
© MorphoTrak 13 of 33
6.3 C++
private: void device_FingerEvent(int status)
{
String^ msg = "";
switch ((FingerEventStatus)status)
{
case FingerEventStatus::NO_FINGER_DETECTED: msg = "Place Finger"; break;
case FingerEventStatus::MOVE_FINGER_DOWN: msg = "Move Down"; break;
case FingerEventStatus::MOVE_FINGER_UP: msg = "Move Up"; break;
case FingerEventStatus::MOVE_FINGER_LEFT: msg = "Move Left"; break;
case FingerEventStatus::MOVE_FINGER_RIGHT: msg = "Move Right"; break;
case FingerEventStatus::PRESS_FINGER_HARDER: msg = "Press Harder"; break;
case FingerEventStatus::REMOVE_FINGER: msg = "Remove Finger"; break;
case FingerEventStatus::OK: msg = "Acquisition Successful"; break;
}
this->lblStatus->Text = msg;
}
private: void device_EnrolmentEvent(int captureIndex)
{
switch (captureIndex)
{
case 1:
lblMessages->Text = "Now enrolling number 1.. 2 More to go";
break;
case 2:
lblMessages->Text = "Now enrolling number 2.. 1 More to go";
break;
case 3:
lblMessages->Text = "Now enrolling number 3.. Last One";
break;
default:
lblMessages->Text = "Error";
break;
}
}
private: void device_QualityEvent(unsigned char quality)
{
this->txtQuality->Text = String::Format("Live Quality = {0}", quality);
this->progressQuality->Value = quality < this->progressQuality->Maximum ?
quality : this->progressQuality->Maximum;
}
Company Confidential ___________________________________________________________________________________________________________________________
© MorphoTrak 14 of 33
7 Sample Code: Acquisition Sagem.MorphoKit Required Namespaces: Sagem.MorphoKit System.IO
7.1 VB
Sub Acquire()
Dim _sSerialNumber As String
clsDevice.TimeOut = 15
lblMessages.Text = "Place your finger to identify"
Dim coder As Coder = New Coder
'Enumerate Devices and select first one
Dim _deviceInfo As IAcquisitionDeviceInfo()
_deviceInfo = clsDevice.EnumerateDevices()
_sSerialNumber = _deviceInfo(0).SerialNumber
If chkConsolidate.Checked = True Then
' Enroll
Dim consoResult As IConsolidatedAcquisitionResult
consoResult = clsDevice.AcquireConsolidated(_sSerialNumber)
If consoResult.Status = 0 Then
Dim cfv As Byte()
Dim consolResult As IConsolidationResult
Dim coderResult1 As ICoderResult
Dim coderResult2 As ICoderResult
Dim coderResult3 As ICoderResult
imgDisplay.Image = CreateGreyscaleBitmap(consoResult.ImageBuffer1,
consoResult.Width, consoResult.Height)
coderResult1 = coder.Enroll(consoResult.ImageBuffer1, consoResult.Width,
consoResult.Height, 2)
coderResult2 = coder.Enroll(consoResult.ImageBuffer1, consoResult.Width,
consoResult.Height, 2)
coderResult3 = coder.Enroll(consoResult.ImageBuffer1, consoResult.Width,
consoResult.Height, 2)
consolResult = coder.Consolidate(coderResult1.Template,
coderResult2.Template, coderResult3.Template)
'This Byte Array (cfv) can be saved to a database as a fingerprint template
cfv = consolResult.Template
'If you wish to save the enrolled template to a file, use below
Company Confidential ___________________________________________________________________________________________________________________________
© MorphoTrak 15 of 33
Dim fileDlg As SaveFileDialog = New SaveFileDialog()
If fileDlg.ShowDialog() = Windows.Forms.DialogResult.OK Then
Dim fs As FileStream = New FileStream(fileDlg.FileName, FileMode.Create)
fs.Write(cfv, 0, cfv.Length)
fs.Close()
End If
Else
Dim result As IAcquisitionResult = clsDevice.Acquire(_sSerialNumber)
If result.Status = 0 Then
Dim coderResult As ICoderResult
imgDisplay.Image = CreateGreyscaleBitmap(result.ImageBuffer,
result.Width, result.Height)
coderResult = coder.Enroll(result.ImageBuffer, result.Width,
result.Height, 2)
Dim cfv As Byte()
' This byte array can be used to match a fingerprint template in the
matcher database
cfv = coderResult.Template
End If
End If
End If
End Sub
7.2 C#
private void btnAcquire_Click(object sender, EventArgs e)
{
//Enumerate Devices and Select first Device in the list
String serialNumber = "";
IAcquisitionDeviceInfo[] _deviceInfo = _device.EnumerateDevices();
serialNumber = _deviceInfo[0].SerialNumber;
if (this.cbConsolidaton.Checked)
{
// call the Acquire method
IConsolidatedAcquisitionResult consoResult =
_device.AcquireConsolidated(serialNumber);
if (consoResult.Status == 0)
{
// update our PictureBox with image1 (for example)
this.display.Image = CreateGreyscaleBitmap(consoResult.ImageBuffer1 as
byte[], consoResult.Width, consoResult.Height);
Coder coder = new Coder();
ICoderResult coderResult1 = coder.Enroll(consoResult.ImageBuffer1,
consoResult.Width, consoResult.Height, 2);
ICoderResult coderResult2 = coder.Enroll(consoResult.ImageBuffer2,
consoResult.Width, consoResult.Height, 2);
Company Confidential ___________________________________________________________________________________________________________________________
© MorphoTrak 16 of 33
ICoderResult coderResult3 = coder.Enroll(consoResult.ImageBuffer3,
consoResult.Width, consoResult.Height, 2);
IConsolidationResult consolResult =
coder.Consolidate(coderResult1.Template, coderResult2.Template,
coderResult3.Template);
// This template can be used to save to a database
byte[] cfv = consolResult.Template as byte[];
// Save the enrolled template to a file
SaveFileDialog fileDlg = new SaveFileDialog();
if (fileDlg.ShowDialog() == DialogResult.OK)
{
FileStream fs = new FileStream(fileDlg.FileName, FileMode.Create);
fs.Write(cfv, 0, cfv.Length);
fs.Close();
}
}
}
else
{
// call the Acquire method
IAcquisitionResult result = _device.Acquire(serialNumber);
if (result.Status == 0)
{
byte[] cfv;
Coder coder = new Coder();
display.Image = CreateGreyscaleBitmap(result.ImageBuffer as byte[],
result.Width, result.Height);
ICoderResult coderResult = coder.Enroll(result.ImageBuffer,
result.Width, result.Height, 2);
// This byte array (template) can be used to match a fingerprint against a
matcher database
cfv = coderResult.Template;
}
}
}
7.3 C++
private: void Acquire()
{
//Enumerate Devices and Select first Device in the list
String^ serialNumber = "";
array < IAcquisitionDeviceInfo^, 1 >^ _deviceInfo;
_deviceInfo = clsDevice->EnumerateDevices();
serialNumber = _deviceInfo[0]->SerialNumber;
if (this->chkConsolidate->Checked)
{
Company Confidential ___________________________________________________________________________________________________________________________
© MorphoTrak 17 of 33
// call the Acquire method
clsConsolResult = clsDevice->AcquireConsolidated(serialNumber);
if (clsConsolResult->Status == 0)
{
// update our PictureBox with image1 (for example)
this->imgDisplay->Image = CreateGreyscaleBitmap(clsConsolResult->ImageBuffer1,
clsConsolResult->Width, clsConsolResult->Height);
Coder^ coder = gcnew Coder();
ICoderResult^ coderResult1 = coder->Enroll(clsConsolResult->ImageBuffer1,
clsConsolResult->Width, clsConsolResult->Height, 2);
ICoderResult^ coderResult2 = coder->Enroll(clsConsolResult->ImageBuffer2,
clsConsolResult->Width, clsConsolResult->Height, 2);
ICoderResult^ coderResult3 = coder->Enroll(clsConsolResult->ImageBuffer3,
clsConsolResult->Width, clsConsolResult->Height, 2);
IConsolidationResult^ consolResult = coder->Consolidate(coderResult1->Template,
coderResult2->Template, coderResult3->Template);
// This template can be used to save to a database
array<unsigned char,1>^ cfv = consolResult->Template;
// Save the enrolled template to a file
SaveFileDialog^ fileDlg = gcnew SaveFileDialog();
if (fileDlg->ShowDialog() == ::DialogResult::OK)
{
FileStream^ fs = gcnew FileStream(fileDlg->FileName, FileMode::Create);
fs->Write(cfv, 0, cfv->Length);
fs->Close();
}
}
}
else
{
// call the Acquire method
IAcquisitionResult^ result = clsDevice->Acquire(serialNumber);
if (result->Status == 0)
{
array<unsigned char,1>^ cfv;
Coder^ coder = gcnew Coder();
this->imgDisplay->Image = CreateGreyscaleBitmap(result->ImageBuffer,
result->Width, result->Height);
ICoderResult^ coderResult = coder->Enroll(result->ImageBuffer, result-
>Width, result->Height, 2);
// This byte array (template) can be used to match a fingerprint against
a matcher database
cfv = coderResult->Template;
}
}
}
Company Confidential ___________________________________________________________________________________________________________________________
© MorphoTrak 18 of 33
8 Sample Code: Loading Fingerprints into the matcher from a database Required Namespaces: Sagem.MorphoKit System.Data.OleDb
8.1 VB
Sub populateMatcher(ByRef match As Matcher)
'Create Variables
Dim cmd As OleDb.OleDbCommand
Dim conn As OleDb.OleDbConnection
Dim reader As OleDb.OleDbDataReader
Dim RecordTemplate As FingerTemplate
Dim matcherRecord As Record
Dim SelectStatement As String
Dim TemplateID As Integer
Dim Temp_Template As Byte()
Dim objConvert As Converter
'Initialize Variables
cmd = New OleDb.OleDbCommand()
conn = New OleDb.OleDbConnection()
RecordTemplate = New FingerTemplate()
matcherRecord = New Record
reader = Nothing
objConvert = New Converter()
Try
'Database code
conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data
source=Training.mdb; User Id=admin; Password=;"
SelectStatement = "SELECT * FROM Users "
cmd.CommandTimeout = 15
cmd.Connection = conn
cmd.CommandText = SelectStatement
conn.Open()
reader = cmd.ExecuteReader()
TemplateID = 0
While reader.Read()
Temp_Template = reader(2)
'Get Templates into correct format for Mkit 4.0
RecordTemplate.Buffer = objConvert.Import(Temp_Template,
TemplateFormat.Sagem_PKCOMPV2, 2)
'Save Template To Matcher
TemplateID = 2
RecordTemplate.Id = TemplateID
Company Confidential ___________________________________________________________________________________________________________________________
© MorphoTrak 19 of 33
matcherRecord.Id = reader(1)
matcherRecord.AddTemplate(RecordTemplate)
match.Insert(matcherRecord)
End While
Finally
conn = Nothing
cmd = Nothing
End Try
8.2 C#
public void populatematcher(ref Matcher match)
{
try
{
cmd = new OleDbCommand();
conn = new OleDbConnection();
OleDbDataReader reader = null;
Record matcherRecord = new Record();
FingerTemplate RecordTemplate = new FingerTemplate();
conn.ConnectionString = connString;
string sInsert = "";
sInsert = "Select * From Users ";
cmd.CommandTimeout = 15;
cmd.Connection = conn;
cmd.CommandText = sInsert;
conn.Open();
reader = cmd.ExecuteReader();
int TemplateID = 0;
byte[] Temp;
while (reader.Read())
{
Temp = (byte[])reader[2];
//Get Template in correct format
RecordTemplate.Buffer = objConvert.Import(Temp,
TemplateFormat.Sagem_PKCOMPV2, 2);
//Save Template to matcher
TemplateID = 2;
RecordTemplate.Id = (byte)TemplateID;
matcherRecord.Id = (string)reader[1];
matcherRecord.AddTemplate(RecordTemplate);
match.Insert(matcherRecord);
}
}
finally
Company Confidential ___________________________________________________________________________________________________________________________
© MorphoTrak 20 of 33
{
if (conn != null)
{
conn.Close();
}
conn = null;
cmd = null;
}
}
8.3 C++
private: void populatematcher(Matcher^ match)
{
OleDbCommand^ cmd = gcnew OleDbCommand();
OleDbConnection^ conn = gcnew OleDbConnection();
OleDbDataReader^ reader;
Record^ matcherRecord = gcnew Record();
FingerTemplate^ RecordTemplate = gcnew FingerTemplate();
String^ ConnStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Users.mdb;User
Id=admin;Password=;Jet OLEDB:Engine Type=5";
try
{
conn->ConnectionString = ConnStr;
String^ sInsert = "";
sInsert = "Select * From Users ";
cmd->CommandTimeout = 15;
cmd->Connection = conn;
cmd->CommandText = sInsert;
conn->Open();
reader = cmd->ExecuteReader();
int TemplateID = 0;
array<unsigned char,1>^ Temp;
while (reader->Read())
{
Temp = (array<unsigned char,1>^)reader[2];
//Get Template in correct format
RecordTemplate->Buffer = clsConvertTemplates->Import(Temp,
TemplateFormat::Sagem_PKCOMPV2, 2);
//Save Template to matcher
TemplateID = 2;
RecordTemplate->Id = TemplateID;
matcherRecord->Id = (String^)reader[1];
matcherRecord->AddTemplate(RecordTemplate);
match->Insert(matcherRecord);
}
}
finally
Company Confidential ___________________________________________________________________________________________________________________________
© MorphoTrak 21 of 33
{
delete conn;
delete cmd;
}
}
Company Confidential ___________________________________________________________________________________________________________________________
© MorphoTrak 22 of 33
9 Sample Code: Identify with Matcher Required Namespaces: Sagem.MorphoKit
9.1 VB
Function Identify(ByVal i_clsMatch As Matcher, ByVal i_bFingerPK As Byte()) As Candidate
Dim _person As Candidate
Dim _id As String = ""
Dim _Score As Integer = 0
_person = New Candidate(_id, _Score)
_person = i_clsMatch.IdentifyTemplate(i_bFingerPK)
Return _person
End Function
9.2 C#
private Candidate Identify(Matcher i_clsMatch, Byte[] i_bFingerPK)
{
String _id = "";
int _score = 0;
Candidate _person = new Candidate(_id, _score);
_person = i_clsMatcher.IdentifyTemplate(i_bFingerPK);
return _person;
}
9.3 C++
private: Candidate^ Identify(Matcher^ i_clsMatch, array<unsigned char,1>^ i_bFingerPK)
{
String^ _id = "";
int _score = 0;
Candidate^ _person = gcnew Candidate(_id, _score);
_person = i_clsMatch->IdentifyTemplate(i_bFingerPK);
return _person;
}
Company Confidential ___________________________________________________________________________________________________________________________
© MorphoTrak 23 of 33
10 Declaration of Sagem.MorphoKit.AcquisitionComponent class instances
Required Namespaces: Sagem.MorphoKit.AcquisitionComponent
10.1 VB
Dim clsAcquisitionComponent As AcquisitionComponent
Dim clsAcqResult As AcquisitionComponentResult
'Initialise Variables
clsAcquisitionComponent = New AcquisitionComponent()
10.2 C#
private AquisitionComponent acquisition = new AquisitionComponent();
AcquisitionComponentResult result;
10.3 C++
// Declare Variables
Sagem::MorphoKit::AcquisitionComponent::AcquisitionComponent^ clsAcquisition;
AcquisitionComponentResult^ clsACResult;
//Initialise Variables
clsAcquisition = gcnew Sagem::MorphoKit::AcquisitionComponent::AcquisitionComponent();
clsACResult = gcnew AcquisitionComponentResult();
Company Confidential ___________________________________________________________________________________________________________________________
© MorphoTrak 24 of 33
11 Sample Code: Acquisition with Sagem.MorphoKit.AcquisitionComponent
Required Namespaces: Sagem.MorphoKit Sagem.MorphoKit.AcquisitionComponent
11.1 VB
'Variables
Dim cfv As Byte()
Dim quality As Integer
'Acquisition Settings
clsAcquisitionComponent.AcquisitionMode = AcquisitionMode.ENROLL
clsAcquisitionComponent.Title = "MKit 4.0 Demo"
clsAcquisitionComponent.Consolidation = True
clsAcquisitionComponent.LogoPath = Application.StartupPath & "\\ideco.JPG"
clsAcquisitionComponent.ShowQualityBar = True
clsAcquisitionComponent.ShowQualityThreshold = True
clsAcquisitionComponent.TimeOut = 3
'Run Acquisition
clsAcqResult = clsAcquisitionComponent.RunAcquisition()
If clsAcqResult.Status = 0 Then
'Convert Template into a format that can be used by MA reader, this format is
also the smallest: 170 bytes
'This byte array (Template), can now be saved o a database
cfv = clsConvertTemplateFormats.Export(clsAcqResult.Template, 2,
TemplateFormat.Sagem_PKMAT)
'The quality can be saved with the template
quality = clsAcqResult.Quality
End If
11.2 C#
try
{
AcquisitionComponent acquisition = new AcquisitionComponent();
//Acquisition settings
acquisition.AcquisitionMode = AcquisitionMode.ENROLL;
acquisition.Title = "MKIT and MACI APP";
acquisition.Consolidation = true;
acquisition.LogoPath = Application.StartupPath + "\\ideco.JPG";
acquisition.ShowQualityBar = true;
acquisition.ShowQualityThreshold = true;
acquisition.TimeOut = 3;
//Run acquisition
AcquisitionComponentResult result = acquisition.RunAcquisition();
Company Confidential ___________________________________________________________________________________________________________________________
© MorphoTrak 25 of 33
if (result.Status == 0)
{
//Convert Template into a format that can be used by MA reader, this
format is also the smallest: 170 bytes
//This byte array (Template), can now be saved o a database
Converter objConvertTemplateFormats = new Converter();
byte[] cfv1 = objConvertTemplateFormats.Export(result.Template, 2,
TemplateFormat.Sagem_PKMAT);
//The quality can be saved with the template
quality = result.Quality;
}
return cfv1;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK,
MessageBoxIcon.Warning);
return null;
}
finally
{
}
11.3 C++
private: array<unsigned char,1>^ AcquisitionWAC()
{
//Acquisition settings
array<unsigned char,1>^ cfv1;
clsAcquisition->AcquisitionMode = AcquisitionMode::ENROLL;
clsAcquisition->Title = "MKIT and MACI APP";
clsAcquisition->Consolidation = true;
clsAcquisition->LogoPath = Application::StartupPath + "\\ideco.JPG";
clsAcquisition->ShowQualityBar = true;
clsAcquisition->ShowQualityThreshold = true;
clsAcquisition->TimeOut = 3;
//Run acquisition
clsACResult = clsAcquisition->RunAcquisition();
if (clsACResult->Status == 0)
{
//Convert Template into a format that can be used by MA reader, this
format is also the smallest: 170 bytes
//This byte array (Template), can now be saved o a database
cfv1 = clsConvertTemplates->Export(clsACResult->Template, 2,
TemplateFormat::Sagem_PKMAT);
//The quality can be saved with the template
int quality = clsACResult->Quality;
}
return cfv1;
}
Company Confidential ___________________________________________________________________________________________________________________________
© MorphoTrak 26 of 33
12 Sample Code: Miscellaneous: CreateGreyscaleBitmap Required Namespaces: System.Drawing System.Drawing.Imaging
12.1 VB
Function CreateGreyscaleBitmap(ByVal buffer As Byte(), ByVal width As Integer, ByVal
height As Integer)
Try
Dim bmp As Bitmap
Dim bmpData As BitmapData
bmp = New Bitmap(width, height,
System.Drawing.Imaging.PixelFormat.Format8bppIndexed)
bmpData = bmp.LockBits(New Rectangle(0, 0, width, height),
ImageLockMode.ReadWrite, PixelFormat.Format8bppIndexed)
System.Runtime.InteropServices.Marshal.Copy(buffer, 0, bmpData.Scan0, width *
height)
bmp.UnlockBits(bmpData)
'Setup Greyscale palette
Dim pal As ColorPalette = bmp.Palette
For i As Integer = 0 To 255
pal.Entries(i) = Color.FromArgb(i, i, i)
Next
bmp.Palette = pal
Return bmp
Catch ex As Exception
MessageBox.Show(ex.Message, "Error")
Return Nothing
End Try
End Function
12.2 C#
private Bitmap CreateGreyScaleImage(byte[] buffer, int width, int height)
{
Bitmap bmp = new Bitmap(width, height,
System.Drawing.Imaging.PixelFormat.Format8bppIndexed);
//Copy Aqcuired Image Data to Bitmap
//All MSO widths are multiples of 4
BitmapData bmpData = bmp.LockBits(new Rectangle(0, 0, width, height),
ImageLockMode.ReadWrite, PixelFormat.Format8bppIndexed);
Company Confidential ___________________________________________________________________________________________________________________________
© MorphoTrak 27 of 33
System.Runtime.InteropServices.Marshal.Copy(buffer, 0, bmpData.Scan0, width *
height);
bmp.UnlockBits(bmpData);
//Set up a greyscale palette
ColorPalette pal = bmp.Palette;
for (int i = 0; i < 256; i++)
pal.Entries[i] = Color.FromArgb(i, i, i);
bmp.Palette = pal;
return bmp;
}
12.3 C++
private: Bitmap^ CreateGreyscaleBitmap(array<unsigned char,1>^ buffer, int width, int
height)
{
Bitmap^ bmp = gcnew Bitmap(width, height,
System::Drawing::Imaging::PixelFormat::Format8bppIndexed);
//Copy Aqcuired Image Data to Bitmap
//All MSO widths are multiples of 4
//Rectangle^ rect;
BitmapData^ bmpData = bmp->LockBits(Rectangle(0,0, width, height),
ImageLockMode::ReadWrite, PixelFormat::Format8bppIndexed);
System::Runtime::InteropServices::Marshal::Copy(buffer, 0, bmpData->Scan0, width
* height);
bmp->UnlockBits(bmpData);
//Set up a greyscale palette
ColorPalette^ pal = bmp->Palette;
for (int i = 0; i < 256; i++)
pal->Entries[i] = Color::FromArgb(i, i, i);
bmp->Palette = pal;
\\return bmp;
}
Company Confidential ___________________________________________________________________________________________________________________________
© MorphoTrak 28 of 33
13 Sample Code: Miscellaneous: Create a Template from an Image Required Namespaces: Sagem.MorphoKit System.IO
13.1 VB
Sub SaveTemplateFromImage(ByVal bmp As Bitmap)
Try
'Variable declaration
Dim fileDlg As SaveFileDialog
Dim coder As Coder
Dim _bmp As Bitmap
Dim coderResult As ICoderResult
Dim cfv As Byte()
Dim fs As FileStream
'Initialize
fileDlg = New SaveFileDialog()
coder = New Coder()
_bmp = New Bitmap(416, 416, PixelFormat.Format8bppIndexed)
coder.CoderAlgorithm = CoderAlgorithm.V9
_bmp = bmp
coderResult = coder.EnrollBitmap(_bmp, 2)
cfv = coderResult.Template
If fileDlg.ShowDialog() = Windows.Forms.DialogResult.OK Then
fs = New FileStream(fileDlg.FileName, FileMode.Create)
fs.Write(cfv, 0, cfv.Length)
fs.Close()
End If
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
13.2 C#
private void btnSaveTemplate_Click(object sender, EventArgs e)
{
try
{
Coder coder = new Coder();
coder.CoderAlgorithm = CoderAlgorithm.V9;
Bitmap bmp = new Bitmap(416, 416, PixelFormat.Format8bppIndexed);
bmp = (Bitmap)this.display.Image;
ICoderResult coderResult = coder.EnrollBitmap(bmp, 2);
byte[] cfv = coderResult.Template as byte[];
SaveFileDialog fileDlg = new SaveFileDialog();
if (fileDlg.ShowDialog() == DialogResult.OK)
Company Confidential ___________________________________________________________________________________________________________________________
© MorphoTrak 29 of 33
{
FileStream fs = new FileStream(fileDlg.FileName, FileMode.Create);
fs.Write(cfv, 0, cfv.Length);
fs.Close();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
13.3 C++
private: void SaveTemplate()
{
Coder^ coder = gcnew Coder();
coder->CoderAlgorithm = CoderAlgorithm::V9;
Bitmap^ bmp = gcnew Bitmap(416, 416, PixelFormat::Format8bppIndexed);
bmp = (Bitmap^)this->imgDisplay->Image;
ICoderResult^ coderResult = coder->EnrollBitmap(bmp, 2);
array<unsigned char,1>^ cfv = coderResult->Template;
SaveFileDialog^ fileDlg = gcnew SaveFileDialog();
if (fileDlg->ShowDialog() == ::DialogResult::OK)
{
FileStream^ fs = gcnew FileStream(fileDlg->FileName, FileMode::Create);
fs->Write(cfv, 0, cfv->Length);
fs->Close();
}
}
Company Confidential ___________________________________________________________________________________________________________________________
© MorphoTrak 30 of 33
14 Example Screens: Sagem.MorphoKit – Personalised Graphical User Interfase
14.1 Acquisition
Company Confidential ___________________________________________________________________________________________________________________________
© MorphoTrak 31 of 33
14.2 Enrollment - Consolidation
Company Confidential ___________________________________________________________________________________________________________________________
© MorphoTrak 32 of 33
15 Example Screens: Sagem.MorphoKit.AcquisitionComponent – Predefined Graphical User Interfase
15.1 Acquisition