Ejemplo n.º 1
0
        public void A2iAOcrProcessingService_Test()
        {
            // Arrange
            var batch1 = new OcrBatch
            {
                JobIdentifier = "5830013",
                Vouchers = new List<OcrVoucher>()
            };

            var VouchersPath = Path.Combine(VouchersBasePath, dpi_240_tif);

            GetAllTestVouchers(batch1, Path.Combine(VouchersPath, Checks));
            configuration.MaxProcessorCount = 4;
            var a2IaService = new A2iACombinedTableService(engine1, configuration);
            a2IaService.Initialise();

            // Act
            a2IaService.ProcessBatch(batch1);

            // Assert
            WriteResults(batch1.Vouchers);
            //foreach (var voucher in batch1.Vouchers)
            //{
            //    Debug.WriteLine("v {0,-15}\tamt {1,-25}\tscore {2,-15}", voucher.Id, voucher.AmountResult.Result, voucher.AmountResult.Score);
            //}
            var resultFile = Path.Combine(ResultPath, string.Format("{0} 500 {1}", "raw", ResultFilename));
            var results = new string[batch1.Vouchers.Count() + 1];
            var index = 0;
            results[index++] = "Voucher Id, Amount, Score";
            foreach (var voucher in batch1.Vouchers)
            {
                results[index++] = string.Format("{0}, {1}, {2}", voucher.Id, voucher.AmountResult.Result, voucher.AmountResult.Score);
            }
            File.WriteAllLines(resultFile, results);
            a2IaService.Shutdown();
        }
Ejemplo n.º 2
0
        public void A2iAOcrProcessingService_Test_Multi_Batch_500_Images()
        {
            // Arrange
            var batch1 = new OcrBatch
            {
                JobIdentifier = "5830013",
                Vouchers = new List<OcrVoucher>()
            };

            var batch2 = new OcrBatch
            {
                JobIdentifier = "5830014",
                Vouchers = new List<OcrVoucher>()
            };

            var batch3 = new OcrBatch
            {
                JobIdentifier = "5830015",
                Vouchers = new List<OcrVoucher>()
            };

            var batch4 = new OcrBatch
            {
                JobIdentifier = "5830016",
                Vouchers = new List<OcrVoucher>()
            };

            const string VouchersPath = VouchersBasePath;
            GetAllTestVouchers(batch1, Path.Combine(VouchersPath, Checks), 0, 100);
            GetAllTestVouchers(batch2, Path.Combine(VouchersPath, Checks), 100, 200);
            GetAllTestVouchers(batch3, Path.Combine(VouchersPath, Checks), 200, 300);
            GetAllTestVouchers(batch4, Path.Combine(VouchersPath, Checks), 300, 500);

            configuration.MaxProcessorCount = 4;
            var a2IaService = new A2iACombinedTableService(engine1, configuration);
            a2IaService.Initialise();

            // Act
            a2IaService.ProcessBatch(batch1);
            a2IaService.ProcessBatch(batch2);
            a2IaService.ProcessBatch(batch3);
            a2IaService.ProcessBatch(batch4);

            // Assert
            WriteResults(batch1.Vouchers);
            WriteResults(batch2.Vouchers);
            WriteResults(batch3.Vouchers);
            WriteResults(batch4.Vouchers);
            var resultFile = Path.Combine(ResultPath, ResultFilename);
            var batchCount = 1;
            batchCount += batch1.Vouchers.Count();
            batchCount += batch2.Vouchers.Count();
            batchCount += batch3.Vouchers.Count();
            batchCount += batch4.Vouchers.Count();
            var results = new string[batchCount];
            var index = 0;
            results[index++] = "Voucher Id, Amount, Score";
            foreach (var voucher in batch1.Vouchers)
            {
                results[index++] = string.Format("{0}, {1}, {2}", voucher.Id, voucher.AmountResult.Result, voucher.AmountResult.Score);
            }
            foreach (var voucher in batch2.Vouchers)
            {
                results[index++] = string.Format("{0}, {1}, {2}", voucher.Id, voucher.AmountResult.Result, voucher.AmountResult.Score);
            }
            foreach (var voucher in batch3.Vouchers)
            {
                results[index++] = string.Format("{0}, {1}, {2}", voucher.Id, voucher.AmountResult.Result, voucher.AmountResult.Score);
            }
            foreach (var voucher in batch4.Vouchers)
            {
                results[index++] = string.Format("{0}, {1}, {2}", voucher.Id, voucher.AmountResult.Result, voucher.AmountResult.Score);
            }
            File.WriteAllLines(resultFile, results);
            a2IaService.Shutdown();
        }
Ejemplo n.º 3
0
        public void A2iAOcrProcessingService_Test_Multi_100_Batch_1_Images()
        {
            // Arrange
            var jobId = 5830013;
            var ocrBatches = new List<OcrBatch>();
            const string VouchersPath = VouchersBasePath;
            for (int i = 0; i < 100; i++)
            {
                var batch = new OcrBatch { JobIdentifier = jobId++.ToString(), Vouchers = new List<OcrVoucher>() };
                ocrBatches.Add(batch);
                GetAllTestVouchers(batch, Path.Combine(VouchersPath, Checks), i, 1);
            }

            configuration.MaxProcessorCount = 4;
            var a2IaService = new A2iACombinedTableService(engine1, configuration);
            a2IaService.Initialise();

            // Act
            foreach (var batch in ocrBatches)
            {
                //await a2IaService.ProcessVoucherAsync(batch.Vouchers);
                a2IaService.ProcessBatch(batch);
            }

            // Assert
            foreach (var batch in ocrBatches)
            {
                WriteResults(batch.Vouchers);
            }
            var resultFile = Path.Combine(ResultPath, ResultFilename);
            var batchCount = 1;
            foreach (var batch in ocrBatches)
            {
                batchCount += batch.Vouchers.Count();
            }
            var results = new string[batchCount];
            var index = 0;
            results[index++] = "Voucher Id, Amount, Score";
            foreach (var batch in ocrBatches)
            {
                foreach (var voucher in batch.Vouchers)
                {
                    results[index++] = string.Format("{0}, {1}, {2}", voucher.Id, voucher.AmountResult.Result, voucher.AmountResult.Score);
                }
            }
            File.WriteAllLines(resultFile, results);
            a2IaService.Shutdown();
        }
Ejemplo n.º 4
0
        public async Task A2iAOcrProcessingService_Test_Async_Images_400dpi_Upscaled_Tiff()
        {
            // Arrange
            var batch1 = new OcrBatch
            {
                JobIdentifier = "5830013",
                Vouchers = new List<OcrVoucher>()
            };

            var VouchersPath = Path.Combine(VouchersBasePath, dpi_400_upscaled_tif);
            GetAllTestVouchers(batch1, Path.Combine(VouchersPath, Checks));

            configuration.FileType = "TIF";
            configuration.MaxProcessorCount = 3;
            //configuration.MaxProcessorCount = 1;
            var a2IaService = new A2iACombinedTableService(engine1, configuration);
            a2IaService.Initialise();

            // Act
            a2IaService.ProcessBatch(batch1);

            // Assert
            const int confidence = 800;
            var subset = batch1.Vouchers.Where(v => int.Parse(v.AmountResult.Score) < confidence);
            Debug.WriteLine("{0}/{2} vouchers with confidence less than {1}", subset.Count(), confidence, batch1.Vouchers.Count());
            subset = batch1.Vouchers;
            foreach (var voucher in subset)
            {
                Debug.WriteLine("v {0,-15}\tamt {1,-25}\tscore {2,-15}\tmicr {3,-25}\tscore {4,-15}", voucher.Id, voucher.AmountResult.Result, voucher.AmountResult.Score, voucher.CodelineResult.Result, voucher.CodelineResult.Score);
            }
            var resultFile = Path.Combine(ResultPath, string.Format("{0} {1}", dpi_400_upscaled_tif, ResultFilename));
            var results = new string[batch1.Vouchers.Count() + 1];
            var index = 0;
            results[index++] = "Voucher Id, Amount, Score";
            foreach (var voucher in batch1.Vouchers)
            {
                results[index++] = string.Format("{0}, {1}, {2}", voucher.Id, voucher.AmountResult.Result, voucher.AmountResult.Score);
            }
            File.WriteAllLines(resultFile, results);
            a2IaService.Shutdown();
        }