全景图生成VR
本教程将指导您使用开放平台接口,将一组全景图上传并生成可在线浏览的 VR 空间。整个流程包括:获取访问令牌、获取上传凭证、上传全景图 ZIP 包、提交处理任务、轮询任务状态,最终获取 VR 链接。
前置准备
- 已在如视开放平台注册账号并获取
app_key和app_secret- 国内用户:前往 my.realsee.cn 注册
- 海外用户:前往 my.realsee.ai 注册
- 已申请开通「全景图生成 VR」接口能力(发邮件至 developer@realsee.com,提供账号归属区、UserID、IdentityID)
- 准备好全景图文件(等距柱状投影格式的全景图,JPG 格式)
API 基础地址
| 环境 | 基础地址 |
|---|---|
| 生产环境 | https://app-gateway.realsee.cn |
数据包格式
全景图需打包为 ZIP 格式上传。ZIP 包内包含一个 manifest.json 配置文件和一个 images/ 图片目录:
my-project.zip
├── manifest.json
└── images/
├── entrance.jpg
├── entrance-02.jpg
├── end-of-nave.jpg
├── presbyterium.jpg
└── high-altar.jpgmanifest.json 示例
{
"version": "1.0",
"floor_map": {
"0": 1,
"1": 2
},
"project_name": "my-pano-project",
"scan_list": [
{ "id": "entrance", "floor": 0 },
{ "id": "entrance-02", "floor": 0 },
{ "id": "end-of-nave", "floor": 0 },
{ "id": "presbyterium", "floor": 1 },
{ "id": "high-altar", "floor": 1 }
]
}字段说明
| 字段 | 类型 | 说明 |
|---|---|---|
version | string | 数据包版本号,当前固定为 "1.0" |
floor_map | object | 楼层映射。key 为 scan_list 中的 floor 值(字符串),value 为实际楼层编号 |
project_name | string | 项目名称。支持 {{timestamp}} 占位符自动替换为当前时间戳 |
scan_list | array | 全景图列表 |
scan_list[].id | string | 全景图标识,必须与 images/ 目录下的文件名(不含扩展名)一致 |
scan_list[].floor | number | 该全景图所在楼层,对应 floor_map 中的 key |
注意事项
images/目录下的图片文件名必须与scan_list中的id对应(如id为"entrance",则文件名为entrance.jpg)- 图片格式为 JPG,需为等距柱状投影(equirectangular)全景图
- 单楼层场景
floor_map只需一个映射即可,如{"0": 0}
流程概览
获取 access_token → 获取上传凭证 → 上传 ZIP 包 → 提交处理任务 → 轮询任务状态 → 获取 VR 链接步骤一:获取 access_token
所有业务接口都需要通过 access_token 鉴权。
- 接口:
POST /auth/access_token - Content-Type:
application/x-www-form-urlencoded
请求参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
app_key | string | 是 | 开放平台的 AppKey |
app_secret | string | 是 | 开放平台的 AppSecret |
请求示例
const getAccessToken = async () => {
const res = await fetch('https://app-gateway.realsee.cn/auth/access_token', {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
body: new URLSearchParams({
app_key: 'your_app_key',
app_secret: 'your_app_secret',
}),
});
const data = await res.json();
return data.data;
};响应示例
{
"code": 0,
"status": "success",
"data": {
"access_token": "VE9LRU5fVjJLTmRBM3J1ZWVweEZwWVF6...",
"expire_at": 1710732700
}
}响应字段说明
| 字段 | 类型 | 说明 |
|---|---|---|
access_token | string | 访问令牌,用于后续接口的 Authorization 请求头 |
expire_at | integer | 过期时间(Unix 时间戳,秒)。过期后需重新获取 |
错误码说明
code: 0— 成功code: -1, status: "illegal app"— app_key 或 app_secret 错误
步骤二:获取上传凭证
获取临时上传凭证,用于将全景图 ZIP 包上传到对象存储。
- 接口:
GET /open/v1/pano/file/token - Header:
Authorization: {access_token}