开发者

How to OCR a specific region of a MODI.Document?

I need to OCR a specific region of a scanned document and I am using MODI (Microsoft's Document Imaging COM object).

My code currently OCR's the entire page (quite accurately!), but I开发者_开发百科 would like to target a specific region of the page where the text is always static (order number). How can I do this?

Here is my code for the page:

MODI.Document md = new MODI.Document();

md.Create("c:\\temp\\mpk.tiff");

md.OCR(MODI.MiLANGUAGES.miLANG_ENGLISH, true, true);
MODI.Image image = (MODI.Image)md.Images[0];

FileStream createFile = new FileStream("c:\\temp\\mpk.txt", FileMode.CreateNew);

StreamWriter writeFile = new StreamWriter(createFile);
writeFile.Write(image.Layout.Text);
writeFile.Close();

md.Close();

Can I somehow specify the region of the image?

Any help would be greatly appreciated!


There's no way to crop the image that I see with the MODI object model. The alternative is to provide it with an image that contains just the order number you want to convert. You can use the classes in the System.Drawing namespace to create it from the original. Check this MSDN page for sample code.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜