标签:
// csc AspriseDemo.cs /r:AspriseOcr.dll // 注意注册:AspriseOCR.InputLicense("123456", "123456789123456789123456789"); // http://asprise.com/ocr/docs/html/asprise-ocr-library-csharp-vb.net-component.html using System; using AspriseOcr; namespace AspriseDemo { class Program { static void Main(string[] args) { AspriseOCR.SetUp(); AspriseOCR.InputLicense("123456", "123456789123456789123456789"); AspriseOCR ocr = new AspriseOCR(); ocr.StartEngine("eng", AspriseOCR.SPEED_FASTEST); string s = ocr.Recognize(@".\demo.png", -1, -1, -1, -1, -1,AspriseOCR.RECOGNIZE_TYPE_ALL, AspriseOCR.OUTPUT_FORMAT_PLAINTEXT); /* 支持识别类型 PDF,TIF,PNG,JPG, //TEXT ONLY s = ocr.Recognize(@"C:\path\img.jpg", -1, -1, -1, -1, -1,AspriseOCR.RECOGNIZE_TYPE_TEXT, AspriseOCR.OUTPUT_FORMAT_PLAINTEXT); //BARCODE ONLY s = ocr.Recognize(@"C:\path\img.jpg", -1, -1, -1, -1, -1,AspriseOCR.RECOGNIZE_TYPE_BARCODE, AspriseOCR.OUTPUT_FORMAT_PLAINTEXT); //PART OF IMAGE s = ocr.Recognize(@"C:\path\img.jpg", -1, 0, 0, 400, 200, AspriseOCR.RECOGNIZE_TYPE_ALL, AspriseOCR.OUTPUT_FORMAT_PLAINTEXT); //More Image s = ocr.Recognize(@"C:\img1.jpg;C:\img2.png", -1, -1, -1, -1, -1,AspriseOCR.RECOGNIZE_TYPE_ALL, AspriseOCR.OUTPUT_FORMAT_PLAINTEXT); //可以使用字典 //ocr.StartEngine("eng", AspriseOCR.SPEED_FASTEST,"START_PROP_DICT_CUSTOM_DICT_FILE=dict.txt"); s = ocr.Recognize("image.png", -1, -1, -1, -1, -1, AspriseOCR.RECOGNIZE_TYPE_ALL, AspriseOCR.OUTPUT_FORMAT_PLAINTEXT); //将识别结果存为 PDF ocr.Recognize(@"C:\test-image.png", -1, -1, -1, -1, -1, Ocr.RECOGNIZE_TYPE_ALL, Ocr.OUTPUT_FORMAT_PDF, AspriseOCR.PROP_PDF_OUTPUT_FILE, "ocr-result.pdf", AspriseOCR.PROP_PDF_OUTPUT_TEXT_VISIBLE, true); */ Console.WriteLine(s); ocr.StopEngine(); Console.ReadKey(); } } }
标签:
原文地址:http://www.cnblogs.com/flaaash/p/5395926.html