Exemplo n.º 1
0
        public ActionResult Card(int id)
        {
            //TODO inject these
            IImageTextProcessor    processor = new GoogleImageTextProcessor();
            IProcessorResultMapper mapper    = new GoogleTextDetectionMapper();

            var results = processor.GetResultsForImage(pics[id], false);
            var dto     = mapper.MapResultsToDto(results);

            dto.ImageUrl = pics[id];

            var rtn = new JsonResult();

            rtn.JsonRequestBehavior = JsonRequestBehavior.AllowGet;
            rtn.Data = dto;

            return(rtn);
        }
Exemplo n.º 2
0
        public IHttpActionResult PostCard([FromBody] string pic)
        {
            byte[] img = Convert.FromBase64String(pic);
            //string path = $"C:\\Users\\David Appel\\Pictures\\{DateTime.Now.Ticks.ToString()}.jpg";
            //var stream = File.Create(path);
            //stream.Write(img, 0, img.Length);
            //stream.Close();
            //stream.Dispose();

            //TODO inject these
            IImageTextProcessor    processor = new GoogleImageTextProcessor();
            IProcessorResultMapper mapper    = new GoogleTextDetectionMapper();

            var results = processor.GetResultsForImage(img);
            var dto     = mapper.MapResultsToDto(results);

            //dto.ImageUrl = S3Service.UploadFileAsync(img, $"{dto.CarrierName}.jpg").Result;

            return(Ok <DtoInsuranceCard>(dto));
        }
Exemplo n.º 3
0
        public void TestGetLinesReturnsProperlySplitLines()
        {
            List <string> expected = new List <string>();

            expected.Add("aetna");
            expected.Add("Managed Choice");
            expected.Add("NAME");

            DtoGoogleTextDetection dto = new DtoGoogleTextDetection();

            dto.Words = new List <TextNode>()
            {
                new TextNode
                {
                    locale       = "en",
                    boundingPoly = new BoundingPoly(),
                    description  = "aetna NrDP\nBeschast\nStreet\nADP TOTALSOURCE, INC\nA more human resource?\nGRP: 326321-018-00020\nIssuer (80840) 9140860054\nManaged Choice\nOpen Access\nID W2434 86188\nNAME\n01 DAVID L APPEL\n02 KIRSTEN LOGAN\nPCP NO ELECTION REQUIRED\nPCP: NO ELECTION REQUIRED\nRX BIN# 6 1 0502\naetna NrDP\nBeschast\nStreet\nADP TOTALSOURCE, INC\nA more human resource?\nGRP: 326321-018-00020\nIssuer (80840) 9140860054\nManaged Choice\nOpen Access\nID W2434 86188\nNAME\n01 DAVID L APPEL\n02 KIRSTEN LOGAN\nPCP NO ELECTION REQUIRED\nPCP: NO ELECTION REQUIRED\nRX BIN# 6 1 0502\n"
                },
                new
                TextNode
                {
                    boundingPoly = new BoundingPoly(),
                    description  = "aetna"
                }
            };

            GoogleTextDetectionMapper mapper = new GoogleTextDetectionMapper();
            var results = mapper.GetLines(dto);

            foreach (var item in expected)
            {
                var line = results.Where(l => l == item).First();
                Assert.IsNotNull(line);
            }

            Assert.IsNull(results.Where(l => l.Contains("\n")).FirstOrDefault());
        }