急用
vb6.0 怎么抓取图片上的文字 --------------------编程问答-------------------- “图片上的文字”本质也是“图”而不是文字!这个就是“OCR”方面的问题了,要处理好,可不是容易的事。
--------------------编程问答--------------------
+1 --------------------编程问答-------------------- 找找有没图像识别的库 --------------------编程问答--------------------
+1 --------------------编程问答-------------------- 这要图像识别了, 直接抓不到的 --------------------编程问答-------------------- 利用office2003中的控件做的ocr源码
Introduction
Optical Character Recognition (OCR) extracts text and layout information from document images. With the help of Microsoft Office Document Imaging Library (MODI), which is contained in the Office 2003 package, you can easily integrate OCR functionality into your own applications. In combination with the MODI Document Viewer control, you will have complete OCR support with only a few lines of code.
Important note: MS Office XP does not contain MODI, MS Office 2003 is required!
Getting started
Adding the library
First of all, you need to add the library’s reference to your project: Microsoft Office Document Imaging 11.0 Type Library (located in MDIVWCTL.DLL).
Create a document instance and assign an image file
Supported image formats are TIFF, multi page TIFF, and BMP.
Dim strLayoutInfo As String--------------------编程问答-------------------- office document imaging那是超级垃圾,用画图板输入几个汉字,存成tif,竟然不能识别.
Dim miDoc As Object
Dim modiLayout As Object
'初始化并加载文档
Set miDoc = CreateObject("MODI.Document") '创建对象
miDoc.Create "c:\VBOCR\z.tif" '加载图片文件
Screen.MousePointer = vbHourglass '设置光标忙
'识别
miDoc.Images(0).OCR miLANG_CHINESE_SIMPLIFIED, True, True '有用的就此一句,识别为中文简体
Set modiLayout = miDoc.Images(0).Layout '读出数据
strLayoutInfo = _
"Language: " & modiLayout.Language & vbCrLf & _
"Number of characters: " & modiLayout.NumChars & vbCrLf & _
"Number of fonts: " & modiLayout.NumFonts & vbCrLf & _
"Number of words: " & modiLayout.NumWords & vbCrLf & _
"Beginning of text: " & Left(modiLayout.Text, 50) & vbCrLf & _
"First word of text: " & modiLayout.Words(0).Text
Debug.Print modiLayout.Text
MsgBox strLayoutInfo, vbInformation + vbOKOnly, "Layout Information"
Set modiLayout = Nothing
Set miDoc = Nothing
Screen.MousePointer = vbDefault
还好能识别英文字符和数字.要不都不知道存在的意义了. --------------------编程问答-------------------- 如果你说的图片上的字是现画上去的,是可以抓取的,思路是拦截GDI中的绘图函数,得到文字。
事实上,很多词典软件的屏幕抓词功能就是这么实现的。 --------------------编程问答--------------------
你说的是hook,别个说的ocr,吼吼
补充:VB , API