public async Task <ActionResult <CaptureResult> > Get() { _logger.LogInformation("Client requested capture"); try { // Capture from the card Capture capture = new Capture(_logFactory); MemoryStream stream = new MemoryStream(); await capture.CapturePhoto(stream); stream.Position = 0; // For debugging //using FileStream stream = System.IO.File.OpenRead(@"procimages/618f82be-b899-47dd-a7a7-966484772220_original.png"); // OCR and return using Ocr ocr = new Ocr(stream, _logFactory); ocr.Process(); return(Ok(ocr.Result)); } catch (Exception e) { _logger.LogError("Exception during capture", e); return(BadRequest(new { message = e.Message + "\n" + e.StackTrace })); } }
private T ScanCatchOcrFailedExeption <T>(Ocr <T> ocr, Bitmap bitmap, Rectangle r) { try { var result = ocr.Process(bitmap, r); return(result); } catch (OcrFailedException) { return(default(T)); } }
private T Scan <T>(Ocr <T> ocr, Bitmap bitmap, Rectangle r) { var result = ocr.Process(bitmap, r); return(result); }