Click here to Skip to main content
15,902,299 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
I'm using Digital Persona U.are.U 4000b fingerprint reader and I have this function that verifies the fingerprint from SQL server

My problem is the loop because it takes a lot of time to compare the templates.

Please give me some advice on how can I optimize or revise my code.


What I have tried:

Protected Sub Process(ByVal Sample As DPFP.Sample)
    con = New SqlConnection

    con.ConnectionString = "Data Source=paulv;Initial Catalog=TestDB;Persist Security Info=True;User ID=sa;Password=Passw0rd"

    Dim command As String = "SELECT * FROM Bio_Emplist"

    Dim da As New SqlDataAdapter(command, con)
    Dim dtb As New DataTable
    da.Fill(dtb)
    If dtb.Rows.Count > 0 Then
        rowCount = dtb.Rows.Count
        Try
            For Each dr As DataRow In dtb.Rows
                Dim fpt As Byte() = CType(dr("Fpt"), Byte())

                Dim ms As New MemoryStream(fpt)
                Dim tmpObj As DPFP.Template = New DPFP.Template
                Dim verify As DPFP.Verification.Verification = New DPFP.Verification.Verification

                Template = tmpObj
                tmpObj.DeSerialize(fpt)

                DrawPicture(ConvertSampleToBitmap(Sample))

                Dim features As DPFP.FeatureSet = ExtractFeatures(Sample, DPFP.Processing.DataPurpose.Verification)
                ' Check quality of the sample and start verification if it's good
                If Not features Is Nothing Then
                    ' Compare the feature set with our template
                    Dim result As DPFP.Verification.Verification.Result = New DPFP.Verification.Verification.Result()
                    verify.Verify(features, Template, result)
                    'UpdateStatus(result.FARAchieved)

                    If result.Verified Then
                        MakeReport("The fingerprint was VERIFIED.")

                        empID = dr("EmpID")
                        empFName = dr("FName")
                        empLName = dr("LName")
                        SetVerifyText(empID, empFName, empLName)
                        Exit Try
                    Else
                        FailedVerifyText()
                        If rowCount = 1 Then
                            MakeReport("The fingerprint was NOT VERIFIED.")
                        Else
                            rowCount = rowCount - 1
                            MakeReport("Finding Match...")
                        End If
                    End If
                End If
            Next
        Catch ex As Exception
            MsgBox(ex.ToString)
        End Try
    End If
End Sub
Posted
Updated 7-Aug-18 22:52pm
Comments
M4rLask 26-Jul-18 17:06pm    
You are comparing all the records in your table with the fingerprint, you also create a new instance of MemoryStream,DPFP.Template and DPFP.Verification.Verification each time a new record is compared,suggest you use a list of fingerprints and another with the data of the users, once a fingerprint matches get the user's data with linq from the list of users

1 solution

Create a Function for getting the Fmds.

Private fingerList As New List(Of Fmd)


Check This :
https://www.codeproject.com/Questions/1250431/How-can-I-save-and-retrieve-a-fingerprint-template
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900