private void RecognizeButton_Click(object sender, System.EventArgs e) { try { string output = ""; TextView licensePlateTV = FindViewById <TextView>(Resource.Id.licensePlateTextview); OpenALPR_Results results = OpenALPRInstance.Recognize(TestImagePath); if (results.DidErrorOccur == false) { foreach (var rr in results.FoundLicensePlates) { output += "Best: " + rr.BestLicensePlate + "(" + rr.Confidence + "%)\n"; foreach (var rc in rr.OtherCandidates) { output += "- " + rc.LicensePlate + "(" + rc.Confidence + "%)\n"; } } } else { output = results.Error.Message + ", " + results.Error.Stacktrace; } licensePlateTV.Text = output; Toast.MakeText(this, output, ToastLength.Long).Show(); } catch (Exception ex) { Toast.MakeText(this, ex.Message + ", " + ex.StackTrace, ToastLength.Long).Show(); } }
private void StartCaptureSession() { sessionTask = Task.Factory.StartNew(async() => { while (Interlocked.CompareExchange(ref sessionIsActive, ACTIVE, ACTIVE) == ACTIVE) { var imageBytes = await TakePhoto(); var file = SavePhoto(imageBytes); var results = OpenALPRInstance.Recognize(file.AbsolutePath, 10); string output = ""; if (results.DidErrorOccur == false) { foreach (var rr in results.FoundLicensePlates) { output += "Best: " + rr.BestLicensePlate + "(" + rr.Confidence + "%)\n"; ShowToast(output); } } var delete = true; if (delete) { System.IO.File.Delete(file.AbsolutePath); } } }); }
public AlprKennzeichenEntity Recognize(string imagePath) { var result = new AlprKennzeichenEntity() { TimeStamp = DateTime.Now }; try { if (System.IO.File.Exists(imagePath)) { var recognitionResults = _openALPRInstance.Recognize(imagePath, 5); if (!recognitionResults.DidErrorOccur) { result.FoundLicenses = new List <AlprKennzeichen>(); foreach (var rr in recognitionResults.FoundLicensePlates) { var foundPlate = new AlprKennzeichen() { LicensePlate = rr.BestLicensePlate, Confidence = rr.Confidence }; result.FoundLicenses.Add(foundPlate); } } else { result.ErrorOccured = true; result.ErrorMessage = recognitionResults.Error.Message + ", " + recognitionResults.Error.Stacktrace; } } else { result.ErrorOccured = true; result.ErrorMessage = "Image-Datei wurde nicht gefunden"; } } catch (Exception ex) { result.ErrorOccured = true; result.ErrorMessage = ex.Message; } return(result); }