许明会的计算机技术主页

Language:C,C++,.NET Framework(C#)
Thinking:Design Pattern,Algorithm,WPF,Windows Internals
Database:SQLServer,Oracle,MySQL,PostSQL
IT:MCITP,Exchange,Lync,Virtualization,CCNP

导航

OCR图像识别技术-Asprise OCR

// 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();
        }
    }
}

posted on 2016-04-15 16:32  许明会  阅读(3682)  评论(1编辑  收藏  举报