Gemini 中文指南
获取 API 密钥 ↗

视频理解

↓ 下载 Markdown

Gemini Robotics ER 2 可以使用两种功能跟踪连续视频源的任务进度:

  • 时刻查找:识别关键事件发生的精确时间戳。
  • 进度分类:将每个视频分配到五个完成括号之一(0–20%、20–40%、40–60%、60–80%、 80–100%)。

瞬间发现 #

瞬间查找可识别发生关键事件的确切视频帧 - 例如,当杯子满了或打结时。机器人用它来验证成功、排序步骤并触发更正。

以下示例提示要求模型识别视频中给定任务的完成时刻:

python
from google import genai

client = genai.Client()

uploaded_file = client.files.upload(file="task_video.mp4")

prompt = """
At what timestamp (in seconds) does the task reach successful completion?
Return a JSON object: {"completion_time_seconds": <float>}.
If the task is not completed, return {"completion_time_seconds": null}.
"""

interaction = client.interactions.create(
    model="gemini-robotics-er-2-preview",
    input=[
        {
            "type": "video",
            "uri": uploaded_file.uri,
            "mime_type": uploaded_file.mime_type
        },
        {"type": "text", "text": prompt}
    ],
)

print(interaction.output_text)

下面显示了时刻查找视频中的示例帧,其中模型识别任务完成时间戳:

进度分类 #

进度分类将视频分配到五个完成括号之一:0–20%、20–40%、40–60%、60–80%,或80–100%。这为机器人提供了实时态势感知能力,因此它们可以调整操作或重试失败的步骤,而无需重新启动整个工作流程。

以下示例提示要求模型对视频的当前进度级别进行分类:

python
from google import genai

client = genai.Client()

uploaded_file = client.files.upload(file="task_video.mp4")

prompt = """
Watch this video and classify the task progress level at the final frame.
Return a JSON object with the progress bracket:
{"progress_level": "0-20" | "20-40" | "40-60" | "60-80" | "80-100"}.
"""

interaction = client.interactions.create(
    model="gemini-robotics-er-2-preview",
    input=[
        {
            "type": "video",
            "uri": uploaded_file.uri,
            "mime_type": uploaded_file.mime_type
        },
        {"type": "text", "text": prompt}
    ],
)

print(interaction.output_text)

下面显示了进度分类视频中的示例帧,其中模型分配了进度括号:

示例 #

有关包括多步骤任务跟踪的完整可运行示例,请参阅 机器人食谱.

后续步骤 #

搜索标题、API 名称或正文内容