maz*_*124 0 c# asp.net google-cloud-vision
尝试使用c#asp.net c#使用Google Cloud Vision检测图像值,但我收到以下错误.
Error loading native library. Not found in any of the possible locations: C:\Users\mazharkhan\Documents\Visual Studio 2013\WebSites\googleapi\bin\grpc_csharp_ext.x86.dll,C:\Users\mazharkhan\Documents\Visual Studio 2013\WebSites\googleapi\bin\runtimes/win/native\grpc_csharp_ext.x86.dll,C:\Users\mazharkhan\Documents\Visual Studio 2013\WebSites\googleapi\bin\../..\runtimes/win/native\grpc_csharp_ext.x86.dll
Run Code Online (Sandbox Code Playgroud)
我在下面收到错误.并尝试打开此网址无效:http://vision.googleapis.com
var channel = new Grpc.Core.Channel(@"http://vision.googleapis.com", credential.ToChannelCredentials()); // <-- Getting error in this line
Run Code Online (Sandbox Code Playgroud)
下面是我的设计代码.
<form id="form1" runat="server">
<div>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
</div>
<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
</form>
Run Code Online (Sandbox Code Playgroud)
下面是我的代码,按下按钮点击标签显示
protected void Button1_Click(object sender, EventArgs e)
{
var image = Google.Cloud.Vision.V1.Image.FromFile(@"C:\!\cat.jpg");
var credential = GoogleCredential.FromFile(@"C:\!\Tutorials-0a2efaf1b53c.json");
var channel = new Grpc.Core.Channel(@"http://vision.googleapis.com", credential.ToChannelCredentials()); // <-- Getting error in this line
var client = ImageAnnotatorClient.Create(channel);
var response = client.DetectText(image);
foreach (var annotation in response)
{
if (annotation.Description != null)
// Console.WriteLine(annotation.Description);
Label1.Text += annotation.Description + "\r\n";
}
}
Run Code Online (Sandbox Code Playgroud)
我用下面的例子url:
检测Google Cloud Vision for .NET中的内容不会导致应用程序挂起
我也在谷歌的json文件中创建了服务密钥帐户.
此错误与Vision API或身份验证无关 - 这是由于gRPC无法正确加载.听起来你正在使用"网站"项目而不是"Web应用程序"项目.这是一个已知问题 - bin在开始使用gRPC之前,有一种解决方法是在执行时将相关库复制到目录中,但我建议不要这样做.
如果可能的话,我建议使用Web应用程序项目.
| 归档时间: |
|
| 查看次数: |
908 次 |
| 最近记录: |