Reputation: 417
I am currently using a biometric device name "SecuGen Hamster", I am able to capture the fingerprint image and save the image into local pc.
But how can I load the image back and do the verification as the verification is done in real-time during the capture of the finger print.
Here is the code I used to capture and save fingerprint image:
private void BtnCapture1_Click(object sender, System.EventArgs e)
{
Int32 iError;
Byte[] fp_image;
Int32 img_qlty;
fp_image = new Byte[m_ImageWidth * m_ImageHeight];
img_qlty = 0;
iError = m_FPM.GetImage(fp_image);
m_FPM.GetImageQuality(m_ImageWidth, m_ImageHeight, fp_image, ref img_qlty);
progressBar_R1.Value = img_qlty;
if (iError == (Int32)SGFPMError.ERROR_NONE)
{
DrawImage(fp_image, pictureBoxR1);
pictureBoxR1.Image.Save(@"D:\TEMP\LeftThumb.jpeg", ImageFormat.Jpeg);
iError = m_FPM.CreateTemplate(fp_image, m_RegMin1);
if (iError == (Int32)SGFPMError.ERROR_NONE)
StatusBar.Text = "First image is captured";
else
DisplayError("CreateTemplate()", iError);
}
else
DisplayError("GetImage()", iError);
}
Here is how it verifies:
/// MatchTemplate(), GetMatchingScore()
private void BtnVerify_Click(object sender, System.EventArgs e)
{
Int32 iError;
bool matched1 = false;
bool matched2 = false;
SGFPMSecurityLevel secu_level;
secu_level = (SGFPMSecurityLevel)comboBoxSecuLevel_V.SelectedIndex;
iError = m_FPM.MatchTemplate(m_RegMin1, m_VrfMin, secu_level, ref matched1);
iError = m_FPM.MatchTemplate(m_RegMin2, m_VrfMin, secu_level, ref matched2);
if (iError == (Int32)SGFPMError.ERROR_NONE)
{
if(radioButton1.Checked == true){
if (matched1) //left
StatusBar.Text = "Left Thumb Verification Success";
else
StatusBar.Text = "Verification Failed";
}
else if (radioButton2.Checked == true)
{
if (matched2) //right
StatusBar.Text = "Right Thumb Verification Success";
else
StatusBar.Text = "Verification Failed";
}
}
else
DisplayError("MatchTemplate()", iError);
}
What I mean is when I browse the fingerprint image, can it convert the jpeg files to bytes and then verify it?
Thanks
Upvotes: 2
Views: 2470
Reputation: 686
The byte array that is returned by FPM.GetImage only has the raw pixel data without the BMP header, which is why you can't copy the array to a picturebox and show the image.
Refer to the BMP format at https://en.wikipedia.org/wiki/BMP_file_format.
The Hamster Pro (which I have) has a scan resolution of 400x300 with 8 bit/pixel for grayscale information. This means that the raw pixel data should result in an array of 12,000 bytes. Which is the actual array that is returned from this method. To display the image, there should be a header of 1,078 bytes as well, without which you get the "Invalid parameter" error.
To convert the raw pixel array returned by this call into a proper BMP object, refer to http://syedemad.com/save-secugen-finger-print-image/ to see how it's done.
The file size you would be seeing when saving should be 12000 + 1078 bytes. Correct?
To get to your question, the CreateTemplate method uses the array returned by GetImage to create the template and not the full BMP format.
Your mistake is that you are using PictureBox.Image.Save method to save a BMP format and trying to compare it with the raw array. Instead, encode the array returned at registration time using Base64 and save that. When checking, load back that saved array instead of reading the BMP file.
Upvotes: 1
Reputation: 354
I don't have access to the SDK docs, but the common pattern for fingerprint matching is to capture an image, then extract a template (the useful features in the image), then store those on disk (not the image) and use them later for matching.
Looking at your code sample, the information you actually want to save is in m_RegMin1 I think, quite possibly a byte[] already. So in the first block do a File.SaveAllBytes("foo.bin", m_RegMin1). In the second block restore it with a File.ReadAllBytes. I think secugen generates ISO templates, check the saved files with a hex editors, the first 3 bytes should be 'F', 'M' and 'R'.
Upvotes: 1