> For the complete documentation index, see [llms.txt](https://docs.convai.com/api-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/convai-unreal-engine-plugin/features/vision/vision-quick-start.md).

# 视觉快速开始

我们将添加一个 **环境摄像头** 组件到现有的 Convai 角色中，分配一个渲染目标，并从以下位置开始捕获： **Event BeginPlay**。最终，在编辑器中运行（Play In Editor）时，角色应对捕获组件前方可见的内容做出响应。

### 前提条件

* Convai Unreal Engine 插件版本 <code class="expression">space.vars.unreal\_plugin\_version</code> 已安装并启用。请参见 [安装插件](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unreal-engine-plugin/getting-started/install-the-convai-plugin.md) （如有需要）。
* 您的 API 密钥已配置。请参见 [配置 API 密钥](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unreal-engine-plugin/getting-started/configure-your-api-key.md).
* 您的关卡中有一个角色，带有一个 **Convai 聊天机器人** 组件（`UConvaiChatbotComponent`）以及一个有效的 `CharacterID`。参见 [添加你的第一个 Convai 角色](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unreal-engine-plugin/getting-started/add-your-first-convai-character.md) 如果你尚未完成该设置。
* 一个 **Convai Player** 组件（`UConvaiPlayerComponent`）已存在，因此您可以在编辑器中运行（Play In Editor）时开始对话。

{% hint style="info" %}
Vision 使用的是从角色视角进行的场景捕获，而不是物理设备摄像头。随附的组件是 **环境摄像头** (`UEnvironmentWebcam`).
{% endhint %}

{% stepper %}
{% step %}

#### 打开角色蓝图

在 **内容浏览器**，双击您的 Convai 角色的蓝图以打开蓝图编辑器。
{% endstep %}

{% step %}

#### 添加环境摄像头组件

在 **Components** 面板，单击 **Add** 并搜索 `EnvironmentWebcam`。选择 **环境摄像头** 以将其添加到相同的 `Actor` ，与 **Convai 聊天机器人** 组件。
{% endstep %}

{% step %}

#### 放置该组件

在 **视口**，选择 **环境摄像头**。将其移动到角色眼睛附近，并旋转它，使其 `+X` 轴朝向角色应看到的关卡区域。
{% endstep %}

{% step %}

#### 创建渲染目标资源

在 **内容浏览器**，在空白区域右键单击，打开 **Convai** 子菜单，然后选择 **Vision 渲染目标** （当前插件版本中的上下文菜单标签）。将资源命名为，例如 `RT_ConvaiVision`，然后保存。

Convai 渲染目标操作会创建一个 `UTextureRenderTarget2D` 与 `RTF_RGBA8`、黑色清除颜色，以及默认大小为 `512 x 512`.
{% endstep %}

{% step %}

#### 分配渲染目标

选择 **环境摄像头** 到角色蓝图中。在 **详细信息** 面板中，将资源分配给 **Convai 渲染目标** 下的 **Convai | Vision**.
{% endstep %}

{% step %}

#### 从 BeginPlay 开始捕获

打开 **事件图表**。拖动 **环境摄像头** 来自 **Components** 面板到图表中。从组件引脚调用 **开始** （类别 **Convai | Vision**）。连接 **Event BeginPlay** 到 **开始**.
{% endstep %}

{% step %}

#### 编译并保存

点击 **编译**，然后 **保存** 蓝图。
{% endstep %}
{% endstepper %}

### 验证 Vision 是否正常工作

在以下对象前方放置一个明显的物体 **环境摄像头**。进入编辑器中运行（Play In Editor），开始对话，并询问该物体的信息，例如颜色或位置。

按顺序检查这些信号：

1. 在 **Convai 聊天机器人** 组件，调用 **支持 Vision**。它应返回 `true`.
2. 在 **环境摄像头**，调用 **获取状态**。它应返回 `Capturing`.
3. 在以下位置打开渲染目标资源： **内容浏览器** 当编辑器中运行（Play In Editor）时。预览应显示场景内容，而不是空白图像。
4. 在 **输出日志**，查找 `SendImage: 发送原始图像` 从 `ConvaiChatbotComponentLog`.

{% hint style="success" %}
**Vision 正在工作** 当 **支持 Vision** 返回 `true`, **获取状态** 返回 `Capturing`，渲染目标预览会在编辑器中运行时更新，并且角色的回复会引用可见物体。
{% endhint %}

如果任何检查失败，请参阅 [排查 Vision 问题](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unreal-engine-plugin/features/vision/troubleshoot-vision.md).

### 下一步

{% content-ref url="/pages/a5aa237a7b13fb2c8d46ff004c1de14a2c4cda2a" %}
[视觉帧来源](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unreal-engine-plugin/features/vision/vision-frame-sources.md)
{% endcontent-ref %}

{% content-ref url="/pages/cf86fde91936bc6994c59ccac11271cc09e11fea" %}
[视觉使用示例](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unreal-engine-plugin/features/vision/vision-usage-examples.md)
{% endcontent-ref %}

{% content-ref url="/pages/63feddf4b54afd4fe7308827bee6b2f213dde1b6" %}
[视觉的工作方式](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unreal-engine-plugin/features/vision/how-vision-works.md)
{% endcontent-ref %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/convai-unreal-engine-plugin/features/vision/vision-quick-start.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
