public RecognizedImage Recognize(Stream imageStream)
        {
            try
            {
                var api = new AsposeOcr();

                using (MemoryStream ms = new MemoryStream())
                {
                    imageStream.Position = 0;
                    imageStream.CopyTo(ms);
                    var rectangles = api.GetRectangles(ms, AreasType.LINES, false);
                    var result     = api.RecognizeImage(ms, new RecognitionSettings
                    {
                        DetectAreas      = false,
                        RecognitionAreas = rectangles
                    });
                    return(CreateRecognizedImageFromResult(result));
                }
            }
            catch (System.Exception ex)
            {
                Console.WriteLine("Aspose.OCR Recognition failed: {0}", ex);
            }
            return(RecognizedImage.Empty);
        }
Example #2
0
        public static void Run()
        {
            // ExStart:1
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_OCR();

            // Initialize an instance of AsposeOcr
            AsposeOcr api = new AsposeOcr();

            // Recognize image
            List <Rectangle> rects = new List <Rectangle>()
            {
                new Rectangle(138, 352, 2033, 537),
                new Rectangle(147, 890, 2033, 1157),
                new Rectangle(923, 2045, 465, 102),
                new Rectangle(104, 2147, 2076, 819)
            };

            string result = api.RecognizeImage(dataDir + "sample.png", rects[0]);

            // Display the recognized text
            Console.WriteLine(result);
            // ExEnd:1

            Console.WriteLine("RecognizeTextFromSpecificRectangle executed successfully");
        }
Example #3
0
        public ReaderService(string path)
        {
            EnsurePath(path);

            _queue = Channel.CreateUnbounded <string>();
            _path  = path;
            _ocr   = new AsposeOcr();
        }
        public static void Run()
        {
            // ExStart:1
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_OCR();

            // Initialize an instance of AsposeOcr
            AsposeOcr api = new AsposeOcr();

            // Recognize image
            string result = api.RecognizeImage(dataDir + "sample.png", true, false);

            // Display the recognized text
            Console.WriteLine(result);
            // ExEnd:1

            Console.WriteLine("RecognizeImageWithTextAreaDetectionAndWithoutSkewCorrection executed successfully");
        }
        public static void Run()
        {
            // ExStart:1
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_OCR();

            // Initialize an instance of AsposeOcr
            AsposeOcr api = new AsposeOcr();

            // Recognize image
            string result = api.RecognizeImage(dataDir + "sample.png");

            // Display the recognized text
            Console.WriteLine(result);
            // ExEnd:1

            Console.WriteLine("PerformOCROnImage executed successfully");
        }
        public static void Run()
        {
            // ExStart:1
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_OCR();

            // Initialize an instance of AsposeOcr with allowed symbols
            AsposeOcr api = new AsposeOcr("0123456789");

            // Recognize image
            string result = api.RecognizeLine(dataDir + "0001460985.Jpeg");

            // Display the recognized text
            Console.WriteLine(result);
            // ExEnd:1

            Console.WriteLine("SpecifyAllowedCharacters executed successfully");
        }
Example #7
0
        public static void Run()
        {
            // ExStart:1
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_OCR();

            // Initialize an instance of AsposeOcr
            AsposeOcr api = new AsposeOcr();

            // Calculate Angle
            float angle = api.CalculateSkew(dataDir + "skew_image.png");

            // Display the result
            Console.WriteLine(angle);
            // ExEnd:1

            Console.WriteLine("CalculateSkewAngle executed successfully");
        }
        public static void Run()
        {
            // ExStart:1
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_OCR();

            // Initialize an instance of AsposeOcr
            AsposeOcr api = new AsposeOcr();

            // Recognize image
            string result = api.RecognizeImage(dataDir + "SpanishOCR.bmp");

            // Display the recognized text
            Console.WriteLine(result);
            // ExEnd:1

            Console.WriteLine("WorkingWithDifferentLanguages executed successfully");
        }
Example #9
0
        public static void Run()
        {
            // ExStart:1
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_OCR();
            float  angle   = 0;

            // Initialize an instance of AsposeOcr
            AsposeOcr api = new AsposeOcr();

            // Calculate Angle
            using (MemoryStream ms = new MemoryStream())
                using (FileStream file = new FileStream(dataDir + "skew_image.png", FileMode.Open, FileAccess.Read))
                {
                    file.CopyTo(ms);
                    angle = api.CalculateSkew(ms);
                }

            // Display the result
            Console.WriteLine(angle);
            // ExEnd:1

            Console.WriteLine("CalculateSkewAngleFromStream executed successfully");
        }
        public static void Run()
        {
            // ExStart:1
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_OCR();
            string result  = "";

            // Initialize an instance of AsposeOcr
            AsposeOcr api = new AsposeOcr();

            // Recognize image
            using (MemoryStream ms = new MemoryStream())
                using (FileStream file = new FileStream(dataDir + "sample.png", FileMode.Open, FileAccess.Read))
                {
                    file.CopyTo(ms);
                    result = api.RecognizeImage(ms);
                }

            // Display the recognized text
            Console.WriteLine(result);
            // ExEnd:1

            Console.WriteLine("RecognizeImageFromStream executed successfully");
        }