如何从数据库反序列化指纹的序列化模板? [英] How to deserialize a serialize template of fingerprint from the database?

查看:91
本文介绍了如何从数据库反序列化指纹的序列化模板?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用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)





问题是当我尝试从数据库中检索指纹并对其进行反序列化时,我有这样的错误:



从类型Byte()转换为类型字节无效。



我尝试过:



Sub OnComplete(ByVal Capture As Object,ByVal ReaderSerialNumber As String,ByVal Sample as DPFP.Sample)实现DPFP.Capture.EventHandler.OnComplete

MakeReport(捕获指纹样本。)

SetPrompt(扫描同一个fing再次打印。)

流程(样本)



CheckTemplate()

如果ds1MaxRow> 0然后

For i = 0 to ds1MaxRow - 1

'byteArray = CType(ds1VerifyFPrintp.Tables(TestImage)。Rows(i).Item(1),字节())

con1 =新的SqlConnection

con1.ConnectionString =数据源= ERSERVER;初始目录=计时;用户ID = sa;密码= sa

将thequery变暗为String =从TestImage中选择Emp_FPrint

con1.Open()

Dim cmd As SqlCommand = New SqlCommand(thequery,con1)

Dim rsBioData As SqlDataReader = cmd.ExecuteReader



Dim byteTemplate As Byte

Dim memStreamTemplate As MemoryStream

如果rsBioData.HasRows那么

虽然rsBioData.Read

byteTemplate = rsBioData(Emp_FPrint)'''''''错误在这里:从典型转换e'Byte()'键入'Byte'无效。 '''''''

memStreamTemplate =新的MemoryStrea(byteTemplate)

Me.Template.DeSerialize(memStreamTemplate)

结束时

结束如果'''''''''''''''''''''$ $ $ $ $ $ $ $ $ $ $ $ $ $ $
FeatureSet = ExtractFeatures(Sample,DPFP.Processing.DataPurpose.Verification)



'检查样品质量并开始验证是否合适

如果Not features is Nothing Then

'将功能集与我们的模板进行比较

Dim results As DPFP.Verification.Verification.Result = New DPFP.Verification.Verification.Result( )

Verificator.Verify(功能,模板,结果)

'UpdateStatus(result.FARAchieved)

如果result.Verified那么

MakeReport(指纹已经过验证。)

否则

MakeReport(指纹未经验证。)

结束如果

结束如果



下一页我

结束如果

End Sub

Im using digitalpersona u.are.u 4500 fingerprint reader.

This is the codes I used to save fingerprint template to database:
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)


The problem is when I try to retrieve fingerprint from the database and Deserialize it , I have this error:

"Conversion from type Byte() to type Byte is not valid."

What I have tried:

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 MemoryStrea(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

推荐答案

Dim byteTemplate As Byte



错误消息很清楚。您不能将字节数组反序列化为单个字节。


The error message is quite clear. You cannot deserialize an array of Bytes into a single Byte.


这篇关于如何从数据库反序列化指纹的序列化模板?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆