> 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 角色 Blueprint，并验证捕获的帧会在 Play In Editor 中影响角色的响应。

我们将添加一个 **环境摄像头** 组件到现有的 Convai 角色，分配一个渲染目标，并从以下位置开始捕获 **事件 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 Chatbot** 组件（`UConvaiChatbotComponent`）以及一个有效的 `CharacterID`。请参阅 [添加你的第一个 Convai 角色](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unreal-engine-plugin/getting-started/add-your-first-convai-character.md) 如果你尚未完成该设置。
* 一个 **Convai 播放器** 组件（`UConvaiPlayerComponent`）已存在，因此你可以在编辑器中运行（Play In Editor）时开始对话。

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

{% stepper %}
{% step %}

#### 打开角色 Blueprint

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

{% step %}

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

在 **组件** 面板，点击 **添加** 并搜索 `EnvironmentWebcam`。选择 **环境摄像头** 将其添加到相同的 `Actor` 与……相同的 **Convai Chatbot** 组件。
{% endstep %}

{% step %}

#### 定位该组件

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

{% step %}

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

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

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

{% step %}

#### 分配渲染目标

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

{% step %}

#### 从 BeginPlay 开始捕获

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

{% step %}

#### 编译并保存

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

### 验证视觉是否正常工作

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

按顺序检查这些信号：

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

{% hint style="success" %}
**视觉正常工作** 当 **支持视觉** 返回 `true`, **获取状态** 返回 `正在捕获`，渲染目标预览会在编辑器中运行期间更新，并且角色的回应会提及可见物体。
{% endhint %}

如果任何检查失败，请参阅 [排查视觉问题](/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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
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>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
