> 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-unity-sdk/features/vision.md).

# 视觉

查找在 Unity 中为 Convai 角色添加实时场景视觉的指南，包括帧源、发布策略、脚本编写和故障排查。

Vision 使 Convai 角色能够看到 Unity 场景中正在发生的事情。帧源会从 Unity 摄像机、物理摄像头或 Meta Quest 透传画面中捕获图像，SDK 则通过 WebRTC 将这些图像与音频对话一起流式传输给 Convai。

### 平台支持

| 平台                | 支持的帧源                                                | 备注                                                              |
| ----------------- | ---------------------------------------------------- | --------------------------------------------------------------- |
| PC / Mac / 主机     | `CameraVisionFrameSource`, `WebcamVisionFrameSource` | 完整 RenderTexture 管线；最高 30 fps                                   |
| Android / iOS     | `CameraVisionFrameSource`, `WebcamVisionFrameSource` | 摄像头源在启动时请求相机权限                                                  |
| WebGL             | *（Canvas，自动）*                                        | `canvas.captureStream()` 路径 — 无需帧源组件；帧率上限为 15 fps； **需要 HTTPS** |
| Meta Quest 3 / 3S | `QuestVisionFrameSource`                             | 需要 Meta XR SDK 和 `horizonos.permission.HEADSET_CAMERA`          |

{% hint style="info" %}
Vision 需要 `ConvaiRoomManager.Connection Type` 设置为 **视频**。如果将其设置为 `音频`, `ConvaiVisionPublisher` 无论其他组件如何配置，它都保持空闲。
{% endhint %}

{% hint style="danger" %}
**WebGL：需要 HTTPS。** 该 `canvas.captureStream()` 浏览器会阻止非 HTTPS 来源的 API。 `http://localhost` 是唯一的例外。在生产环境测试 Vision 之前，请将你的 WebGL 构建部署到 HTTPS 主机上。
{% endhint %}

<table data-view="cards"><thead><tr><th></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td><strong>视觉工作原理</strong><br>了解管线架构、关键概念、组件放置和启动顺序。</td><td><a href="/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/features/vision/how-vision-works.md">视觉的工作原理</a></td></tr><tr><td><strong>动态视觉上下文</strong><br>打开帧采样，让角色基于缓冲帧进行推理，而不是处理每个传入帧，使用与动态上下文相同的响应模式词汇。</td><td><a href="/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/features/vision/dynamic-vision-context.md">动态视觉上下文</a></td></tr><tr><td><strong>Vision 快速入门</strong><br>通过逐步的 Inspector 指南，让角色接收实时摄像头画面——无需代码。</td><td><a href="/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/features/vision/quick-start.md">视觉快速开始</a></td></tr><tr><td><strong>视觉帧来源</strong><br>为每个平台和用例配置 CameraVisionFrameSource、WebcamVisionFrameSource 和 QuestVisionFrameSource。</td><td><a href="/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/features/vision/frame-sources.md">视觉帧源</a></td></tr><tr><td><strong>发布策略</strong><br>选择发布策略，调整帧率和比特率，并了解包括 WebGL 在内的平台特定行为。</td><td><a href="/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/features/vision/publishing-and-policies.md">发布策略</a></td></tr><tr><td><strong>Vision 调试预览</strong><br>将当前活动的帧源可视化为屏幕叠加层，并在编辑器中监控捕获状态。</td><td><a href="/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/features/vision/debug-preview.md">视觉调试预览</a></td></tr><tr><td><strong>自定义帧源</strong><br>实现 IVisionFrameSource 以发布任何自定义视频管线——接口约定、Y 轴翻转要求和最小实现。</td><td><a href="/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/features/vision/custom-frame-sources.md">自定义帧来源</a></td></tr><tr><td><strong>Vision 脚本 API</strong><br>ConvaiVisionPublisher 属性和方法、运行时状态监控，以及用于分析集成的领域事件。</td><td><a href="/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/features/vision/scripting-api.md">Vision 脚本 API</a></td></tr><tr><td><strong>视觉使用示例</strong><br>面向安全培训、设备入门、VR 演示和手动触发会话的端到端示例。</td><td><a href="/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/features/vision/usage-examples.md">视觉使用示例</a></td></tr><tr><td><strong>排查视觉问题</strong><br>使用结构化检查清单和决策树诊断发布失败、空白画面、权限错误以及平台特定问题。</td><td><a href="/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/features/vision/troubleshooting-and-diagnostics.md">排查视觉问题</a></td></tr></tbody></table>

### 动态视觉上下文

动态视觉上下文使 Convai 能够持续从已发布的视频轨道中采样到滚动帧缓冲区，并将最新帧附加到角色的轮次中，而不是在每一帧到达时都做出反应。它与 [动态上下文](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/features/dynamic-context.md): `ConvaiRespondMode` 值 `Silent`, `自动`，以及 `MustRespond` 决定新输入是否发言、由模型决定，还是保持沉默。参见 [动态上下文脚本 API](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/features/dynamic-context/dynamic-context-scripting-api.md) 获取完整的 `ConvaiRespondMode` 参考资料。

### 下一步

先从 [Vision 快速入门](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/features/vision/quick-start.md) 以从场景摄像机获取可工作的流，然后使用 [视觉帧来源](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/features/vision/frame-sources.md) 为你的平台选择合适的捕获方法。有关管线详情，请参见 [视觉工作原理](/api-docs/zh/cha-jian-yu-ji-cheng/convai-unity-sdk/features/vision/how-vision-works.md).


---

# 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-unity-sdk/features/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.
