Beispiel #1
0
        public static void exe_ocr(string filename, IOcrDocument ocrDocument)
        {
            Console.WriteLine(filename);
            RasterCodecs rasterCodecs = null;
            RasterImage  rasterImage  = null;

            try
            {
                rasterCodecs = new RasterCodecs();
                rasterCodecs.ThrowExceptionsOnInvalidImages = false;
                rasterImage = rasterCodecs.Load(filename);
                AutoBinarizeCommand command = new AutoBinarizeCommand();
                command.Run(rasterImage);

                //AutoLineRemoveCommand commandLine = new AutoLineRemoveCommand();
                //commandLine.Run(rasterImage);

                IOcrPage page = ocrDocument.Pages.AddPage(rasterImage, null);
                if (page != null)
                {
                    page.UpdateNativeFillMethod();
                    page.Recognize(null);
                }

                // ocrDocument.Pages.zon(NativeOcrZoneType.AutoGraphic);
            }catch (Exception e)
            {
                //    Console.WriteLine("add image faild: " + e);
            }
            finally
            {
                if (rasterCodecs != null)
                {
                    rasterCodecs.Dispose();
                }
                if (rasterImage != null)
                {
                    rasterImage.Dispose();
                }
            }
        }