问题
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.
回答1:
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.
来源:https://stackoverflow.com/questions/50715542/trying-detect-image-values-using-google-cloud-vision-using-c-sharp-asp-net-c-sha