进阶 ai.google.dev 2026-10-15 02:43:21 · 35 阅读

第17章 视频理解

Gemini 4 Argon 现已推出,欢迎试用。

首页

Gemini API

文档

视频理解

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": }. 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) ```

下面展示了进度分类视频的示例帧,模型为视频分配了相应的进度区间:

示例

如需包含多步任务追踪在内的完整可运行示例,请参阅 Robotics cookbook。

后续步骤

面向机器人的 Live API — 实时双向流式传输。 任务编排 — 结合空间推理的长时程任务。 Gemini Robotics ER 概览 — 模型对比与能力介绍。

评论 (0)