0

我使用适用于 .NET 的 DigitalPersona SDK OneTouch 在 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
4

2 回答 2

1

对我来说,这是解决方案:

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
于 2017-06-09T18:59:42.553 回答
1

你完成了困难的部分,只错过了这个

Verificator = New DPFP.Verification.Verification()
Capturer.Priority = DPFPDevXLib.DPFPCapturePriorityEnum.CapturePriorityHigh
StartCapture()

此外,应用程序必须在 Admin 下运行才能使高优先级工作。** 高优先级意味着您的应用接收所有事件,无论其是否最小化。

于 2015-09-23T06:15:50.347 回答