Azure-Samples / Azure-Samples/cognitive-services-quickstart-code

ComputerVisionClient Error or Bug - ReadInStreamAsync method: 'Invalid URI format' in Xamarin.Forms

Đang mở
#307 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Jupyter Notebook
Star
389
Fork
556
Merge trung bình
3 ngày 12 giờ
Pull request đã merge (30 ngày)
1

Mô tả

> Please provide us with the following information:
> ---------------------------------------------------------------

### This issue is for a: (mark with an `x`)
```
- [x ] bug report -> please search issues before submitting
- [ ] feature request
- [ ] documentation issue or request
- [ ] regression (a behavior that used to work and stopped in a new release)
```

### Minimal steps to reproduce
> I am capturing a photo and opening a stream using Xamarin.Essentials 1.7 MediaPicker built into Essentials.
When I call the ReadInStreamAsync(stream) method in Computer Vision Client, I get an error and my Xamarin.Forms app breaks inside the method: 'Invalid URI: The format of the URI could not be determined.'
This is the stream.Name value - '/data/user/0/com.companyname.xamphotoappdemo2/cache/2203693cc04e0be7f4f024d5f9499e13/198fd32db9cc4be38a493325974fa138/d964251252fc4963aca94339d73a8007.jpg'

var stream = await file.OpenReadAsync();

chosenImage.Source = ImageSource.FromStream(() => stream);

// 2. Add OCR logic.

var client = Authenticate(ApiSettings.subscriptionKey, ApiSettings.endpoint);

var text = await client.ReadInStreamAsync(stream);

//after the request, get the operation location
string operationLocation = text.OperationLocation;

//we only need the operation ID, not the whole URL
const int numberOfCharsInOperationId = 36;
string operationId = operationLocation.Substring(operationLocation.Length - numberOfCharsInOperationId);

//Get the ocr read results
ReadOperationResult results;
do
{
results = await client.GetReadResultAsync(Guid.Parse(operationId));
}
while ((results.Status == OperationStatusCodes.Running || results.Status == OperationStatusCodes.NotStarted));

var readResults = results.AnalyzeResult.ReadResults;

var expirationDates = from page in readResults
from line in page.Lines
where line.Text.Contains("EXPIRES") && line.Words.Count == 4
select line.Words[3].Text;

expirationDate.Text = expirationDates.ToString();

### Any log messages given by the failure
>

### Expected/desired behavior
> The text should be read in from the image and display on the Xaml page control.

### OS and Version?
> Windows 7, 8 or 10. Linux (which distribution). macOS (Yosemite? El Capitan? Sierra?)

### Versions
>

### Mention any other details that might be useful

> ---------------------------------------------------------------
> Thanks! We'll be in touch soon.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Hướng nghiên cứu

Issue không nêu tệp hoặc bài kiểm thử nào trong repository; hãy bắt đầu với lệnh gọi Xamarin.Forms đến ComputerVisionClient.ReadInStreamAsync và giá trị stream.Name được báo cáo. Tái hiện lỗi Invalid URI bằng stream MediaPicker được cung cấp, sau đó xác minh rằng OCR đọc được hình ảnh và trả về văn bản mà không xảy ra exception.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
csharp
Lĩnh vực
computer-vision, mobile-dev
Loại issue
Lỗi
Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
35/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.