Xamarin Microsoft Oxford Vision文本识别问题

时间:2018-11-11 17:13:11

标签: android xamarin text computer-vision

我在使用带有Xamarin.Forms的Microsoft Oxford Vision收据中的文本识别时遇到问题。

这是一个代码:

private async void BtnTake_Clicked(object sender, EventArgs e)
    {
        try
        {
            var photo = await TakePic();

            Image = ImageSource.FromStream(() => photo.GetStream());

            var result = client.RecognizeTextAsync(photo.GetStream()).Result;
            var words = from r in result.Regions
                        from l in r.Lines
                        from w in l.Words
                        select w.Text;

            OutputText = string.Join(" ", words.ToArray());

            await Navigation.PushAsync(new TextFromPhoto(OutputText, Image));
        }
        catch (Exception ex)
        {
            OutputText = "Ops! Something wrong!" + ex.ToString();
            await Navigation.PushAsync(new TextFromPhoto(OutputText, Image));
        }
    }

    private async Task<MediaFile> TakePic()
    {
        var file = await CrossMedia.Current.TakePhotoAsync(new StoreCameraMediaOptions
        {
            SaveToAlbum = true,
            PhotoSize = PhotoSize.Medium
        });

        return file;
    }

代码可以完美地处理普通文本,例如书本照片页,这是我在应用程序中使用的,但是当我尝试使用它来扫描收据程序中的文本时,在输出上,我们可以看到“ 513nlkm nlmnl l1mk 531”或类似的内容。

当我有“普通”文字时的照片:

enter image description here

有收据文字的照片:

enter image description here

是否有解决此问题的行之有效的方法?

0 个答案:

没有答案
相关问题