OCR reading problems

Discussions about machine vision support in GdPicture.
Post Reply
arldic
Posts: 2
Joined: Tue Mar 02, 2010 1:07 pm

OCR reading problems

Post by arldic » Tue Mar 02, 2010 1:22 pm

Hi

I'm having problems with ocr-reading when scanning. I'm scaning id-cards. What should I do to make this code read better

Kind Regards
Dick

Code: Select all

       Dim ImageID As Integer
        Dim MultiPageID As Integer
        Dim strTempPath As String
        Dim strGuid As String
        Dim oGuid As New System.Guid
        Dim strOCR As String
        strGuid = oGuid.NewGuid.ToString

        Dim nImageCount As Integer
   
        If oGdPictureImaging.TwainOpenDefaultSource(Me.Handle) Then
            nImageCount = 0

            InitScanConfig()

            oGdPictureImaging.TwainSetAutoFeed(True) 'Set AutoFeed Enabled
            oGdPictureImaging.TwainSetAutoScan(True) 'To  achieve the maximum scanning rate
            oGdPictureImaging.TwainSetResolution(500)
            oGdPictureImaging.TwainSetPixelType(TwainPixelType.TWPT_RGB) 'Black & White
            oGdPictureImaging.TwainSetBitDepth(1) ' 1 bpp
            Do
                ImageID = oGdPictureImaging.TwainAcquireToGdPictureImage(Me.Handle)
                If ImageID <> 0 Then
                    nImageCount = nImageCount + 1
                    Call ApplyImageFilters(ImageID)
                    MultiPageID = ImageID
                    oGdPictureImaging.OCRTesseractReinit()
                    oGdPictureImaging.OCRTesseractSetPassCount(2)
                    strOCR = oGdPictureImaging.OCRTesseractDoOCR(ImageID, TesseractDictionary.TesseractDictionaryEnglish, "C:\Program Files\GdPicture.NET\Redist\OCR\", "1234567890.-abcdefghijklmnopqrstuvwxyz")
                    MsgBox(strOCR)

                    'Call oGdPictureImaging.TiffSaveAsMultiPageFile(MultiPageID, My.Application.Info.DirectoryPath & "\multipage.tif", TiffCompression.TiffCompressionCCITT4)
                End If
            Loop While oGdPictureImaging.TwainGetState > TwainStatus.TWAIN_SOURCE_ENABLED

            oGdPictureImaging.TiffCloseMultiPageFile(MultiPageID)
            oGdPictureImaging.TwainCloseSource()
            strTempPath = System.IO.Path.GetTempPath.ToString
            If System.IO.Directory.Exists(strTempPath) Then
                strTempPath = "c:\xwebs"
                oGdPictureImaging.SaveAsJPEG(ImageID, strTempPath & "\" & strGuid & ".jpg")
                MsgBox("Done !")
            Else
                MsgBox("temppath saknas i din profil")
            End If
        Else
            MsgBox("can't open default source, twain state is: " & oGdPictureImaging.TwainGetState.ToString)
        End If

arldic
Posts: 2
Joined: Tue Mar 02, 2010 1:07 pm

Re: OCR reading problems

Post by arldic » Tue Mar 02, 2010 5:50 pm

I have now defined an area to ocr scan with following code.
oGdPictureImaging.SetROI(750, 448, 338, 83)
But sometimes it returns 2020-11-10 (which is correct) but other times
it is 2020711710 or 12020-11-10.
The id-card is not moved from the scanner, but still different results from time to time.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest