Professional Documents
Culture Documents
Morpokit
Morpokit
Morpokit
___________________________________________________________________________________________________________________________
MorphoTrak
1 of 33
Company Confidential
___________________________________________________________________________________________________________________________
Table of Contents
1
OVERVIEW ......................................................................................................................................... 5
4.1
VB ........................................................................................................................................................................................................ 7
4.2
C#......................................................................................................................................................................................................... 7
4.3
C++ ...................................................................................................................................................................................................... 8
5.1
VB ........................................................................................................................................................................................................ 8
5.2
C#......................................................................................................................................................................................................... 9
5.3
C++ .................................................................................................................................................................................................... 10
6.1
VB ...................................................................................................................................................................................................... 11
6.2
C#....................................................................................................................................................................................................... 12
6.3
C++ .................................................................................................................................................................................................... 13
7.1
VB ...................................................................................................................................................................................................... 14
7.2
C#....................................................................................................................................................................................................... 15
7.3
C++ .................................................................................................................................................................................................... 16
SAMPLE CODE: LOADING FINGERPRINTS INTO THE MATCHER FROM A DATABASE ......... 18
8.1
VB ...................................................................................................................................................................................................... 18
8.2
C#....................................................................................................................................................................................................... 19
MorphoTrak
2 of 33
Company Confidential
___________________________________________________________________________________________________________________________
8.3
C++ .................................................................................................................................................................................................... 20
9.1
VB ...................................................................................................................................................................................................... 22
9.2
C#....................................................................................................................................................................................................... 22
9.3
C++ .................................................................................................................................................................................................... 22
10
10.1
VB ...................................................................................................................................................................................................... 23
10.2
C#....................................................................................................................................................................................................... 23
10.3
C++ .................................................................................................................................................................................................... 23
11
11.1
VB ...................................................................................................................................................................................................... 24
11.2
C#....................................................................................................................................................................................................... 24
11.3
C++ .................................................................................................................................................................................................... 25
12
12.1
VB ...................................................................................................................................................................................................... 26
12.2
C#....................................................................................................................................................................................................... 26
12.3
C++ .................................................................................................................................................................................................... 27
13
13.1
VB ...................................................................................................................................................................................................... 28
13.2
C#....................................................................................................................................................................................................... 28
13.3
C++ .................................................................................................................................................................................................... 29
Acquisition ........................................................................................................................................................................................ 30
14.2
MorphoTrak
3 of 33
Company Confidential
___________________________________________________________________________________________________________________________
Acquisition ........................................................................................................................................................................................ 32
15.2
Enrollment ........................................................................................................................................................................................ 33
MorphoTrak
4 of 33
Company Confidential
___________________________________________________________________________________________________________________________
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 DLLs 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 DLLs are Microsoft
Windows Vista and Windows 7 compliant in both runtime and development environments.
The main goal of these new generation DLLs 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.
MorphoTrak
5 of 33
Company Confidential
___________________________________________________________________________________________________________________________
Figure 2.1
MorphoTrak
6 of 33
Company Confidential
___________________________________________________________________________________________________________________________
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.2 C#
using Sagem.MorphoKit;
using Sagem.MorphoKit.AcquisitionComponent;
MorphoTrak
7 of 33
Company Confidential
___________________________________________________________________________________________________________________________
4.3 C++
using namespace Sagem::MorphoKit;
using namespace Sagem::MorphoKit::AcquisitionComponent;
5.1 VB
Dim i_sID As String
Dim i_iScore As Integer
Dim
Dim
Dim
Dim
Dim
clsDevice As AcquisitionDevice
clsMatcher As Matcher
clsConsolResult As IConsolidatedAcquisitionResult
clsConvertTemplateFormats As Converter
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
-----------------------------------------------------------------------------
MorphoTrak
8 of 33
Company Confidential
___________________________________________________________________________________________________________________________
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)
{
}
MorphoTrak
9 of 33
Company Confidential
___________________________________________________________________________________________________________________________
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)
{
}
MorphoTrak
10 of 33
Company Confidential
___________________________________________________________________________________________________________________________
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
MorphoTrak
11 of 33
Company Confidential
___________________________________________________________________________________________________________________________
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)
{
}
MorphoTrak
12 of 33
Company Confidential
___________________________________________________________________________________________________________________________
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;
}
MorphoTrak
13 of 33
Company Confidential
___________________________________________________________________________________________________________________________
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
Dim
Dim
Dim
consolResult
coderResult1
coderResult2
coderResult3
As
As
As
As
IConsolidationResult
ICoderResult
ICoderResult
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
MorphoTrak
14 of 33
Company Confidential
___________________________________________________________________________________________________________________________
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);
MorphoTrak
15 of 33
Company Confidential
___________________________________________________________________________________________________________________________
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)
{
MorphoTrak
16 of 33
Company Confidential
___________________________________________________________________________________________________________________________
MorphoTrak
17 of 33
Company Confidential
___________________________________________________________________________________________________________________________
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
MorphoTrak
18 of 33
Company Confidential
___________________________________________________________________________________________________________________________
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
MorphoTrak
19 of 33
Company Confidential
___________________________________________________________________________________________________________________________
{
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
MorphoTrak
20 of 33
Company Confidential
___________________________________________________________________________________________________________________________
{
delete conn;
delete cmd;
}
}
MorphoTrak
21 of 33
Company Confidential
___________________________________________________________________________________________________________________________
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;
}
MorphoTrak
22 of 33
Company Confidential
___________________________________________________________________________________________________________________________
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();
MorphoTrak
23 of 33
Company Confidential
___________________________________________________________________________________________________________________________
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();
MorphoTrak
24 of 33
Company Confidential
___________________________________________________________________________________________________________________________
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;
}
MorphoTrak
25 of 33
Company Confidential
___________________________________________________________________________________________________________________________
12.1 VB
Function CreateGreyscaleBitmap(ByVal buffer As Byte(), ByVal width As Integer, ByVal
height As Integer)
Try
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);
MorphoTrak
26 of 33
Company Confidential
___________________________________________________________________________________________________________________________
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;
}
MorphoTrak
27 of 33
Company Confidential
___________________________________________________________________________________________________________________________
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)
MorphoTrak
28 of 33
Company Confidential
___________________________________________________________________________________________________________________________
{
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();
}
}
MorphoTrak
29 of 33
Company Confidential
___________________________________________________________________________________________________________________________
MorphoTrak
30 of 33
Company Confidential
___________________________________________________________________________________________________________________________
MorphoTrak
31 of 33
Company Confidential
___________________________________________________________________________________________________________________________
MorphoTrak
32 of 33
Company Confidential
___________________________________________________________________________________________________________________________
15.2 Enrollment
MorphoTrak
33 of 33