vb.net OCR运行错误 [英] vb.net OCR running error
本文介绍了vb.net OCR运行错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试阅读http://sfprivat.8u.cz/captchapred.bmp,但它仍在写"OCR运行错误",我试图将颜色转换为黑色&白色 http://sfprivat.8u.cz/captcha.bmp但我仍然收到此错误。
代码:
尝试
Dim img As Bitmap = New Bitmap(PictureBox1.Image)
Dim c As Color
Dim i As Integer = 0
Do while(i< ; img.Width)
Dim j As Integer = 0
Do While(j< img.Height)
c = img.GetPixel(i,j)
Dim r As Integer = 0
r = Convert.ToInt16(cR)
Dim g As Integer = 0
g = Convert.ToInt16(cG)
Dim b As Integer = 0
b =转换.ToInt16(cB)
Dim ans As Integer =((r _
+(g + b))_
/ 3)
If(ans > 128)然后
r = 255
g = 255
b = 255
否则
r = 0
g = 0
b = 0
结束If
c = Color.FromArgb(r,g,b)
img.SetPixel(i,j,c)
j =(j + 1)
循环
i =( i + 1)
循环
PictureBox1.Image = img
Catch ex As Exception
MessageBox.Show(ex.Message)
结束尝试
PictureBox1.Image.Save(CurDir()+" \ captcha.bmp")
Dim md As New MODI.Document()
md.Create(CurDir()+ " \ captcha.bmp")
md.OCR(MODI.MiLANGUAGES.miLANG_ENGLISH,True,True)
Dim imagec As MODI.Image = DirectCast(md.Images(0),MODI.Image)
Dim layout As MODI.Layout = imagec.Layout
Dim out As String = ""
对于j As Integer = 0 To layout.Words.Count - 1
Dim word As MODI.Word = DirectCast(layout.Words(j),MODI.Word)
out + =" ; " &安培; word.Text
下一个
MsgBox(out)
错误在这一行"md.OCR(MODI) .MiLANGUAGES.miLANG_ENGLISH,True,True)"
谢谢提前
解决方案
由于您的问题是关于Office Develop,我会将您的主题移至"Excel for Developers"。
问候,
George 。赵
Hi, please I'm trying to read http://sfprivat.8u.cz/captchapred.bmp but it still writing "OCR running error", i tryied to convert colors to black & white http://sfprivat.8u.cz/captcha.bmp but still I'm getting this error.
Code:
Try Dim img As Bitmap = New Bitmap(PictureBox1.Image) Dim c As Color Dim i As Integer = 0 Do While (i < img.Width) Dim j As Integer = 0 Do While (j < img.Height) c = img.GetPixel(i, j) Dim r As Integer = 0 r = Convert.ToInt16(c.R) Dim g As Integer = 0 g = Convert.ToInt16(c.G) Dim b As Integer = 0 b = Convert.ToInt16(c.B) Dim ans As Integer = ((r _ + (g + b)) _ / 3) If (ans > 128) Then r = 255 g = 255 b = 255 Else r = 0 g = 0 b = 0 End If c = Color.FromArgb(r, g, b) img.SetPixel(i, j, c) j = (j + 1) Loop i = (i + 1) Loop PictureBox1.Image = img Catch ex As Exception MessageBox.Show(ex.Message) End Try PictureBox1.Image.Save(CurDir() + "\captcha.bmp") Dim md As New MODI.Document() md.Create(CurDir() + "\captcha.bmp") md.OCR(MODI.MiLANGUAGES.miLANG_ENGLISH, True, True) Dim imagec As MODI.Image = DirectCast(md.Images(0), MODI.Image) Dim layout As MODI.Layout = imagec.Layout Dim out As String = "" For j As Integer = 0 To layout.Words.Count - 1 Dim word As MODI.Word = DirectCast(layout.Words(j), MODI.Word) out += " " & word.Text Next MsgBox(out)
Error is on this line "md.OCR(MODI.MiLANGUAGES.miLANG_ENGLISH, True, True)"
Thanks advance
解决方案
Hi ,Since your question is about Office Develop, I will move your thread to "Excel for Developers".
Regards,
George.Zhao
这篇关于vb.net OCR运行错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文