我使用DigitalPersona SDK OneTouch for .NET在visual basic中创建了一个应用程序,用于比较指纹识别器中扫描的指纹" U.are.U 4500"将指纹存储在文件夹中。只要它是活动窗口(在所有打开的应用程序中),应用程序就可以正常工作,而且即使它被最小化或不是活动应用程序,我也需要它始终听取读者的意见。我尝试过使用后台工作程序,设置表单属性TopMost True,制作服务,甚至在调用事件deactivate时将表单设置为活动状态,但这些替代方案都没有起作用。我将不胜感激任何帮助,并提前感谢您的建议。
这是我的vb.net应用程序的代码。
Public Class CaptureForm
Implements DPFP.Capture.EventHandler
Private Template As DPFP.Template
Private Verificator As DPFP.Verification.Verification
Private Capturer As DPFP.Capture.Capture
Private Sub CaptureForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If BackgroundWorker1.IsBusy <> True Then
BackgroundWorker1.RunWorkerAsync()
End If
End Sub
Private Sub CaptureForm_FormClosed(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles MyBase.FormClosed
StopCapture()
End Sub
'Private Sub CaptureForm_Deactivate(ByVal sender As System.Object, ByVal e As EventArgs) Handles MyBase.Deactivate
' Me.Activate()
'End Sub
'Private Sub CaptureForm_Activate(ByVal sender As System.Object, ByVal e As EventArgs) Handles MyBase.Activated
'End Sub
Sub Init()
Try
Capturer = New DPFP.Capture.Capture()
If (Not Capturer Is Nothing) Then
Capturer.EventHandler = Me
End If
Catch ex As Exception
MessageBox.Show("No se pudo iniciar la operación de captura!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
Verificator = New DPFP.Verification.Verification()
StartCapture()
End Sub
Protected Overridable Sub Process(ByVal Sample As DPFP.Sample)
' Process the sample and create a feature set for the enrollment purpose.
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
Dim result As DPFP.Verification.Verification.Result = New DPFP.Verification.Verification.Result()
Dim foundFile As String
Dim fileReader As String
fileReader = My.Computer.FileSystem.ReadAllText("templates.txt")
Dim flag As Boolean
flag = False
For Each foundFile In My.Computer.FileSystem.GetFiles(fileReader, FileIO.SearchOption.SearchTopLevelOnly, "*.fpt")
Using fs As IO.FileStream = IO.File.OpenRead(foundFile)
Dim template1 As New DPFP.Template(fs)
Me.Template = template1
End Using
Verificator.Verify(features, Template, result)
If result.Verified Then
flag = True
Dim file As System.IO.StreamWriter
Dim file2 As String
Dim nombre As String = My.Computer.FileSystem.GetName(foundFile)
file2 = nombre.Remove(nombre.Length - 4, 4)
'MsgBox(file2)
file = My.Computer.FileSystem.OpenTextFileWriter("ingreso.txt", False)
file.WriteLine(file2)
file.Close()
Exit For
End If
Next
If flag = False Then
End If
End If
End Sub
Protected Function ExtractFeatures(ByVal Sample As DPFP.Sample, ByVal Purpose As DPFP.Processing.DataPurpose) As DPFP.FeatureSet
Dim extractor As New DPFP.Processing.FeatureExtraction() ' Create a feature extractor
Dim feedback As DPFP.Capture.CaptureFeedback = DPFP.Capture.CaptureFeedback.None
Dim features As New DPFP.FeatureSet()
extractor.CreateFeatureSet(Sample, Purpose, feedback, features) ' TODO: return features as a result?
If (feedback = DPFP.Capture.CaptureFeedback.Good) Then
Return features
Else
Return Nothing
End If
End Function
Protected Sub StartCapture()
If (Not Capturer Is Nothing) Then
Try
Capturer.StartCapture()
Catch ex As Exception
End Try
End If
End Sub
Protected Sub StopCapture()
If (Not Capturer Is Nothing) Then
Try
Capturer.StopCapture()
Catch ex As Exception
End Try
End If
End Sub
Sub OnComplete(ByVal Capture As Object, ByVal ReaderSerialNumber As String, ByVal Sample As DPFP.Sample) Implements DPFP.Capture.EventHandler.OnComplete
Process(Sample)
End Sub
Sub OnFingerGone(ByVal Capture As Object, ByVal ReaderSerialNumber As String) Implements DPFP.Capture.EventHandler.OnFingerGone
End Sub
Sub OnFingerTouch(ByVal Capture As Object, ByVal ReaderSerialNumber As String) Implements DPFP.Capture.EventHandler.OnFingerTouch
End Sub
Sub OnReaderConnect(ByVal Capture As Object, ByVal ReaderSerialNumber As String) Implements DPFP.Capture.EventHandler.OnReaderConnect
End Sub
Sub OnReaderDisconnect(ByVal Capture As Object, ByVal ReaderSerialNumber As String) Implements DPFP.Capture.EventHandler.OnReaderDisconnect
End Sub
Sub OnSampleQuality(ByVal Capture As Object, ByVal ReaderSerialNumber As String, ByVal CaptureFeedback As DPFP.Capture.CaptureFeedback) Implements DPFP.Capture.EventHandler.OnSampleQuality
End Sub
Private Sub BackgroundWorker1_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
Init()
End Sub
End Class
答案 0 :(得分:0)
你完成了困难的部分,只是错过了这个
Verificator = New DPFP.Verification.Verification()
Capturer.Priority = DPFPDevXLib.DPFPCapturePriorityEnum.CapturePriorityHigh
StartCapture()
此外,应用程序必须在Admin下运行才能使用高优先级。 **高优先级意味着您的应用程序会收到所有事件,如果最小化则会被视为。
答案 1 :(得分:0)
对我而言,这是解决方案:
Public snwr As String
snwr = readers(0).SerialNumber
Protected Overridable Sub Init()
Try<br>
**Capturer = New DPFP.Capture.Capture(snwr,DPFP.Capture.Priority.High)
If (Not Capturer Is Nothing) Then
Capturer.EventHandler = Me
End If<br>
Catch ex As Exception<br>
MessageBox.Show("Can't initiate capture operation!", "Error",
MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub