> 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 角色，为其指定一个渲染目标，并从 **Event BeginPlay**启动捕获。完成后，在 Play In Editor 期间，角色应能对捕获组件前方可见的事物作出回应。

### 前提条件

* 已安装并启用 Convai Unreal Engine 插件版本 <code class="expression">space.vars.unreal\_plugin\_version</code> 。如有需要，请参阅 [安装插件](https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/convai-unreal-engine-plugin/getting-started/install-the-convai-plugin.md) 。
* 已配置 API 密钥。请参阅 [配置 API 密钥](https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/convai-unreal-engine-plugin/getting-started/configure-your-api-key.md).
* 关卡中有一个角色，其中包含 **Convai 聊天机器人** 组件（`UConvaiChatbotComponent`），并且具有有效的 `CharacterID`。请参阅 [添加你的第一个 Convai 角色](https://docs.convai.com/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" %}
视觉功能使用角色视角进行场景捕获，而非实体设备摄像头。随插件提供的组件是 **环境摄像头** (`UEnvironmentWebcam`).
{% endhint %}

{% stepper %}
{% step %}

#### 打开角色蓝图

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

{% step %}

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

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

{% step %}

#### 设置组件的位置

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

{% step %}

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

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

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

{% step %}

#### 指定渲染目标

在角色蓝图中选择 **Environment Webcam** 。在 **详细信息** 面板中，在 **Convai Render Target** 下方的 **Convai | Vision**.
{% endstep %}

{% step %}

#### 从 BeginPlay 开始捕获

打开 **事件图表**。将 **Environment Webcam** 从 **组件** 面板拖入图表。从组件引脚调用 **Start** （类别： **Convai | Vision**）。将 **Event BeginPlay** 连接到 **Start**.
{% endstep %}

{% step %}

#### 编译并保存

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

### 验证视觉功能是否正常

在 **环境摄像头**。进入编辑器内运行（Play In Editor），开始对话，并询问关于该物体的问题，例如它的颜色或位置。

按顺序检查以下信号：

1. 在 **Convai 聊天机器人** 组件上，调用 **Supports Vision**。它应返回 `true`.
2. 在 **环境摄像头**上，调用 **Get State**。它应返回 `Capturing`.
3. 在编辑器内运行期间，在 **内容浏览器** 中打开渲染目标资源。预览应显示场景内容，而不是空白图像。
4. 在 **输出日志**中，查找 `SendImage: Sending raw image` ，来自 `ConvaiChatbotComponentLog`.

{% hint style="success" %}
**以下情况表明视觉功能正常：** 当 **Supports Vision** 返回 `true`, **Get State** 返回 `Capturing`，渲染目标预览在编辑器内运行期间持续更新，并且角色的回答提到了画面中可见的物体。
{% endhint %}

如果任何一项检查未通过，请参阅 [视觉功能故障排查](https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/convai-unreal-engine-plugin/features/vision/troubleshoot-vision.md).

### 后续步骤

{% content-ref url="/pages/a5aa237a7b13fb2c8d46ff004c1de14a2c4cda2a" %}
[视觉帧源](https://docs.convai.com/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" %}
[视觉使用示例](https://docs.convai.com/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" %}
[视觉的工作原理](https://docs.convai.com/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.
