我正在使用digitalpersona u.are.u 4500
指纹识别器。
这是我用来将指纹模板保存到数据库的代码:
Dim str As New MemoryStream
Enroller.Template.Serialize(str)
Dim serializedTemplate As Byte() = str.ToArray()
Dim bytes() as Byte = serializedTemplate
comm.Parameters.AddWithValue("@Emp_FPrint", bytes)
问题是当我尝试从数据库中检索指纹并Deserialize
时,我有这个错误:
从类型' Byte()'转换键入' Byte'无效。
这是我用来检索的代码和Deserialize
指纹:
Sub OnComplete(ByVal Capture As Object, ByVal ReaderSerialNumber As String, ByVal Sample As DPFP.Sample) Implements DPFP.Capture.EventHandler.OnComplete
MakeReport("The fingerprint sample was captured.")
SetPrompt("Scan the same fingerprint again.")
Process(Sample)
CheckTemplate()
If ds1MaxRow > 0 Then
For i = 0 To ds1MaxRow - 1
' byteArray = CType(ds1VerifyFPrintp.Tables("TestImage").Rows(i).Item(1), Byte())
con1 = New SqlConnection
con1.ConnectionString = "Data Source=ERSERVER;Initial Catalog=Timekeeping;User ID=sa;Password=sa"
Dim thequery As String = "Select Emp_FPrint from TestImage "
con1.Open()
Dim cmd As SqlCommand = New SqlCommand(thequery, con1)
Dim rsBioData As SqlDataReader = cmd.ExecuteReader
Dim byteTemplate As Byte
Dim memStreamTemplate As MemoryStream
If rsBioData.HasRows Then
While rsBioData.Read
byteTemplate = rsBioData("Emp_FPrint") ''''''''ERROR HERE : Conversion from type 'Byte()' to type 'Byte' is not valid. '''''''
memStreamTemplate = New MemoryStream(byteTemplate)
Me.Template.DeSerialize(memStreamTemplate)
End While
End If
'''''''STUCK UNTO THIS LINE''''''''''
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()
Verificator.Verify(features, Template, result)
' UpdateStatus(result.FARAchieved)
If result.Verified Then
MakeReport("The fingerprint was VERIFIED.")
Else
MakeReport("The fingerprint was NOT VERIFIED.")
End If
End If
Next i
End If
End Sub
答案 0 :(得分:0)
试试这个
Dim cmd As New MySqlCommand(" SELECT * FROM employeefp",conn) Dim rdr As MySqlDataReader = cmd.ExecuteReader()
While (rdr.Read())
Dim MemStream As IO.MemoryStream
Dim fpBytes As Byte()
fpBytes = rdr("FP")
MemStream = New IO.MemoryStream(fpBytes)
Dim templa8 As DPFP.Template = New DPFP.Template()
templa8.DeSerialize(MemStream)
Dim tmpObj As New AppData
tmpObj.No = rdr("No").ToString()
tmpObj.Template = templa8
FPList.Add(tmpObj)
End While