Пример #1
0
        // SoftwareBitmap を OCR に掛ける
        private async Task RecognizeBitmapAsync(UwpSoftwareBitmap bitmap)
        {
            this.RecognizedTextTextBox.Text = string.Empty;

            var          ocrEngine = UwpOcrEngine.TryCreateFromLanguage(this.LangComboBox.SelectedItem as UwpLanguage);
            UwpOcrResult ocrResult = await ocrEngine.RecognizeAsync(bitmap);

            foreach (var ocrLine in ocrResult.Lines)
            {
                this.RecognizedTextTextBox.Text += (ocrLine.Text + "\n");
            }
        }
Пример #2
0
        public void SetOcrLanguage(string language)
        {
            OcrLanguages langus = new OcrLanguages();
            string       tag    = langus.GetTag(language);

            ocrLanguage = new UwpLanguage(tag);
            engine      = UwpOcrEngine.TryCreateFromLanguage(ocrLanguage);

            if (engine == null)
            {
                ocrLanguage = null;
                throw new InvalidOperationException(errMsgFailedToSetLanguage);
            }
        }