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