> 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/troubleshoot-vision.md).

# 排查视觉问题

修复常见 Unreal 视觉问题，包括缺少视觉上下文、启动失败、空白渲染目标和无效源注册。

当场景视觉功能未按预期工作时，请使用本页。每个条目都列出了症状、可能原因、修复方法以及如何验证修复效果。

### 诊断顺序

逐项排查具体问题前，请先检查以下信号：

1. 在 **Convai Chatbot** 组件上，调用 **Supports Vision**.
2. 在 **Environment Webcam**上，调用 **Get State**.
3. 在 **Environment Webcam**上，调用 **Get Last Error Message** 和 **Get Last Error Code**.
4. 确认 **Convai Render Target** 已在 **Details** 面板中指定。
5. 在 Play In Editor 期间，于 **Content Browser** 中打开渲染目标资源，并确认预览内容会更新。
6. 在 **Output Log**中，按 `ConvaiChatbotComponentLog` 筛选，并查找 `SendImage: Sending raw image` 或 `SendImage: Unable to capture Raw data`.

| 信号                         | 正常值                            |
| -------------------------- | ------------------------------ |
| **Supports Vision**        | `true`                         |
| **Get State**              | `Capturing` 处于活动捕获会话期间         |
| **Get Last Error Message** | 成功启动后为空字符串                     |
| 渲染目标预览                     | Play In Editor 期间显示场景内容        |
| Output Log                 | `SendImage: Sending raw image` |

### 角色没有响应视觉上下文

**症状：** 角色会响应语音，但忽略场景中可见的物体。

**原因：** 帧源未注册到聊天机器人，捕获未处于 `Capturing` 状态，或者会话是在视觉功能可用之前创建的。

**修复方法：**

1. 将 **Environment Webcam** 放在与 `Actor` 相同的 **Convai Chatbot** 组件上，或者使用 **Set Vision Component** 并传入摄像头引用。
2. 调用 **Get State**。如果返回 `Stopped`，则从 **Start** 中调用 `BeginPlay` ，或启用 `bAutoStartVision`.
3. 将 `UTextureRenderTarget2D` 赋给 **Convai Render Target**.
4. 如果在初始连接设置完成后才添加视觉组件，请在 **Always Allow Vision** 中 **Edit > Project Settings > Plugins > Convai** （高级类别）启用该选项，然后重新连接会话。

**验证：** **Supports Vision** 返回 `true`, **Get State** 返回 `Capturing`，并且角色会在回复中提及场景中可见的内容。

### Start 无效 — 组件仍处于 Stopped 状态

**症状：** 调用 **Start** 不会使组件切换到 `Capturing`. **Get State** 仍返回 `Stopped`.

**原因：** **Convai Render Target** 尚未指定。 `UEnvironmentWebcam` 检查 `CanStart()` 再进行状态转换。

**修复方法：** 将一个 `UTextureRenderTarget2D` 指定为 **Convai Render Target**。通过 **Convai > Vision Render Target** 在 **内容浏览器** 中创建资源，以使用插件默认值（`512 x 512`, `RTF_RGBA8`，清除颜色为黑色）。

**验证：** 再次调用 **Start** 。 **Get State** 应在一个帧内返回 `Capturing` 。

**诊断信息：** **Get Last Error Message** 在发生此故障时会返回 `ConvaiRenderTarget is null. Cannot start capture.` 。

### 渲染目标显示为黑色或空白

**症状：** 内容浏览器中的渲染目标预览 **内容浏览器** 或调试控件中显示的图像完全是黑色。

**原因：** **Environment Webcam** 未朝向可见的场景几何体、尚未开始捕获，或者内部捕获源已更改。

**修复方法：**

1. 选择 **Environment Webcam** 并确认其 `+X` 轴朝向你希望角色看到的场景区域。
2. 调用 **Get State**。如果状态为 `Stopped`，请调用 **Start** 或启用 `bAutoStartVision`.
3. 选择嵌套的 `EnvironmentSceneCapture2D` 子组件（ `CaptureComponent` 属性），并确认 **捕获源** 为 `SCS_FinalToneCurveHDR`.
4. 如果 `bCopyPostProcessProperties` 为 `true`，请确认关卡中存在后期处理体积。如果没有，请禁用此属性。

**验证：** 运行“在编辑器中播放”时，渲染目标预览应更新并显示场景内容。

### 启用视觉功能时，角色响应延迟较高

**症状：** 与不使用视觉功能的对话相比，角色响应时间明显增加。

**原因：** 帧正以默认的 `15` FPS 捕获并发送。

**解决方法：** 降低捕获速率。在 **最大 FPS** (`m_MaxFPS`) 中将值设为 `5` ，位置在 **细节** 面板；或者调用 **设置最大 FPS** 并指定值 `5`.

**验证：** 测量更改前后的响应时间。 **输出日志** 中仍应以降低后的频率显示 `SendImage: Sending raw image` 。

### 调用 Set Vision Component 后，Supports Vision 返回 false

**症状：** **Set Vision Component** 返回 `false` ，并且聊天机器人仍提示不支持视觉功能。

**原因：** 传入的组件未实现 `UConvaiVisionInterface`.

**解决方法：** 传入一个 `UConvaiWebcamBase` 子类，例如 `UEnvironmentWebcam`，或其他实现了 `IConvaiVisionInterface`。单纯的 `USceneCaptureComponent2D` 不是有效的帧源。

**请确认：** 在蓝图中将组件转换为 `UConvaiWebcamBase` 。如果转换成功，请将其传递给 **设置 Vision 组件** 并确认返回值为 `true`.

### 控制台警告无法捕获原始数据

**症状：** 该 **输出日志** 显示 `SendImage: Unable to capture Raw data`.

**原因：** `UConvaiChatbotComponent::SendImage()` 已调用 `CaptureRaw()`，但当前活动的帧源返回了 `false` 或空帧数据。

**修复方法：**

1. 确认 **获取状态** 返回 `Capturing`.
2. 确认 **Convai 渲染目标** 已分配。
3. 打开渲染目标预览，并确认其中包含场景内容。
4. 对于自定义视觉组件，请确认 `CaptureRaw()` 会填充 `Width`, `Height`，以及 `Data`，并返回 `true`.

**验证：** “ **输出日志** 应切换为 `SendImage: Sending raw image` （帧捕获成功后）。

### 后续步骤

{% content-ref url="/pages/ec5b9bfb145ddc8145050976e8e8db28d33fc076" %}
[视觉 Blueprint 参考](https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/convai-unreal-engine-plugin/features/vision/vision-blueprint-reference.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/ffb5a5d9ba2394107ce64c0b07938a181186f763" %}
[视觉快速开始](https://docs.convai.com/api-docs/zh/cha-jian-yu-ji-cheng/convai-unreal-engine-plugin/features/vision/vision-quick-start.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/troubleshoot-vision.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.
