public async Task <IActionResult> RegistrarPaper([FromBody] PaperResource resource)
        {
            var           paper  = _mapper.Map <PaperResource, Paper>(resource);
            PaperResponse result = await _paperUseCase.RegistrarPaper(paper);

            if (!result.Success)
            {
                return(BadRequest(new ErrorResource(result.Message)));
            }

            var paperResource = _mapper.Map <Paper, PaperResource>(result.Resource);

            return(Ok(new { mensaje = "Guardado satisfactoriamente", paperResource }));
        }
Ejemplo n.º 2
0
        public List <Dictionary <string, string> > GetUtf8TextBaseOnRegions(IImage image, ROIProfile regions, out IImage imgdrawed)
        {
            imgdrawed = null;
            List <Dictionary <string, string> > result = new List <Dictionary <string, string> >();

            if (image == null)
            {
                return(result);
            }

            if (regions == null)
            {
                return(result);
            }

            IPaperResource paperResource = PaperResource.DefaultInstance();
            PaperProfile   paperProfile  = paperResource.GetPaperProfile(regions.PaperSize);

            if (paperProfile == null)
            {
                return(result);
            }

            InitialLaguagePack(regions);
            Dictionary <string, string> onePage     = new Dictionary <string, string>();
            Image <Gray, byte>          imgOriginal = image is Image <Gray, byte>?image as Image <Gray, byte> : new Image <Gray, byte>(image.Bitmap);
            Image <Bgr, byte>           imgColor    = imgOriginal.Copy().Convert <Bgr, byte>();

            foreach (ROI region in regions.Regions)
            {
                Rectangle rect = region.RegionRectangle.ConvertActualyImageSizeToImageResize(paperProfile, imgOriginal.Bitmap);
                imgOriginal.ROI = rect;
                imgColor.Draw(rect, new Bgr(Color.Red), 1);
                _tesseracts[region.Language].SetImage(imgOriginal.Copy());
                string          txt = _tesseracts[region.Language].GetUTF8Text();
                MatchCollection ms  = Regex.Matches(txt, region.GenaratedRegexPattern, RegexOptions.Multiline);
                Match           m   = ms.Cast <Match>().OrderByDescending(s => s.Length).Take(1).FirstOrDefault();
                onePage.Add(region.RegionName, m?.Value);
                imgOriginal.ROI = Rectangle.Empty;
            }
            imgdrawed = imgColor;
            result.Add(onePage);
            return(result);
        }