示例#1
0
 public void TestInitialize()
 {
     _template = new OcrTemplate
     {
         CourtId = 1,
         DocumentType = "Case Management Statement",
         OcrTemplateId = 1                
     };
                  
     var caseNumberRegion = new OcrRegion(1561, 957, 2291, 1158, OcrRegionName.CaseNumber);
     var plaintiffRegion = new OcrRegion(150, 830, 1640, 1010, OcrRegionName.Plaintiff);
     var attorneyRegion = new OcrRegion(150, 200, 1640, 590, OcrRegionName.Attorney);
     var hearingDateRegion = new OcrRegion(150, 1220, 2291, 1350, OcrRegionName.HearingDate);
     _template.Regions.Add(caseNumberRegion);
     _template.Regions.Add(plaintiffRegion);
     _template.Regions.Add(attorneyRegion);
     _template.Regions.Add(hearingDateRegion);
 }
示例#2
0
        static void Main(string[] args)
        {
            var template = new OcrTemplate
            {
                CourtId = 1,
                DocumentType = "Case Management Statement",
                OcrTemplateId = 1
            };

            var caseNumberRegion = new OcrRegion(1561, 957, 2291, 1158, OcrRegionName.CaseNumber);
            var plaintiffRegion = new OcrRegion(150, 830, 1640, 1010, OcrRegionName.Plaintiff);
            var attorneyRegion = new OcrRegion(150, 200, 1640, 590, OcrRegionName.Attorney);
            var hearingDateRegion = new OcrRegion(150, 1220, 2291, 1350, OcrRegionName.HearingDate);
            template.Regions.Add(caseNumberRegion);
            template.Regions.Add(plaintiffRegion);
            template.Regions.Add(attorneyRegion);
            template.Regions.Add(hearingDateRegion);

            FileInfo pdfFile = new FileInfo("OLPDFS\\43159219.pdf");


            var pngFile = CloudOcrService.ConvertPdfToPng(pdfFile);

            var results = CloudOcrService.ExtractTemplateFromPdfAsync(pdfFile, template);

            foreach (var str in results.Result)
            {
                
            }
            Console.WriteLine(results.Result.Select(s => s));
            foreach (var region in template.Regions)
            {
                Console.WriteLine(region.RegionName.ToString() + ": " + CloudOcrService.ExtractRegionFromPng(pngFile, region));
            }
            Console.ReadLine();
        }
示例#3
0
        public static string ExtractRegionFromPng(FileInfo pngFile, OcrRegion region)
        {
            var xmlResult = CallOcrWebService(pngFile, region.TopLeftX, region.TopLeftY, region.BottomRightX, region.BottomRightY);

            return(GetOcrTextFromResultXml(xmlResult));
        }
示例#4
0
 public static string ExtractRegionFromPng(FileInfo pngFile, OcrRegion region)
 {
     var xmlResult = CallOcrWebService(pngFile, region.TopLeftX, region.TopLeftY, region.BottomRightX, region.BottomRightY);
     return GetOcrTextFromResultXml(xmlResult);
 }