我正在使用Digital Persona U.are.U 4000b指纹读取器,并且此功能可以验证来自SQL Server的指纹
我的问题是循环,因为比较模板需要很多时间。
请给我一些有关如何优化或修改代码的建议。
代码
Protected Sub Process(ByVal Sample As DPFP.Sample)
con = New SqlConnection
con.ConnectionString = "Data Source=Test;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