在 C# 中使用 MODI 进行 OCR。需要从内存而不是磁盘读取图像
我正在尝试使用 MODI 对内存中已有的位图执行 OCR。我似乎无法找到解决方案,因为我找到的所有示例都使用 create 方法从磁盘抓取图像并为 OCR 做好准备。但是,我已经将图像存储在内存中,并且可以写入和读取图像往返磁盘消耗太多时间。
Bitmap bmp = ...
//Instantiate the MODI.Document object
MODI.Document md = new MODI.Document();
//The Create method grabs the picture from disk snd prepares for OCR.
md.Create("C:\\bmp.gif"); //but I don't want to read from disk :(
//Do the OCR.
md.OCR(MODI.MiLANGUAGES.miLANG_ENGLISH, true, true);
//Get the first (and only image)
MODI.Image image = (MODI.Image)md.Images[0];
//Get the layout.
MODI.Layout layout = image.Layout;
I'm trying to use MODI to perfom OCR on bitmaps I already have in memory. I can't seem to find a solution to this as all the examples I find use the create method to grab the image from the disk and prepares it for the OCR., however, I already have the image on memory and writing and reading i to and from the disk consumes too much time.
Bitmap bmp = ...
//Instantiate the MODI.Document object
MODI.Document md = new MODI.Document();
//The Create method grabs the picture from disk snd prepares for OCR.
md.Create("C:\\bmp.gif"); //but I don't want to read from disk :(
//Do the OCR.
md.OCR(MODI.MiLANGUAGES.miLANG_ENGLISH, true, true);
//Get the first (and only image)
MODI.Image image = (MODI.Image)md.Images[0];
//Get the layout.
MODI.Layout layout = image.Layout;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
你不能。 Create 只有一个版本,并且需要一个文件。
制作一个临时文件。将图像保存到其中。删除临时文件。
使用 Path.GetTempFileName() 来执行此操作。
You can't. There is only one version of Create and it takes a file.
Make a temp file. Save the image into it. Delete the temp file.
Use Path.GetTempFileName() to do that.
这个 MODI.Document 类可以从流中读取吗?就像
Image.FromStream(YourStream);
这样你就可以创建一个内存流并从中读取。
Can this MODI.Document Class read from a stream? Like the
Image.FromStream(YourStream);
That way you can create a memory stream and read from it.
您可以在维基百科上查看 MODI / OCR 信息
en.wikipedia.org/wiki/Microsoft_Office_Document_Imaging
en.wikipedia.org/wiki/List_of_optical_character_recognition_software
You can check MODI / OCR information on wikipedia
en.wikipedia.org/wiki/Microsoft_Office_Document_Imaging
en.wikipedia.org/wiki/List_of_optical_character_recognition_software
使用 Microsoft Office 的成像功能对图像进行 OCR 的最简单代码(需要 MS-Office 2007 或更高版本,必须安装成像组件,并且必须将 MODI 添加到引用中)。
调用函数可以是:
Simplest code to OCR an image using Microsoft Office's Imaging functionality (requires MS-Office 2007 or later, imaging components must be installed and MODI must be added to references).
Calling function can be: