public async Task <IActionResult> OcrDocument(string fileName, Region[] data) { var ocrImage = new OcrImage(Path.Combine(filePath, fileName)); var result = await ocrImage.IdentifyData(data.Select(x => new Rectangle((int)x.TopLeft.X, (int)x.TopLeft.Y, (int)x.Width, (int)x.Height))); return(Ok(result)); }
private OcrTemplate FindTemplate(OcrImage ocrImage) { foreach (var t in Templates.GetTemplates()) { var idFields = t.IdentificationData.ToRecs(); if (ocrImage.IdentifyData(idFields).ToList()[0].ToLower() == t.TemplateDescription.Replace("Template", "").ToLower()) { return(t); } } throw new Exception("Unable to find a template that match the document"); }