Example #1
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");
        }
        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);
        }
        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
            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 #6
0
        private async Task RecognizeNext()
        {
            var file = await _queue.Reader.ReadAsync();

            var img = Image.FromFile(file);

            if (img == null)
            {
                return;
            }

            var temp = Path.GetTempFileName();

            CropHalfImage(img).Save(temp);

            var result = _ocr.RecognizeImage(temp);

            Console.WriteLine(result[0] + " Id: " + Thread.CurrentThread.ManagedThreadId);
        }
        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");
        }
Example #8
0
 public async Task <List <string> > Recognize(List <Rectangle> areas)
 {
     return(ac.RecognizeImage(ms, areas));
 }