Visual Basic.NET - lector de huella

   
Vista:

lector de huella

Publicado por samuel (2 intervenciones) el 08/04/2011 00:25:21
nesecito pasar la imagen al templeate para poder hacer la verificacion no se quien me pueda ayudar


Imports System.Collections.Generic
Imports System.Data.SqlClient
Imports DPFP
Imports DPFP.Capture
Imports DPFP.Error
Imports DPFP.Processing
Imports DPFP.Verification
Imports System.IO
Imports DPFP.Verification.Verification
Public Class Verificar
Implements DPFP.Capture.EventHandler
Public Event OnTemplate(ByVal template)
Private Enroller As DPFP.Processing.Enrollment
Private Capturer As DPFP.Capture.Capture
Public Imagen As Byte()
Private Template As DPFP.Template
Private Verificator As DPFP.Verification.Verification
Private Const cs As String = "Data Source=cagdlss13\sql2k5;" & _
"Initial Catalog=RelojChecador;" & _
"Integrated Security=true"
Protected Overridable Sub Init()
Try
Capturer = New DPFP.Capture.Capture() ' Crear una operación de captura.

If (Not Capturer Is Nothing) Then
Capturer.EventHandler = Me ' Suscribe para capturar Evento .
Else
MessageBox.Show("No se puede iniciar la operación de captura!")
End If
Catch ex As Exception
MessageBox.Show("No se puede iniciar la operación de captura!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
Protected Overridable Sub Process(ByVal Sample As DPFP.Sample)
DrawPicture(ConvertSampleToBitmap(Sample))
End Sub
Protected Function ConvertSampleToBitmap(ByVal Sample As DPFP.Sample) As Bitmap
Dim convertor As New DPFP.Capture.SampleConversion() ' crea un convertidor de la muestra .
Dim bitmap As Bitmap = Nothing ' TODO: el tamaño no importa
convertor.ConvertToPicture(Sample, bitmap) ' TODO: cambio de mapa de bits como resultado
Return bitmap
End Function
Protected Function ExtractFeatures(ByVal Sample As DPFP.Sample, ByVal Purpose As DPFP.Processing.DataPurpose) As DPFP.FeatureSet
Dim extractor As New DPFP.Processing.FeatureExtraction() ' crea un extracto de caracterisca
Dim feedback As DPFP.Capture.CaptureFeedback = DPFP.Capture.CaptureFeedback.None
Dim features As New DPFP.FeatureSet()
extractor.CreateFeatureSet(Sample, Purpose, feedback, features) ' TODO: características de rendimiento como resultado?
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
MessageBox.Show("No se puede iniciar la captura!")
End Try
End If
End Sub
Protected Sub StopCapture()
If (Not Capturer Is Nothing) Then
Try
Capturer.StopCapture()
Catch ex As Exception
MessageBox.Show("No se puede terminar de captura!")
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
MessageBox.Show("La muestra de la huella digital fue capturado.")
MessageBox.Show("Busque en la misma huella digital nuevo.")
Procesis(Sample)
End Sub

Sub OnFingerGone(ByVal Capture As Object, ByVal ReaderSerialNumber As String) Implements DPFP.Capture.EventHandler.OnFingerGone
MessageBox.Show("El dedo se retira del lector de huella digita.")
End Sub

Sub OnFingerTouch(ByVal Capture As Object, ByVal ReaderSerialNumber As String) Implements DPFP.Capture.EventHandler.OnFingerTouch
MessageBox.Show("El lector de huellas digitales se conmovió.")
End Sub

Sub OnReaderConnect(ByVal Capture As Object, ByVal ReaderSerialNumber As String) Implements DPFP.Capture.EventHandler.OnReaderConnect
MessageBox.Show("El lector de huellas digitales fue vinculado.")
End Sub

Sub OnReaderDisconnect(ByVal Capture As Object, ByVal ReaderSerialNumber As String) Implements DPFP.Capture.EventHandler.OnReaderDisconnect
MessageBox.Show("El lector de huellas digitales se ha desconectado.")
End Sub

Sub OnSampleQuality(ByVal Capture As Object, ByVal ReaderSerialNumber As String, ByVal CaptureFeedback As DPFP.Capture.CaptureFeedback) Implements DPFP.Capture.EventHandler.OnSampleQuality
If CaptureFeedback = DPFP.Capture.CaptureFeedback.Good Then
MessageBox.Show("La calidad de la muestra de la huella digital es buena.")
Else
MessageBox.Show("La calidad de la muestra de huellas digitales es pobre.")
End If
End Sub

Protected Sub SetStatus(ByVal status)
Invoke(New FunctionCall(AddressOf SetStatus), status)
End Sub

Protected Sub SetPrompt(ByVal text)
Invoke(New FunctionCall(AddressOf SetPrompt), text)
End Sub

Protected Sub MakeReport(ByVal status)
Invoke(New FunctionCall(AddressOf MakeReport), status)
End Sub

Protected Sub DrawPicture(ByVal bmp)
Invoke(New FunctionCall(AddressOf _DrawPicture), bmp)
End Sub
Private Sub _DrawPicture(ByVal bmp)
pbFotoEmpleado.Image = New Bitmap(bmp, pbFotoEmpleado.Size)
End Sub
Protected Sub Procesis(ByVal Sample As DPFP.Sample)
Process(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
' 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
MessageBox.Show("La huella digital se verificó.")
Else
MessageBox.Show("La pálida huella digital NO VERIFICADO.")
End If
End If
End Sub
Protected Sub UpdateStatus(ByVal FAR As Integer)
' Show "False accept rate" value
SetStatus(String.Format("Tasa de falsa aceptación (FAR) = {0}", FAR))
End Sub
Protected Sub UpdateStatus()
' Show number of samples needed.
SetStatus(String.Format("Muestras de huellas dactilares necesarios: {0}", Enroller.FeaturesNeeded))
End Sub
Public Sub Verify(ByVal Imagen As DPFP.Template)
Template = Imagen
End Sub
Public Function Cargarimagen(ByVal foto As DPFP.FeatureSet)
Dim conexion As New SqlConnection(cs)
Dim cmd As New SqlCommand("SELECT * from Huellas ", conexion)
Dim adapter As New SqlDataAdapter(cmd)
Dim datostabla As New DataTable
adapter.Fill(datostabla)
If datostabla.Rows.Count = 0 Then
MessageBox.Show("No estas registrado")
Else
Imagen = CType(datostabla.Rows(0)("Huella"), Byte())
Dim memorybits As New MemoryStream(Imagen)
End If
Return AcceptButton
End Function

Private Sub Verificar_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Init()
StartCapture()
Dim Verifier As New Verificar()
Verifier.Verify(Template)
End Sub
End Class
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder