---
title: cv_s2net_panorama-depth-estimation
canonical_url: "https://www.modelscope.cn/models/iic/cv_s2net_panorama-depth-estimation"
md_url: "https://www.modelscope.cn/models/iic/cv_s2net_panorama-depth-estimation.md"
repository: iic/cv_s2net_panorama-depth-estimation
chinese_name: "球面上的全景图单目深度估计"
last_updated: 2023-11-30
license: "Apache License 2.0"
pipeline_tag: panorama-depth-estimation
tasks:
  - panorama-depth-estimation
model_type:
  - roberta
library_name:
  - pytorch
frameworks:
  - Pytorch
domain:
  - cv
downloads: 8121
stars: 14
tags:
  - Alibaba
  - Panorama
  - S2net
  - Depth
  - "3D Vision"
  - XR
---

# cv_s2net_panorama-depth-estimation

> cv_s2net_panorama-depth-estimation - iic 在 ModelScope 开源的模型。提出了一种用于单目全景深度估计的端到端深度网络S2Net，该网络工作在单位球面上，从而减少畸变。S2Net将从等距图像中提取的特征图投影到由均匀分布的网格采样的单位球面上，并在球面上融合畸变更少的特征图信息并预测深度图。S2Net包含一个基于全局交叉注意力的融合模块，用于融合不同尺度的球面特征图并增强获取全局上下文的能力。

iic/cv_s2net_panorama-depth-estimation 是 ModelScope 魔搭社区上的panorama-depth-estimation模型，采用 Apache License 2.0 许可。

- **Repository**: iic/cv_s2net_panorama-depth-estimation
- **License**: Apache License 2.0
- **Tasks**: panorama-depth-estimation
- **Tags**: Alibaba, Panorama, S2net, Depth, 3D Vision, XR
- **Downloads**: 8121
- **Stars**: 14
- **Last updated**: 2023-11-30

Source: https://www.modelscope.cn/models/iic/cv_s2net_panorama-depth-estimation

---

# 球面上的全景图深度估计
## 任务
输入一张单目全景RGB图像，全景深度估计算法将分析场景三维结构，输出图像对应的稠密深度图。
![intro](description/intro.png)
## 模型描述

本模型基于S2Net: Accurate Panorama Depth Estimation on Spherical Surface，是该算法的官方模型。


技术细节请见：

[arXiv](https://arxiv.org/abs/2301.05845)

### 方法简述
- 全景图像利用等距投影捕捉其周围的完整空间信息，从而引入了大量畸变。这要求基于全景图的深度估计方法能够处理畸变并从图像中提取全局上下文信息。
- 本方法提出了一种用于单目全景深度估计的端到端深度网络S2Net，该网络工作在单位球面上，从而减少畸变。
- S2Net将从等距图像中提取的特征图投影到由均匀分布的网格采样的单位球面上，并在球面上融合畸变更少的特征图信息并预测深度图。
- S2Net包含一个基于全局交叉注意力的融合模块，用于融合不同尺度的球面特征图并增强获取全局上下文的能力。
### 方法流程

![s2net](description/framework4.png)

- 上图为S2Net方法的基本流程。浅蓝色部分处理平面ERP图像，而灰蓝色部分处理单位球面。具体流程如下：
  - 使用SwinEncoder从ERP图像提取特征，并将特征从图像平面映射到单位球面。
  - 使用全局交叉注意力融合模块(Cross Attention Fusion Decoder)在球面上融合多尺度特征并最终预测球面上的深度图。
  - 最后将深度图从单位球面映射回到图像平面。
### 网络结构
![CAF](description/network.png)

- Fusion指的是全局交叉注意力融合模块，用于融合不同尺度的球面特征。
- “LN”，“SPE”和“ResCon”分别表示层归一化(Layer Normalization)，球形位置嵌入(Spherical Positional Embedding，详见论文III-C节)和残差卷积(Residual Convolution)。

## 如何使用
### 依赖
```shell
pip install healpy
```

### 代码示例

```python
import cv2
from modelscope.outputs import OutputKeys
from modelscope.pipelines import pipeline
from modelscope.utils.constant import Tasks
from modelscope.utils.cv.image_utils import depth_to_color


task = 'panorama-depth-estimation'
model_id = 'damo/cv_s2net_panorama-depth-estimation'

input_location = 'data/test/images/panorama_depth_estimation.jpg'
estimator = pipeline(Tasks.panorama_depth_estimation, model=model_id)
result = estimator(input_location)
depth_vis = result[OutputKeys.DEPTHS_COLOR]
cv2.imwrite('result.jpg', depth_vis)
```

### 适用范围

输入一张单目全景RGB图像，图像投影模型为等距投影，即长宽比为2:1，建议分辨率为1024x512。


## 结果
### 定性结果
#### 点云可视化结果
![PointCloud](description/circularpadding8.png)

上图展示了S2Net与UniFuse点云重建结果比较。相比于UniFuse，S2Net能够更好的保证ERP图像左右端的空间一致性。
#### Depth可视化结果

![Depth](description/exhibit4.jpg)

### 定量结果
[Matterprot3d](https://niessner.github.io/Matterport/)和[Stanford2D3D](http://buildingparser.stanford.edu/dataset.html)数据集上的结果。

![M3D S2D3D](description/m3d-s2d3d.png)


[Pano3d](https://vcl3d.github.io/Pano3D/)数据集上的结果。

![Pano3D](description/pano3d.png)

## Bibtex
If you find this code useful in your research, please cite:
```text
@article{li2023mathcal,
  title={S2Net: Accurate Panorama Depth Estimation on Spherical Surface},
  author={Li, Meng and Wang, Senbo and Yuan, Weihao and Shen, Weichao and Sheng, Zhe and Dong, Zilong},
  journal={IEEE Robotics and Automation Letters},
  volume={8},
  number={2},
  pages={1053--1060},
  year={2023},
  publisher={IEEE}
}
```
