Exemplo n.º 1
0
        public static string ImgToFile(string pathToFile, int Language)
        {
            if (FormatFile(pathToFile))
            {
                string result = "";
                using (Bitmap load = new Bitmap(pathToFile))
                {
                    using (PumaPage image = new PumaPage(load))
                    {
                        image.FileFormat                = PumaFileFormat.TxtAscii;
                        image.AutoRotateImage           = true;
                        image.EnableSpeller             = false;
                        image.RecognizeTables           = true;
                        image.FontSettings.DetectItalic = true;
                        image.Language = SetLanguage(Language);

                        try
                        {
                            result = image.RecognizeToString();
                        }
                        catch (Exception e)
                        {
                            image.Dispose();
                        }
                    }
                }
                return(result);
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 2
0
        public void ImageToText()
        {
            string result = "";
            //picture.Save("picture.png");
            PumaPage image = new PumaPage(picture);

            using (image)
            {
                image.FileFormat         = PumaFileFormat.TxtAscii;
                image.AutoRotateImage    = false;
                image.EnableSpeller      = false;
                image.Language           = PumaLanguage.RussianEnglish;
                image.PreserveLineBreaks = false;

                try
                {
                    result = image.RecognizeToString();
                }
                catch (Exception)
                {
                    Console.WriteLine("Recognition failed");
                }
                finally
                {
                    image.Dispose();
                }
            }

            picture.Dispose();
            result    = result.Replace(" ", "");
            imageText = String.Copy(result);
        }