0

I am developing a vb.net 2008 application that should verify one's fingerprint from the scanner and the one from the database.

When I input an ID it's returning the fingerprint of that person from the database. Then how do I compare the two fingerprints images, one from the scanner and the one in the picturebox?

I am using this code but it's not giving me results.

Sub compare_6()
    Me.Cursor = Cursors.WaitCursor
    Application.DoEvents()

    ' Get the threshold.
    Dim threshold As Integer = Integer.Parse(txtThreshold.Text)

    ' Load the images.

    Dim bm1 As Bitmap = PictureBox1.Image
    Dim bm2 As Bitmap = PictureBox2.Image

    ' Make a difference image.
    Dim wid As Integer = Math.Min(bm1.Width, bm2.Width)
    Dim hgt As Integer = Math.Min(bm1.Height, bm2.Height)
    Dim bm3 As New Bitmap(wid, hgt)

    ' Create the difference image.
    Dim are_identical As Boolean = True
    '  Dim r1, g1, b1, r2, g2, b2, r3, g3, b3 As Integer
    Dim color1, color2 As Color
    Dim eq_color As Color = Color.White
    Dim ne_color As Color = Color.Red
    Dim dr, dg, db, diff As Integer
    For x As Integer = 0 To wid - 1
        For y As Integer = 0 To hgt - 1
            color1 = bm1.GetPixel(x, y)
            color2 = bm2.GetPixel(x, y)
            dr = CInt(color1.R) - color2.R
            dg = CInt(color1.G) - color2.G
            db = CInt(color1.B) - color2.B
            '
            diff = dr * dr + dg * dg + db * db
            If diff <= threshold Then
                bm3.SetPixel(x, y, eq_color)
            Else
                bm3.SetPixel(x, y, ne_color)
                are_identical = False
            End If
        Next y
    Next x

    ' Display the result.
    picResult.Image = bm3

    Me.Cursor = Cursors.Default
    If (bm1.Width <> bm2.Width) OrElse (bm1.Height <> bm2.Height) Then are_identical = False
    If are_identical Then
        MessageBox.Show("The images are identical")
        Exit Sub
    Else
        MessageBox.Show("The images are different")
        Exit Sub
    End If

    bm1.Dispose()
    bm2.Dispose()
End Sub      ` 

I will be grateful if any one helps me with this. Thanks for your attention.

4

1 回答 1

2

你永远不会得到相同的图像。您无法获得 2 次精确扫描。指纹验证有 2 种类型。点,您可以在其中查找指纹中脊的交叉点。模式,其中使用模式识别算法。这要困难得多,但会产生更好的结果,尤其是在部分打印的情况下。

您需要做的是忘记重新发明轮子,并合并一个第三方软件模块,该模块将进行比较并将结果返回给您。

谷歌指纹比对软件。有 370 万条结果。这是用 C++ 编写的,包含源代码。祝你好运。

于 2013-05-05T20:26:33.357 回答