开发者

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

开发者 https://www.devze.com 2023-02-14 19:05 出处:网络
I need to OCR a specific region of a scanned document and I am using MODI (Microsoft\'s Document Imaging COM object).

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

精彩评论

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

关注公众号