0

DigitalPersona SDK OneTouch for .NET を使用して、指紋リーダー「U.are.U 4500」で読み取った指紋とフォルダーに保存されている指紋を比較するアプリケーションを Visual Basic で作成しました。アプリは、アクティブなウィンドウ (開いているすべてのアプリの中で) である限り正常に動作し、最小化されている場合やアクティブなアプリではない場合でも、リーダーを常にリッスンする必要があります。バックグラウンド ワーカーを使用して、フォーム プロパティ TopMost True を設定し、サービスを作成し、イベントの非アクティブ化が呼び出されたときにフォームをアクティブに設定しようとしましたが、この代替手段はどれも機能しませんでした。ご意見をお寄せいただきありがとうございます。

これが私の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()

また、高優先度が機能するには、アプリケーションが管理者の下で実行されている必要があります。** 優先度が高いとは、アプリケーションが最小化されているかどうかに関係なく、すべてのイベントを受け取ることを意味します。

于 2015-09-23T06:15:50.347 に答える