twain ocr函数返回空字节 [英] twain ocr function returns empty byte

查看:108
本文介绍了twain ocr函数返回空字节的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下代码:



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)





我面临的问题是虽然缓冲区中的indice是正确的,并且路径和dll很好地实现但是转换为字节数组不成功,所以sbytes字节数组总是被设置为空。我没有得到任何异常,但是长度是字节是0



任何想法如何解决这个问题?



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?

推荐答案

更改
Me.dynamicDotNetTwain1.OCRLanguage = "English"

to

Me.dynamicDotNetTwain1.OCRLanguage = "eng"


不确定,但看起来很有希望:

dynamicDotNetTwain1。 CurrentImageIndexInBuffer 在最后一行与 dynamicDotNetTwain1.CurrentSelectedImageIndicesInBuffer 在最后一行。
Not sure, but that looks promissing:
dynamicDotNetTwain1.CurrentImageIndexInBuffer in the top lines vs. dynamicDotNetTwain1.CurrentSelectedImageIndicesInBuffer in the last line.


这篇关于twain ocr函数返回空字节的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆