Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用JSON文件在c#中连接google cloud vision API 启用了云视觉API 从谷歌云下载了JSON文件_C# - Fatal编程技术网

如何使用JSON文件在c#中连接google cloud vision API 启用了云视觉API 从谷歌云下载了JSON文件

如何使用JSON文件在c#中连接google cloud vision API 启用了云视觉API 从谷歌云下载了JSON文件,c#,C#,如何将JSON文件与c#windows应用程序连接,以及如何与从图像读取文本的Google cloud vision连接?我认为您应该使用与文档类似的内容: using Google.Cloud.Vision.V1; using System; namespace GoogleCloudSamples { public class QuickStart { public static void Main(string[] args) {

如何将JSON文件与c#windows应用程序连接,以及如何与从图像读取文本的Google cloud vision连接?

我认为您应该使用与文档类似的内容:

using Google.Cloud.Vision.V1;
using System;

namespace GoogleCloudSamples
{
    public class QuickStart
    {
        public static void Main(string[] args)
        {

            // jsonPath is the path to the key.json file 
            var credential = GoogleCredential.FromFile(jsonPath); 
            // Instantiates a client
            var client = ImageAnnotatorClient.Create(credential);
            // Load the image file into memory
            var image = Image.FromFile("wakeupcat.jpg");
            // Performs label detection on the image file
            var response = client.DetectLabels(image);
            foreach (var annotation in response)
            {
                if (annotation.Description != null)
                    Console.WriteLine(annotation.Description);
            }
        }
    }
}