# 视频理解

{% callout type="note" %}
视频理解需要Gemini Robotics ER 2（`gemini-robotics-er-2-preview`）。 ER 1.6. 上不可用
{% /callout %}

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

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

## 瞬间发现  {% #moment-finding %}

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

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

```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)
```

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

![](https://www.gstatic.com/cloud-cms/0d2c507f7f0c9e70b859bd31bf829b9e.png)

## 进度分类  {% #progress-classification %}

进度分类将视频分配到五个完成括号之一：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)
```

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

![](https://www.gstatic.com/cloud-cms/4c93b6e1b473ca3307b8ceeaabef7e63.png)

## 示例  {% #full-examples %}

有关包括多步骤任务跟踪的完整可运行示例，请参阅 [机器人食谱](https://github.com/google-gemini/robotics-samples/blob/main/Getting%20Started/gemini_robotics_er.ipynb).

## 后续步骤  {% #whats-next %}

* [用于机器人技术的 Live API](/docs/robotics-streaming) — 实时双向流。
* [任务编排](/docs/robotics-orchestration) - 具有空间推理的长视野任务。
* [Gemini Robotics ER概述](/docs/robotics-overview) — 模型比较和功能。
