尝试使用c#asp.net c#使用Google Cloud Vision检测图像值 [英] Trying detect image Values using Google Cloud Vision using c# asp.net c#

查看:69
本文介绍了尝试使用c#asp.net c#使用Google Cloud Vision检测图像值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试使用c#asp.net c#使用Google Cloud Vision检测图像值,但出现错误.

 加载本机库时出错.在任何可能的位置找不到: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文件 

我在下面的行中遇到错误.并尝试打开此网址无效:

解决方案

此错误与Vision API或身份验证无关,这与gRPC无法正确加载有关.听起来您正在使用"Web站点"项目而不是"Web应用程序"项目.这是已知问题-一种解决方法是将相关库复制到bin 目录在开始使用gRPC之前的执行时间,但是我建议不要这样做.

如果可以的话,我建议您改用Web应用程序项目.

Trying detect image Values using Google Cloud Vision using c# asp.net c# but i am getting below error.

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

I am getting error in below line. And tried to open this url is not working: http://vision.googleapis.com

var channel = new Grpc.Core.Channel(@"http://vision.googleapis.com", credential.ToChannelCredentials()); // <-- Getting error in this line 

Below is my design code.

<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>

Below is my code which worte in button click for display in label

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";

    }

}

I used below example url:

Detecting content in Google Cloud Vision for .NET does nothing/hangs app

I created service key account also in google for json file.

解决方案

This error isn't really about the Vision API, or authentication - it's due to gRPC not loading properly. It sounds like you're using a "Web Site" project rather than a "Web Application" project. This is a known issue - there's a workaround of copying the relevant library into the bin directory at execution time before starting to use gRPC, but I'd advise against that.

I'd advise using a Web Application project instead, if you possibly can.

这篇关于尝试使用c#asp.net c#使用Google Cloud Vision检测图像值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆