Exemple #1
0
        public static GenericOcrResponse Map(AwsOcrResponse awsResponse)
        {
            var response = new GenericOcrResponse();

            response.SummaryText = string.Join(" ", awsResponse.TextDetections.Select(td => td.DetectedText));

            response.Detections = awsResponse.TextDetections.Select(td => Get(td)).ToList();
            return(response);
        }
Exemple #2
0
        public async Task Tesseract5()
        {
            TesseractOcrService tesseractService = new TesseractOcrService();
            TesseractResponse   result           = await tesseractService.GetOcrResultAsync(@"data/abc.JPG", "eng");

            Assert.IsNotNull(result);
            GenericOcrResponse genericResult = result.Map();

            Assert.IsNotNull(genericResult);
        }
Exemple #3
0
        public async Task WindowsOcr()
        {
            WindowsOcrService windowsOcrExecutor = new WindowsOcrService();
            WindowsOcrResult  result             = await windowsOcrExecutor.GetOcrResultAsync(@"data/abc.JPG", "en");

            Assert.IsNotNull(result);
            GenericOcrResponse genericResult = result.Map();

            Assert.IsNotNull(genericResult);
        }
Exemple #4
0
        public async Task AwsOcr()
        {
            var            accessKey     = ConfigurationManager.AppSettings["awsAccessKey"];
            var            secretKey     = ConfigurationManager.AppSettings["awsSecretKey"];
            var            awsRegion     = ConfigurationManager.AppSettings["awsRegion"];
            AwsOcrService  awsOcrService = new AwsOcrService(accessKey, secretKey, awsRegion);
            AwsOcrResponse result        = await awsOcrService.GetOcrResultAsync(@"data/abc.JPG");

            Assert.IsNotNull(result);
            GenericOcrResponse genericResult = result.Map();

            Assert.IsNotNull(genericResult);
        }
Exemple #5
0
        public async Task GoogleOCR()
        {
            var apiToken = ConfigurationManager.AppSettings["googleApiToken"];
            GoogleOcrService googleOcrService = new GoogleOcrService(apiToken);

            GoogleOcrResponse result = await googleOcrService.GetOcrResultAsync(@"data/abc.JPG");

            var descriptions = result.Responses.SelectMany(r => r.Annotations).ToList();

            Assert.IsNotNull(result);
            GenericOcrResponse genericResult = result.Map();

            Assert.IsNotNull(genericResult);
        }
Exemple #6
0
        public async Task AzureOcr()
        {
            var subscriptionKey = ConfigurationManager.AppSettings["azureSubscriptionKey"];
            var endpoint        = ConfigurationManager.AppSettings["azureEndpoint"];


            AzureOcrService azureOcrExecutor = new AzureOcrService(subscriptionKey, endpoint);
            AzureOcrResults result           = await azureOcrExecutor.GetOcrResultAsync(@"data/abc.JPG");

            Assert.IsNotNull(result);
            GenericOcrResponse genericResult = result.Map();

            Assert.IsNotNull(genericResult);
        }
Exemple #7
0
        public GenericOcrResponse Map(AwsOcrResponse awsResponse)
        {
            using (MagickImage img = new MagickImage(awsResponse.InputImage))
            {
                this.width  = img.Width;
                this.height = img.Height;
            }

            var response = new GenericOcrResponse();

            response.SummaryText = string.Join(" ", awsResponse.TextDetections.Select(td => td.DetectedText));

            response.Detections = awsResponse.TextDetections.Select(td => Get(td)).ToList();
            return(response);
        }