Проверка отпечатков пальцев цифровой персоны занимает много времени
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.
Что я уже пробовал:
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
M4rLask
Вы сравниваете все записи в своей таблице с отпечатком пальца, а также создаете новый экземпляр MemoryStream,DPFP.Шаблон и DPFP.Verification.Проверка каждый раз,когда сравнивается новая запись, предложите вам использовать список отпечатков пальцев и еще один с данными пользователей, как только отпечаток пальца совпадет, получите данные пользователя с linq из списка пользователей