クライアント ライブラリを使用して動画にアノテーションを付ける
このクイックスタートでは、Video Intelligence API について説明します。このクイックスタートでは、 Google Cloud プロジェクトと承認を設定してから、Video Intelligence に動画のアノテーションをリクエストします。
始める前に
- Google Cloud アカウントにログインします。 Google Cloudを初めて使用する場合は、 アカウントを作成して、実際のシナリオでの Google プロダクトのパフォーマンスを評価してください。新規のお客様には、ワークロードの実行、テスト、デプロイができる無料クレジット $300 分を差し上げます。
-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
Roles required to select or create a project
- Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
-
Create a project: To create a project, you need the Project Creator role
(
roles/resourcemanager.projectCreator), which contains theresourcemanager.projects.createpermission. Learn how to grant roles.
-
Verify that billing is enabled for your Google Cloud project.
Enable the Cloud Video Intelligence API.
Roles required to enable APIs
To enable APIs, you need the Service Usage Admin IAM role (
roles/serviceusage.serviceUsageAdmin), which contains theserviceusage.services.enablepermission. Learn how to grant roles.-
Google Cloud CLI をインストールします。
-
外部 ID プロバイダ(IdP)を使用している場合は、まず連携 ID を使用して gcloud CLI にログインする必要があります。
-
gcloud CLI を初期化するには、次のコマンドを実行します。
gcloud init -
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
Roles required to select or create a project
- Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
-
Create a project: To create a project, you need the Project Creator role
(
roles/resourcemanager.projectCreator), which contains theresourcemanager.projects.createpermission. Learn how to grant roles.
-
Verify that billing is enabled for your Google Cloud project.
Enable the Cloud Video Intelligence API.
Roles required to enable APIs
To enable APIs, you need the Service Usage Admin IAM role (
roles/serviceusage.serviceUsageAdmin), which contains theserviceusage.services.enablepermission. Learn how to grant roles.-
Google Cloud CLI をインストールします。
-
外部 ID プロバイダ(IdP)を使用している場合は、まず連携 ID を使用して gcloud CLI にログインする必要があります。
-
gcloud CLI を初期化するには、次のコマンドを実行します。
gcloud init
クライアント ライブラリをインストールする
Go
go get cloud.google.com/go/videointelligence/apiv1
Java
Maven を使用している場合は、次のものを pom.xml ファイルに追加します。BOM の詳細については、Google Cloud Platform ライブラリ BOM をご覧ください。
Gradle を使用している場合は、次のものを依存関係に追加します。
sbt を使用している場合は、次のものを依存関係に追加します。
Visual Studio Code または IntelliJ を使用している場合は、次の IDE プラグインでプロジェクトにクライアント ライブラリを追加できます。
プラグインでは、サービス アカウントのキー管理などの追加機能も提供されます。詳細は各プラグインのドキュメントをご覧ください。
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 のリファレンス ドキュメントをご覧ください。
認証を設定する
-
Google Cloud CLI をインストールします。インストール後、次のコマンドを実行して Google Cloud CLI を初期化します。
gcloud init外部 ID プロバイダ(IdP)を使用している場合は、まず連携 ID を使用して gcloud CLI にログインする必要があります。
-
ローカルシェルを使用している場合は、ユーザー アカウントのローカル認証情報を作成します。
gcloud auth application-default login
Cloud Shell を使用している場合は、この操作を行う必要はありません。
認証エラーが返され、外部 ID プロバイダ(IdP)を使用している場合は、 連携 ID を使用して gcloud CLI にログインしていることを確認します。
ログイン画面が表示されます。ログインすると、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 に最初のリクエストが送信されました。
いかがでしたか
クリーンアップ
このページで使用したリソースについて、 Google Cloud アカウントに課金されないようにするには、次の手順を実施します。
- 不要になったプロジェクトを Google Cloud console で削除します。