private void OnOcrCompleted(OcrServiceResult result)
        {
            if (result.Status == Status.Success)
            {
                int           wordCount = 0;
                StringBuilder sb        = new StringBuilder();
                foreach (OcrText item in result.OcrResult.OcrTexts)
                {
                    wordCount += item.Words.Count;
                    sb.Append(item.Text);
                    sb.Append("\n");
                }

                if (wordCount > 0)
                {
                    MessageBox.Show(sb.ToString());
                }
            }
        }
Пример #2
0
        private void OnOcrCompleted(OcrServiceResult result)
        {
            _progressIndicator.IsVisible = true;
            _progressIndicator.Text      = "Trwa przeszukiwanie kwot...";
            _ocrResultList.Clear();
            if (result.Status == Status.Success)
            {
                //int wordCount = 0;

                string pattern = @"[1-9][0-9]{0,2}(?:,?[0-9]{3}){0,3}\.[0-9]{2}";
                Regex  r       = new Regex(pattern);

                foreach (OcrText item in result.OcrResult.OcrTexts)
                {
                    //wordCount += item.Words.Count;

                    _ocrResultList.Add(String.Empty);
                    MatchCollection mc = r.Matches(item.Text);
                    foreach (var ocrText in mc)
                    {
                        _ocrResultList.Add(ocrText.ToString());
                    }
                }
                _progressIndicator.IsVisible = false;
                if (_ocrResultList.Count > 1)
                {
                    lpkOcrResult.Visibility  = Visibility.Visible;
                    lpkOcrResult.ItemsSource = _ocrResultList;
                }
                else
                {
                    lpkOcrResult.Visibility = Visibility.Collapsed;
                }
            }
            else
            {
                _progressIndicator.IsVisible = false;
                MessageBox.Show("Nie przetworzono obrazu - wystąpił błąd OCR", "", MessageBoxButton.OK);
            }
        }
Пример #3
0
        private void OnOcrCompleted(OcrServiceResult result)
        {
            string address = " ";

            Debug.Assert(result != null, "result is null");

            if (result.Status == Status.Success)
            {
                this.ocrData.SetOcrResult(result.OcrResult.OcrTexts);

                if (this.ocrData.GetWordCount() > 0)
                {
                    int           wordcount = 0;
                    StringBuilder sb        = new StringBuilder();
                    // TODO TO STRING
                    foreach (OcrText ocr in result.OcrResult.OcrTexts)
                    {
                        address   += ocr.Text;
                        wordcount += ocr.Words.Count;
                        Debug.WriteLine(ocr.Text);
                        sb.Append(ocr.Text); // ocr text
                    }
                    this.ocrConversionStateManager.OcrConversionState = OcrConversionState.ConversionOK;
                }
                else
                {
                    this.ocrConversionStateManager.OcrConversionState = OcrConversionState.ConversionEmpty;
                }
            }
            else
            {
                this.ocrConversionStateManager.OcrConversionState        = OcrConversionState.ConversionError;
                this.ocrConversionStateManager.OcrConversionErrorMessage = result.Exception.Message;
            }

            NavigationService.Navigate(new Uri("/AddressPlotting.xaml?from=button" + "&longitude=" + address, UriKind.RelativeOrAbsolute));
        }
Пример #4
0
        private void OnOcrCompleted(OcrServiceResult result)
        {
            cardText = result;

            if (result.Status == Status.Success)
            {
                int wordCount = 0;
                StringBuilder sb = new StringBuilder();
                foreach (OcrText item in result.OcrResult.OcrTexts)
                {
                    wordCount += item.Words.Count;
                    sb.Append(item.Text);
                    sb.Append("\n");
                }

                if (wordCount > 0)
                {
                    this.textBlock5.Text = sb.ToString();
                }
                else
                {
                    this.textBlock5.Text = "ERROR: We were unable to read this card. Please check the quality of the image and try again.";
                }
            }
            else
            {
                this.textBlock5.Text = "ERROR: " + result.Exception.Message;
            }

            this.button2.IsEnabled = true;
            this.button3.IsEnabled = true;
        }
        private void OnOcrCompleted(OcrServiceResult result)
        {
            string address = " ";
            Debug.Assert(result != null, "result is null");

            if (result.Status == Status.Success)
            {
                this.ocrData.SetOcrResult(result.OcrResult.OcrTexts);

                if (this.ocrData.GetWordCount() > 0)
                {
                    int wordcount = 0;
                    StringBuilder sb = new StringBuilder();
                    // TODO TO STRING
                    foreach (OcrText ocr in result.OcrResult.OcrTexts)
                    {
                        address += ocr.Text;
                        wordcount += ocr.Words.Count;
                        Debug.WriteLine(ocr.Text);
                        sb.Append(ocr.Text); // ocr text
                    }
                    this.ocrConversionStateManager.OcrConversionState = OcrConversionState.ConversionOK;
                }
                else
                {
                    this.ocrConversionStateManager.OcrConversionState = OcrConversionState.ConversionEmpty;
                }
            }
            else
            {
                this.ocrConversionStateManager.OcrConversionState = OcrConversionState.ConversionError;
                this.ocrConversionStateManager.OcrConversionErrorMessage = result.Exception.Message;
            }

            NavigationService.Navigate(new Uri("/AddressPlotting.xaml?from=button" + "&longitude=" + address, UriKind.RelativeOrAbsolute));
           
        }