locked
problem with digital person and background execution BackgroundWorker1 RRS feed

  • General discussion

  • Good afternoon, I have tried to work with digital people from vb.net, I already did the whole form and the validation, but the problem is that I could not make it work in the background, could you help me with the issue? I share my code

    I have used

    BackgroundWorker1 

    along with this other code

    Capturer.Priority = DPFPDevXLib.DPFPCapturePriorityEnum.CapturePriorityHigh

    but I don't know where to use it I couldn't insert it

    Imports System.IO
    Imports DPFP
    Imports DPFP.Capture
    Imports DPFP.Capture.Priority
    Imports MySql.Data.MySqlClient
    
    Public Class Busqueda
        Implements DPFP.Capture.EventHandler
        Private template As DPFP.Template
        Private Captura As DPFP.Capture.Capture
        Private verificador As DPFP.Verification.Verification
    
        Protected Overridable Sub Init()
            Try
                Captura = New Capture()
                If Not Captura Is Nothing Then
                    Captura.EventHandler = Me
                    verificador = New Verification.Verification()
    'acá es donde he probado el codigo'
                    template = New Template()
    
                Else
                    MsgBox("No se pudo obtener la captura", MsgBoxStyle.Information, "Solobus - Huellas")
                End If
            Catch ex As Exception
                MsgBox("No se pudo inicializar la captura 1", MsgBoxStyle.Information, "Solobus - Huellas")
            End Try
        End Sub
        Protected Sub iniciarCaptura()
            If Not Captura Is Nothing Then
                Try
                    Captura.StartCapture()
                Catch ex As Exception
                    MsgBox("No se pudo iniciar la captura 2", MsgBoxStyle.Information, "Solobus - Huellas")
                End Try
            End If
        End Sub
        Protected Sub pararCaptura()
            If Not Captura Is Nothing Then
                Try
                    Captura.StopCapture()
                Catch ex As Exception
                    MsgBox("no se pudo detener la captura", MsgBoxStyle.Information, "Solobus - Huellas")
                End Try
            End If
        End Sub
        Private Sub ponerImagen(ByVal bmp)
            imagenHuella.Image = bmp
        End Sub
        Protected Function convertirSampleaMapadeBits(ByVal Sample As DPFP.Sample) As Bitmap
            Dim convertidor As New DPFP.Capture.SampleConversion() 
            Dim mapaBits As Bitmap = Nothing
            convertidor.ConvertToPicture(Sample, mapaBits)
            Return mapaBits
        End Function
        Protected Function extraerCaracteristicas(ByVal Sample As DPFP.Sample, ByVal Purpose As DPFP.Processing.DataPurpose) As DPFP.FeatureSet
    
            Dim extrator As New DPFP.Processing.FeatureExtraction()
            Dim alimentacion As DPFP.Capture.CaptureFeedback = DPFP.Capture.CaptureFeedback.None
            Dim caracteristicas As New DPFP.FeatureSet()
            extrator.CreateFeatureSet(Sample, Purpose, alimentacion, caracteristicas)
    
            If (alimentacion = DPFP.Capture.CaptureFeedback.Good) Then
                Return caracteristicas
            Else
                Return Nothing
            End If
    
        End Function
        Public Sub OnComplete(Capture As Object, ReaderSerialNumber As String, Sample As Sample) Implements EventHandler.OnComplete
            ponerImagen(convertirSampleaMapadeBits(Sample))
            Dim caracteristicas As DPFP.FeatureSet = extraerCaracteristicas(Sample, DPFP.Processing.DataPurpose.Verification)
            If Not caracteristicas Is Nothing Then
                Dim result As New DPFP.Verification.Verification.Result()
                Dim builderconex As New MySqlConnectionStringBuilder()
                builderconex.Server = "localhost"
                builderconex.UserID = "root"
                builderconex.Password = ""
                builderconex.Database = "sgm"
    
                Dim conexion As New MySqlConnection(builderconex.ToString())
                conexion.Open()
                Dim cmd As New MySqlCommand()
                cmd = conexion.CreateCommand
                cmd.CommandText = "SELECT * FROM huella_digital"
                Dim read As MySqlDataReader
                read = cmd.ExecuteReader()
                Dim verificado As Boolean = False
                Dim cedula As String = ""
                While (read.Read())
                    Dim memoria As New MemoryStream(CType(read("huella"), Byte()))
                    template.DeSerialize(memoria.ToArray())
                    verificador.Verify(caracteristicas, template, result)
                    If (result.Verified) Then
                        cedula = read("cedula")
                        verificado = True
                        Exit While
                    End If
                End While
    
                If (verificado) Then
                    MsgBox(cedula, MsgBoxStyle.Information, "Solobus - Huellas")
                Else
                    MsgBox("No se encuentra ningun registro", MsgBoxStyle.Information, "Solobus - Huellas")
                End If
    
                read.Dispose()
                cmd.Dispose()
                conexion.Close()
                conexion.Dispose()
    
    
            End If
        End Sub
    
        Public Sub OnFingerGone(Capture As Object, ReaderSerialNumber As String) Implements EventHandler.OnFingerGone
    
        End Sub
    
        Public Sub OnFingerTouch(Capture As Object, ReaderSerialNumber As String) Implements EventHandler.OnFingerTouch
    
        End Sub
    
        Public Sub OnReaderConnect(Capture As Object, ReaderSerialNumber As String) Implements EventHandler.OnReaderConnect
    
        End Sub
    
        Public Sub OnReaderDisconnect(Capture As Object, ReaderSerialNumber As String) Implements EventHandler.OnReaderDisconnect
    
        End Sub
    
        Public Sub OnSampleQuality(Capture As Object, ReaderSerialNumber As String, CaptureFeedback As CaptureFeedback) Implements EventHandler.OnSampleQuality
    
        End Sub
    
        Private Sub Busqueda_Load(sender As Object, e As EventArgs) Handles MyBase.Load
            If BackgroundWorker1.IsBusy <> True Then
                BackgroundWorker1.RunWorkerAsync()
            End If
    
            Init()
            iniciarCaptura()
        End Sub
    
        Private Sub Busqueda_FormClosing(sender As Object, e As FormClosingEventArgs) Handles MyBase.FormClosing
            pararCaptura()
        End Sub
    
        Private Sub BackgroundWorker1_DoWork(sender As Object, e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
            Init()
        End Sub
    End Class

    Thanks in advance



    
    
    <g-img class="GB1dfd" style="display:inline-block;vertical-align:middle;"></g-img>
    Sunday, September 8, 2019 9:45 PM

All replies

  • In the Init method, right after the "If Not Captura Is Nothing Then" check, you can add:

    Captura.Priority = DPFPDevXLib.DPFPCapturePriorityEnum.CapturePriorityHigh

    Monday, September 9, 2019 1:17 AM
    Answerer
  • Hello cheong00, how are you? I hope it's ok, 

    when adding the code it tells me that the reference "DPFPDevNET" is not declared, proceed to change the Asian line

    Change for this

    Captura.Priority = DPFP.Capture.Priority.High

    But it tells me that the Priority property is readonly


    I am somewhat lost, since I had not developed on vb.net before, what do you recommend me to do? for this to work in the background,

    thank you

    • Edited by Salinasmc Monday, September 9, 2019 2:55 PM
    Monday, September 9, 2019 2:54 PM
  • Since you're having problem with a 3rd party component, it's better to ask the question in their forum. (The package itself should have support information)

    Btw, from information I gathered, I think you should be able to pass it as the second parameter of the constructor, while the first one seems to be the serial number of the reader.

    Monday, September 9, 2019 3:35 PM
    Answerer
  • Dado que tiene problemas con un componente de terceros, es mejor hacer la pregunta en su foro. (El paquete en sí debe tener información de soporte)

    Por cierto, de la información que reúne, creo que deberías poder pasarlo como el segundo parámetro del constructor, mientras que lo primero parece ser el número de serie del lector.

    thank you very much, happy afternoon

    Monday, September 9, 2019 6:21 PM
  • Did you find the answer to this post? i have the same problem, i can't do make my app work if lose focus.
    Tuesday, October 29, 2019 6:03 AM