使用客户端库为视频添加注释
本快速入门为您介绍 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 发送了第一个请求。
结果怎么样?
清理
为避免因本页中使用的资源导致您的 Google Cloud 账号产生费用,请按照以下步骤操作。
- 使用 Google Cloud console 删除您不需要的项目。