> 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-frame-sources.md).

# 视觉帧来源

帧源是聊天机器人上的一个组件 `Actor` 它实现 `IConvaiVisionInterface`。该 `ConvaiVisionBase` 模块随附 **环境摄像头** (`UEnvironmentWebcam`) 用于通过一个进行场景捕获 `USceneCaptureComponent2D`.

如果你是第一次设置视觉，请先完成 [视觉快速入门](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unreal-engine-plugin/features/vision/vision-quick-start.md) 首先完成视觉快速入门。使用此页面在初始设置后配置帧源。

### 内置帧源

**环境摄像头** 在组件选择器中显示为 **环境摄像头**。它从组件变换捕获场景，渲染到一个 `UTextureRenderTarget2D`，并向聊天机器人公开帧数据。

#### 环境摄像头上的属性

| 属性                           | 类型                          | 默认值     | 描述                                                   |
| ---------------------------- | --------------------------- | ------- | ---------------------------------------------------- |
| `ConvaiRenderTarget`         | `UTextureRenderTarget2D*`   | `null`  | 组件捕获到的渲染目标。需要在 **Start** 之前才能进入 `Capturing`.         |
| `CaptureComponent`           | `USceneCaptureComponent2D*` | 自动创建    | 名为 `EnvironmentSceneCapture2D`.                      |
| `bCopyPostProcessProperties` | `bool`                      | `false` | 从第一个 `APostProcessVolume` 中复制设置，来源于世界中的 `BeginPlay`. |
| `bAutoStartVision`           | `bool`                      | `false` | 调用 **Start** 在 `BeginPlay` 启用时。                      |

#### 继承自 UConvaiWebcamBase 的属性

| 属性               | 类型        | 默认值    | 描述                                  |
| ---------------- | --------- | ------ | ----------------------------------- |
| `标识符`            | `FString` | `""`   | 存储在组件上的可选标签。已发布的运行时路径不使用。           |
| `m_MaxFPS`       | `int`     | `15`   | 面板中显示的最大捕获 FPS **详情** 为 **最大 FPS**. |
| `bUpdateOnFetch` | `bool`    | `true` | 存储在基类上。已发布的运行时路径不使用。                |

参见 [视觉蓝图引用](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unreal-engine-plugin/features/vision/vision-blueprint-reference.md) 以查看完整的属性和节点列表。

### 渲染目标要求

**环境摄像头** 不会进入 `Capturing` ，除非 `UTextureRenderTarget2D` 被分配给 **Convai 渲染目标**.

推荐创建路径：

| 将      | 值                     |
| ------ | --------------------- |
| 宽度     | `512`                 |
| 高度     | `512`                 |
| 渲染目标格式 | `RTF_RGBA8`           |
| 清除颜色   | `FLinearColor::Black` |

从 **内容浏览器** 创建该资源，方法是选择 **Convai > 视觉渲染目标** （当前插件版本中的上下文菜单标签），或创建一个标准的 `TextureRenderTarget2D` 并手动匹配这些值。

### 开始和停止捕获

调用 **Start** 于 **环境摄像头** 以开始捕获。组件会验证 `CaptureComponent` 和 **Convai 渲染目标**，将状态设为 `Capturing`，启用 `bCaptureEveryFrame` 在内部捕获组件上，并开始将场景帧写入渲染目标。

调用 **停止** 以将状态设为 `已停止` 并禁用 `bCaptureEveryFrame`.

手动连接的替代方案 **Start** ：

* 启用 `bAutoStartVision` 在 **详情** 面板以调用 **Start** 在期间自动 `BeginPlay`.
* 遵循 **Event BeginPlay → Start** 中的模式 [视觉快速入门](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unreal-engine-plugin/features/vision/vision-quick-start.md).

### 在运行时更改活动视觉组件

`UConvaiChatbotComponent` 自动发现其上的第一个组件 `Actor` 它实现 `UConvaiVisionInterface`。要显式选择不同来源，请调用 **设置视觉组件** 在聊天机器人上，并传入所需组件。

```
// 伪代码 — 蓝图节点名称
ChatbotComponent → 设置视觉组件（VisionComponent：EnvironmentWebcamReference）
```

**设置视觉组件** 返回 `true` 仅在传入组件实现 `UConvaiVisionInterface`.

### 使用多个视觉组件

每个聊天机器人只能有一个活动帧源。 当多个组件实现 `IConvaiVisionInterface` 在同一个 `Actor`上时，聊天机器人会使用发现过程中找到的第一个。调用 **设置视觉组件** 中 `BeginPlay` 以选择特定来源。

### 启用后期视觉设置

`AlwaysAllowVision` 是 `UConvaiSettings`上的一个项目设置。打开 **编辑 > 项目设置 > 插件 > Convai** 并启用 **始终允许视觉** 在高级类别中。

启用后，会话设置使用连接类型 `视频` 即使尚未注册任何视觉组件。仅当你的项目在初始连接设置之后添加或切换帧源时才使用此功能。对于带有 **环境摄像头** 已经在聊天机器人上 `Actor` 之前 `BeginPlay`, **支持视觉** 就足够了。

### 纹理源类型

当聊天机器人读取一帧时，它会调用 `GetImageTexture` 在活动源上。 **环境摄像头** 始终返回 `RenderTarget2D` 因为它捕获到一个 `UTextureRenderTarget2D`.

### 使用网络摄像头图像

当前的 Convai Unreal Engine 插件不包含直接从物理网络摄像头设备读取的组件。 **环境摄像头** 捕获任何对其 `USceneCaptureComponent2D`.

对于初学者项目，请将网络摄像头图像用作可见的场景内容：

{% stepper %}
{% step %}

#### 将网络摄像头画面引入 Unreal

使用 Unreal Engine 的媒体工作流在关卡中显示网络摄像头画面，例如在平面、网格体或小组件上。关键结果是网络摄像头图像在渲染场景中可见。
{% endstep %}

{% step %}

#### 将环境摄像头指向该画面

放置 **环境摄像头** 在聊天机器人上 `Actor` 并将其旋转，使其 `+X` 轴朝向显示网络摄像头画面的表面。
{% endstep %}

{% step %}

#### 将场景捕获到 Convai 渲染目标中

分配 **Convai 渲染目标** 并调用 **Start** ，如中所述 [视觉快速入门](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unreal-engine-plugin/features/vision/vision-quick-start.md)。聊天机器人会接收网络摄像头图像的帧，因为该图像现在已成为被捕获场景的一部分。
{% endstep %}

{% step %}

#### 验证捕获的图像

在编辑器播放期间打开渲染目标资源。如果预览显示网络摄像头表面，询问角色该画面中可见什么。
{% endstep %}
{% endstepper %}

对于需要发送网络摄像头像素但不在关卡中渲染它们的生产项目，请实现一个自定义 C++ 帧源，通过 `IConvaiVisionInterface`。参见 [自定义视觉组件](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unreal-engine-plugin/features/vision/custom-vision-components.md).

### 下一步

{% 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/ec5b9bfb145ddc8145050976e8e8db28d33fc076" %}
[视觉蓝图参考](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unreal-engine-plugin/features/vision/vision-blueprint-reference.md)
{% endcontent-ref %}

{% content-ref url="/pages/afdaa73f8daaacc42144959e698d777a078e46d3" %}
[自定义视觉组件](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unreal-engine-plugin/features/vision/custom-vision-components.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-frame-sources.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.
