twain ocr function returns empty byte

250 views Asked by At

i have the below code:

    ddlResultFormat.Items.Add("Text")

    dynamicDotNetTwain1.LoadImage("C:\Users\elj\Desktop\3b072e9b-76b4-4776-bd3c-5984074d8ecd.png")
    Dim r = dynamicDotNetTwain1.GetImage(dynamicDotNetTwain1.CurrentImageIndexInBuffer).Width.ToString()
    Dim l = dynamicDotNetTwain1.GetImage(dynamicDotNetTwain1.CurrentImageIndexInBuffer).Height.ToString()
    Dim languageFolder As String
    languageFolder = "C:\Program Files (x86)\Dynamsoft\Dynamic .NET TWAIN 5.2 Trial\Samples\Bin\"
    Dim languages As New Dictionary(Of String, String)
    languages.Add("English", "eng")
    Me.dynamicDotNetTwain1.OCRTessDataPath = languageFolder
    Me.dynamicDotNetTwain1.OCRLanguage = "English"

    Dim ocrResultFormat As Dynamsoft.DotNet.TWAIN.OCR.ResultFormat
    ocrResultFormat = CType(System.Enum.Parse(GetType(Dynamsoft.DotNet.TWAIN.OCR.ResultFormat), Val("&H" & 0)), Dynamsoft.DotNet.TWAIN.OCR.ResultFormat)
    Me.dynamicDotNetTwain1.OCRResultFormat = ResultFormat.Text

    Dim strDllPath As String
    strDllPath = "C:\Program Files (x86)\Dynamsoft\Dynamic .NET TWAIN 5.2 Trial\Redistributable\OCRResources\"
    dynamicDotNetTwain1.OCRDllPath = strDllPath

    If (Me.dynamicDotNetTwain1.CurrentImageIndexInBuffer < 0) Then
        Dim jajajja = "Please load an image before doing OCR!"
    End If

    Dim sbytes As Byte()
    sbytes = Me.dynamicDotNetTwain1.OCR(Me.dynamicDotNetTwain1.CurrentSelectedImageIndicesInBuffer)

the problem that i'm facing is that the sbytes byte array is being always set to empty although the indice in the buffer is correct and the paths and the dll are well implemented but the convert to the byte array is not being successful i'm not getting any exception but the length of the byte is 0

any idea how can i fix this?

1

There are 1 answers

0
Rachel On

Please update the following line of code and try again.

Me.dynamicDotNetTwain1.OCRLanguage = "eng" 'not English