We are using digital persona for our biometrics. We can already save employee ID, employee name and assigned finger .Our problem is that we dont know how to save a fingerprint template to a database and retrieve it so that it can still be read and verified by the biometric scanner. The file extension is ".ftp" .

Private Sub buttonRegister_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles buttonRegister.Click

        'Does user already exists
        Dim bUserExists As Boolean = _Users.UserExists(New UserID(textBoxUserName.Text))

        ' first make sure the user is created if new user
        If _ActiveUser Is Nothing Or Not bUserExists Then
            ' initialize with supplied user name
            _ActiveUser = New User(textBoxUserName.Text)
        Else
            ' update active user if not as originally selected
            If bUserExists And Not listBoxUsers.SelectedItem.ToString() = textBoxUserName.Text Then
                _ActiveUser = _Users(New UserID(textBoxUserName.Text))
            End If
        End If

        ' and check if the template already exists for the assigned finger
        If _ActiveUser.TemplateExists(_AssignedFinger) Then
            ' show message indicating template already exists for selected finger
            Dim diagResult As DialogResult = MessageBox.Show(Me, [String].Format("Oops!" + ControlChars.Cr + ControlChars.Lf + "{0} has a template enrolled to his/her {1} finger." + ControlChars.Cr + ControlChars.Lf + ControlChars.Cr + ControlChars.Lf + "Shall the old template be discarded?", _ActiveUser.ID.ToString(), _Fingers(_AssignedFinger)), "Template already assigned!", MessageBoxButtons.YesNo, MessageBoxIcon.Error)

            ' if user selected not to overwrite, then abort
            If diagResult = Windows.Forms.DialogResult.No Then
                Return
            End If
        End If

        Try
            ' attempt to read the template
            Dim templateOpened As New DPFP.Template(File.OpenRead(textBoxTemplateFilename.Text))

            ' run a template duplicate check
            IdentifyTemplate(templateOpened)

            ' remove the old template if exists
            If _ActiveUser.TemplateExists(_AssignedFinger) Then
                ' removed from assigned finger
                _ActiveUser.RemoveTemplate(_AssignedFinger)
            End If

            ' and assign it to the user as specified
            _ActiveUser.AddTemplate(templateOpened, _AssignedFinger)

            ' update collection
            If Not _Users.UserExists(_ActiveUser.ID) Then
                ' update list box
                listBoxUsers.Items.Add(_ActiveUser.ID.ToString())

                ' add user it to the user collection
                _Users.AddUser(_ActiveUser)
            End If

            ' success
            UpdateEventLog([String].Format("{0}: Template successfully assigned to {1} finger.", _ActiveUser.ID.ToString(), _AssignedFinger.ToString()))

            ' turn off groupbox
            groupAddTemplate.Visible = False

            listBoxUsers.SelectedItem = _ActiveUser.ID.ToString()

            ' sync gui
            _syncUI()

            ' view user
            _syncViewUser()

        Catch Err As DPFP.Error.SDKException
            ' log message
            UpdateEventLog(Err.ToString())
            System.Diagnostics.Trace.WriteLine(Err.ToString())
        Catch Err As System.IO.FileNotFoundException
            ' log message
            UpdateEventLog("Template file not found or is inaccessible.")
            System.Diagnostics.Trace.WriteLine(Err.ToString())
        Catch Err As Exception
            ' log message
            UpdateEventLog(Err.ToString())
            System.Diagnostics.Trace.WriteLine(Err.ToString())
        End Try

        Using conn As New MySqlConnection("Server = localhost; Username= root; Password =; Database = vb")
            Using cmd
                With cmd
                    MsgBox("Connection Established")
                    .Connection = conn
                    .Parameters.Clear()
                    'Create Insert Query
                    .CommandText = "INSERT INTO employees(UserID, Name, Finger) VALUES (@iID, @iName, @iFinger)"
                    .Parameters.Add(New MySqlParameter("@iID", ID.Text))
                    .Parameters.Add(New MySqlParameter("@iName", textBoxUserName.Text))
                    .Parameters.Add(New MySqlParameter("@iFinger", comboBoxAssignedFinger.Text))


                End With
                Try
                    'Open Connection and Execute Query
                    conn.Open()
                    cmd.ExecuteNonQuery()
                Catch ex As MySqlException
                    MsgBox(ex.Message.ToString())
                End Try
            End Using
        End Using

Dani AI

Generated

You do not need phpMyAdmin for this piece; treat the fingerprint template as opaque binary from the SDK and store it in a BLOB column. As said, avoid text types so you do not corrupt the bytes. And to ’s point: do not compress or re-encode the data. Save exactly what the SDK gives you. The file extension (.ftp or otherwise) does not matter once you have the template object.

Minimal VB.NET pattern:

' templateOpened is a DPFP.Template you just enrolled/loaded
Dim tplBytes() As Byte
Using ms As New IO.MemoryStream()
    templateOpened.Serialize(ms)     ' serialize template to bytes
    tplBytes = ms.ToArray()
End Using

Using conn As New MySql.Data.MySqlClient.MySqlConnection(cs)
Using cmd As New MySql.Data.MySqlClient.MySqlCommand(
    "INSERT INTO employees(UserID, Name, Finger, Template) VALUES (@id,@name,@finger,@tpl)", conn)
    cmd.Parameters.Add("@id", MySqlDbType.VarChar).Value = ID.Text
    cmd.Parameters.Add("@name", MySqlDbType.VarChar).Value = textBoxUserName.Text
    cmd.Parameters.Add("@finger", MySqlDbType.VarChar).Value = comboBoxAssignedFinger.Text
    cmd.Parameters.Add("@tpl", MySqlDbType.Blob).Value = tplBytes   ' BLOB/MEDIUMBLOB works
    conn.Open()
    cmd.ExecuteNonQuery()
End Using
End Using

To retrieve and verify:

Dim tpl As New DPFP.Template()
Using conn As New MySqlConnection(cs), _
      cmd As New MySqlCommand("SELECT Template FROM employees WHERE UserID=@id AND Finger=@finger", conn)
    cmd.Parameters.Add("@id", MySqlDbType.VarChar).Value = ID.Text
    cmd.Parameters.Add("@finger", MySqlDbType.VarChar).Value = comboBoxAssignedFinger.Text
    conn.Open()
    Using r = cmd.ExecuteReader()
        If r.Read() Then
            Using ms As New IO.MemoryStream(DirectCast(r("Template"), Byte()))
                tpl.DeSerialize(ms)  ' rebuild template
            End Using
        End If
    End Using
End Using
' Then use DPFP.Verification.Verification to compare features with tpl

Tips:

  • Store one row per finger (or a separate table) and index by UserID+Finger.
  • Never base64 or UTF-8 encode the template; keep it as raw bytes.
  • BLOB is usually enough; MEDIUMBLOB if you plan to store multiple templates or versions.

Recommended Answers

All 2 Replies

Per a quick read at DigitalPersona.com, ftp is a legacy Fingerprint Template format, their newer formats are fid and fmd - with fmd being the enrollment data.

That same quick read did not tell me definitively what format their data is in, although they hint at it being an image that must not be compressed.

The should provide more information and hopefully answer your question.

I don't use MySql, but based this article: it seems that storing and retrieving binary data follows the same methods as used for for DBs that I'm familar with.

I don't know if the use of phpmyadmin would throw in any obstacles for you, but it should be worth a try.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.