ADR Compare Pages in TIF - Always Returns 100

Discussions about Automatic Document Recognition in GdPicture.NET.
Post Reply
thowle
Posts: 24
Joined: Thu Jul 30, 2009 1:56 am

ADR Compare Pages in TIF - Always Returns 100

Post by thowle » Wed Sep 30, 2009 9:15 pm

The following code ALWAYS Returns 100 for all...

Code: Select all

Public Sub doDetectDuplicates()
        Panel15.Visible = True
        ListView2.Items.Clear()

        Dim MaxStatus As Integer = oGdPictureImaging.TiffGetPageCount(tiffID) * oGdPictureImaging.TiffGetPageCount(tiffID)
        Dim CurrentStatus As Integer = 0

        ProgressBar7.Value = (CurrentStatus / MaxStatus) * 100

        Dim TemplateID As Integer

        For pageNum As Integer = 1 To oGdPictureImaging.TiffGetPageCount(tiffID)
            oGdPictureImaging.TiffSelectPage(tiffID, pageNum)

            Dim thisImage As Bitmap = New Bitmap(oGdPictureImaging.GetBitmapFromGdPictureImage(tiffID))
            Dim newImage As Integer = oGdPictureImaging.CreateGdPictureImageFromBitmap(thisImage)
            TemplateID = oGdPictureImaging.ADRCreateTemplateFromGdPictureImage(newImage)

            If TemplateID = 0 Then
                MsgBox("Can't create Template " + "Error number: " + Str(oGdPictureImaging.GetStat))
            End If

            For comparePageNum As Integer = 1 To oGdPictureImaging.TiffGetPageCount(tiffID)
                oGdPictureImaging.TiffSelectPage(tiffID, pageNum)

                Dim thisImageCompare As Bitmap = New Bitmap(oGdPictureImaging.GetBitmapFromGdPictureImage(tiffID))
                Dim newImageCompare As Integer = oGdPictureImaging.CreateGdPictureImageFromBitmap(thisImageCompare)
                oGdPictureImaging.ADRGetCloserTemplateForGdPictureImage(newImageCompare)
                oGdPictureImaging.ReleaseGdPictureImage(newImageCompare)
                thisImageCompare = Nothing

                Dim tConf As Double = oGdPictureImaging.ADRGetLastConfidence()
                If tConf > 50 Then
                    Dim lvi As New ListViewItem
                    With lvi
                        .Text = "Page " & pageNum
                        .SubItems.Add("Page " & comparePageNum)
                        .SubItems.Add(FormatNumber(tConf, 1) & "% Match")
                    End With
                    ListView2.Items.Add(lvi)
                End If

                CurrentStatus = CurrentStatus + 1
                If ((CurrentStatus / MaxStatus) * 100) > 100 Then
                    ProgressBar7.Value = 100
                Else
                    ProgressBar7.Value = (CurrentStatus / MaxStatus) * 100
                End If
                Application.DoEvents()
            Next

            CurrentStatus = CurrentStatus + 1
            If ((CurrentStatus / MaxStatus) * 100) > 100 Then
                ProgressBar7.Value = 100
            Else
                ProgressBar7.Value = (CurrentStatus / MaxStatus) * 100
            End If
            Application.DoEvents()

            oGdPictureImaging.ADRDeleteTemplate(TemplateID)
            oGdPictureImaging.ReleaseGdPictureImage(newImage)
            thisImage = Nothing
        Next
    End Sub

thowle
Posts: 24
Joined: Thu Jul 30, 2009 1:56 am

Re: ADR Compare Pages in TIF - Always Returns 100

Post by thowle » Wed Sep 30, 2009 10:02 pm

Nevermind, found the issue in the fact that I wasn't comparing and apple to an orange.. it was comparing apple to apple by not getting the newTiffID.

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests