示例#1
0
        public async Task RecognizeTextAsync()
        {
            try
            {
                if (this.ImageUrl != null)
                {
                    this.OcrResults = await VisionServiceHelper.RecognizeTextAsync(this.ImageUrl);
                }
                else if (this.GetImageStreamCallback != null)
                {
                    this.OcrResults = await VisionServiceHelper.RecognizeTextAsync(this.GetImageStreamCallback);
                }
            }
            catch (Exception e)
            {
                this.OcrResults = new Microsoft.ProjectOxford.Vision.Contract.OcrResults();

                if (this.ShowDialogOnFaceApiErrors)
                {
                    await ErrorTrackingHelper.GenericApiCallExceptionHandler(e, "Vision API failed.");
                }
            }
            finally
            {
                this.OcrAnalysisCompleted?.Invoke(this, EventArgs.Empty);
            }
        }
示例#2
0
        public async Task RecognizeTextAsync(TextRecognitionMode textRecognitionMode)
        {
            try
            {
                this.TextRecognitionMode = textRecognitionMode;
                if (this.ImageUrl != null)
                {
                    this.TextOperationResult = await VisionServiceHelper.RecognizeTextAsync(this.ImageUrl, textRecognitionMode);
                }
                else if (this.GetImageStreamCallback != null)
                {
                    this.TextOperationResult = await VisionServiceHelper.RecognizeTextAsync(this.GetImageStreamCallback, textRecognitionMode);
                }
            }
            catch (Exception ex)
            {
                ErrorTrackingHelper.TrackException(ex, "Vision API RecognizeTextAsync error");

                this.TextOperationResult = new TextOperationResult();

                if (this.ShowDialogOnFaceApiErrors)
                {
                    await ErrorTrackingHelper.GenericApiCallExceptionHandler(ex, "Vision API failed.");
                }
            }
            finally
            {
                this.TextRecognitionCompleted?.Invoke(this, EventArgs.Empty);
            }
        }