locked
Hangs Cloud Vision API using Asp.net c# (response is not working) RRS feed

  • Question

  • User-471420332 posted

    Hanging Cloud Vision API using Asp.net c#,

    I am getting hangs in below line.

     var response = client.DetectText(image); // <-- Nothing happens, app hangs, why?

    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 tried below code also using console application but same response is not working is my console code.

        static void Main(string[] args)
        {
    
            var credential = GoogleCredential.FromFile(@"C:\!\Tutorials-0a2efaf1b53c.json");
            var channel = new Grpc.Core.Channel(ImageAnnotatorClient.DefaultEndpoint.ToString(), credential.ToChannelCredentials());
    
            var client = ImageAnnotatorClient.Create(channel);
    
            var image = Google.Cloud.Vision.V1.Image.FromFile(@"C:\!\cat.jpg");
    
            var response = client.DetectLabels(image);
    
            foreach (var annotation in response)
            {
                if (annotation.Description != null)
                    Console.WriteLine(annotation.Description);
            }
    
    
        }
    Wednesday, June 6, 2018 3:34 PM

Answers

  • User283571144 posted

    Hi mazhar khan india,

    According to your description, this issue is realted with the goole cloud version API issue not asp.net issue.

    I suggest you could post this issue on the google support forum.

     https://groups.google.com/forum 

    Best Regards,

    Brando

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, June 7, 2018 5:35 AM