使用用戶端程式庫為影片加上註解
本快速入門導覽課程將介紹 Video Intelligence API。在本快速入門導覽課程中,您將設定 Google Cloud 專案和授權,然後要求 Video Intelligence 標註影片。
事前準備
- Sign in to your Google Cloud account. If you're new to Google Cloud, create an account to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.
-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
-
Make sure that billing is enabled for your Google Cloud project.
-
Enable the Cloud Video Intelligence API.
-
Install the Google Cloud CLI.
-
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
-
To initialize the gcloud CLI, run the following command:
gcloud init
-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
-
Make sure that billing is enabled for your Google Cloud project.
-
Enable the Cloud Video Intelligence API.
-
Install the Google Cloud CLI.
-
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
-
To initialize the gcloud CLI, run the following command:
gcloud init
安裝用戶端程式庫
Go
go get cloud.google.com/go/videointelligence/apiv1
Java
Node.js
安裝程式庫前,請確認您已設定適當的 Node.js 開發環境。
npm install @google-cloud/video-intelligence
Python
安裝程式庫前,請確認您已設定適當的 Python 開發環境。
pip install --upgrade google-cloud-videointelligence
其他語言
C#: 請按照用戶端程式庫頁面上的 C# 設定說明操作, 然後參閱 .NET 適用的 Video Intelligence 參考說明文件。
PHP: 請按照用戶端程式庫頁面的 PHP 設定說明 操作,然後前往 PHP 適用的 Video Intelligence 參考文件。
Ruby: 請按照用戶端程式庫頁面的 Ruby 設定說明 操作,然後前往 Ruby 適用的 Video Intelligence 參考說明文件。
設定驗證方法
-
After installing the Google Cloud CLI, initialize it by running the following command:
gcloud init
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
-
If you're using a local shell, then create local authentication credentials for your user account:
gcloud auth application-default login
You don't need to do this if you're using Cloud Shell.
If an authentication error is returned, and you are using an external identity provider (IdP), confirm that you have signed in to the gcloud CLI with your federated identity.
畫面上會顯示登入畫面。登入後,您的憑證會儲存在 ADC 使用的 本機憑證檔案中。
標籤偵測
現在您可以使用 Video Intelligence API 要求取得影片或影片片段的資訊,例如標籤偵測。執行下列程式碼,即可進行您的第一個影片標籤偵測要求:
Go
Java
Node.js
執行範例前,請確認已設定適當的 Node.js 開發環境。
Python
執行範例前,請確認已設定適當的 Python 開發環境。
其他語言
C#: 請按照用戶端程式庫頁面上的 C# 設定說明操作, 然後參閱 .NET 適用的 Video Intelligence 參考說明文件。
PHP: 請按照用戶端程式庫頁面的 PHP 設定說明 操作,然後前往 PHP 適用的 Video Intelligence 參考文件。
Ruby: 請按照用戶端程式庫頁面的 Ruby 設定說明 操作,然後前往 Ruby 適用的 Video Intelligence 參考說明文件。
恭喜!您已將第一個要求傳送至 Video Intelligence API。
還順利嗎?
清除所用資源
如要避免系統向您的 Google Cloud 帳戶收取本頁所用資源的費用,請按照下列步驟操作。
- 請透過 Google Cloud console 刪除不需要的專案。