Microsoft ProjectOxford Vision API ClientException 错误
Posted
技术标签:
【中文标题】Microsoft ProjectOxford Vision API ClientException 错误【英文标题】:Microsoft ProjectOxford Vision API ClientException Error 【发布时间】:2017-08-10 12:55:17 【问题描述】:我正在研究 MS 的新 API,但在学习教程时遇到了错误。 这是我的完整代码。我试图用这个来获得图像的颜色。 我得到的回报是“错误返回 CV”所以我没有得到 null imageStream 也不分析结果。 先感谢您!
namespace UWPApp1
public sealed partial class MainPage : Page
IRandomAccessStream imageStream;
const string APIKEY_CV = [MyComputerVisionKeyComesHere];
VisionServiceClient VisionClient = new VisionServiceClient(APIKEY_CV);
AnalysisResult analysisResult;
public MainPage()
this.InitializeComponent();
private async void button_Click(object sender, RoutedEventArgs e)
try
FileSavePicker fileSavePicker = new FileSavePicker();
fileSavePicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
fileSavePicker.FileTypeChoices.Add("JPEG files", new List<string>() ".jpg" );
fileSavePicker.SuggestedFileName = "image";
var outputFile = await fileSavePicker.PickSaveFileAsync();
if (outputFile == null)
// The user cancelled the picking operation
return;
imageStream = await outputFile.OpenAsync(FileAccessMode.Read);
BitmapImage imageTest = new BitmapImage();
imageTest.SetSource(imageStream);
image.Source = imageTest;
catch
textBox.Text = "Error taking photo";
private async void button1_Click(object sender, RoutedEventArgs e)
try
VisualFeature[] feature = new VisualFeature[] VisualFeature.Tags, VisualFeature.Description, VisualFeature.Color ;
analysisResult = await VisionClient.AnalyzeImageAsync(imageStream.AsStream(), feature);
if (analysisResult != null)
var color = analysisResult.Color;
textBox.Text = "The Accent Color is" + color.AccentColor;
else
textBox.Text = "analysisResult is null";
catch
textBox.Text = "Error Return CV";
【问题讨论】:
【参考方案1】:Project oxford vision API ocr exception
我用同样的方法解决了。 我添加了 imageStream.Seek(0);在我的代码中
【讨论】:
以上是关于Microsoft ProjectOxford Vision API ClientException 错误的主要内容,如果未能解决你的问题,请参考以下文章
Project oxford vision API ocr异常
Microsoft 认知服务视觉 API ClientException 错误
未找到导入的项目“C:\Program Files\dotnet\sdk\2.1.201\Microsoft\VisualStudio\v15.0\WebApplications\Microsoft.
Microsoft.ReportViewer.WinForms.V15 与 .NET Core 3.1 不兼容 - 如何在 WPF Core 中显示 RDLC?