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

# 视觉帧源

配置内置的 Environment Webcam 帧源，创建其渲染目标，并在运行时选择活动视觉组件。

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

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

### 内置帧源

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

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

| 属性                           | 类型                          | 默认      | 说明                                                         |
| ---------------------------- | --------------------------- | ------- | ---------------------------------------------------------- |
| `ConvaiRenderTarget`         | `UTextureRenderTarget2D*`   | `null`  | 组件捕获到的渲染目标。在以下操作之前为必需 **开始** 可以进入 `正在捕获`.                  |
| `CaptureComponent`           | `USceneCaptureComponent2D*` | 自动创建    | 内部场景捕获组件，名为 `EnvironmentSceneCapture2D`.                   |
| `bCopyPostProcessProperties` | `bool`                      | `false` | 从第一个 `APostProcessVolume` 复制设置，该体积在以下期间于世界中找到 `BeginPlay`. |
| `bAutoStartVision`           | `bool`                      | `false` | 调用 **开始** 期间 `BeginPlay` 启用时。                              |

#### 从 UConvaiWebcamBase 继承的属性

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

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

### 渲染目标要求

**环境摄像头** 不会进入 `正在捕获` ，除非将一个 `UTextureRenderTarget2D` 分配给 **Convai 渲染目标**.

推荐创建路径：

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

从 **内容浏览器** 创建资产，方法是选择 **Convai > Vision Render Target** （当前插件版本中的上下文菜单标签），或者创建标准的 `TextureRenderTarget2D` 并手动匹配这些值。

### 开始和停止捕获

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

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

手动连接的替代方案 **开始** ：

* 启用 `bAutoStartVision` ，位于 **Details** 面板以调用 **开始** 自动在 `BeginPlay`.
* 遵循 **Event BeginPlay → Start** 模式，来自 [Vision 快速入门](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unreal-engine-plugin/features/vision/vision-quick-start.md).

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

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

```
// 伪代码 — 蓝图节点名称
ChatbotComponent → Set Vision Component (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 渲染目标** 并调用 **开始** 如中所述 [Vision 快速入门](/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" %}
[视觉 Blueprint 参考](/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 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-frame-sources.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.
