簡體   English   中英

如何使用 JSON 文件在 C# 中連接谷歌雲視覺 API

[英]How to connect with google cloud vision API in c# with JSON file

  1. 啟用 Cloud Vision API
  2. 從谷歌雲下載JSON文件。

如何將JSON文件與c# windows應用程序連接,並與谷歌雲視覺連接從圖像中讀取文本?

我相信您應該使用與文檔類似的內容:

快速入門:使用客戶端庫

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);
            }
        }
    }
}
          

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM