public static CodeRecognitionResult FromException(Exception ex) { CodeRecognitionResult result = new CodeRecognitionResult() { SuccessfullyProcessedImage = false, Exception = ex }; return(result); }
public static CodeRecognitionResult FromPrediction(ImagePrediction imagePrediction) { CodeRecognitionResult result = new CodeRecognitionResult(); if (imagePrediction == null) { result.SuccessfullyProcessedImage = false; } else { result.SuccessfullyProcessedImage = true; result.PredictionScore = imagePrediction.Score.Max(); result.PredictedLabel = imagePrediction.PredictedLabelValue; } return(result); }
public CodeRecognitionResult Recognize(ImageData imageData) { if (!CanProcessImage) { return(null); } ImagePrediction imagePrediction; try { imagePrediction = _predictionEngine.Predict(imageData); } catch (Exception ex) { return(CodeRecognitionResult.FromException(ex)); } return(CodeRecognitionResult.FromPrediction(imagePrediction)); }