摘要
目前大多数先进的双目立体匹配网络通过构建4D代价矩阵以保留图像的语义信息,增加了网络的计算量开销。为了解决上述问题,提出了两阶段的组合代价矩阵和多尺度动态注意力的EDNet++网络。首先从全局的、粗粒度的视差搜索范围上构建的基于相似度的代价矩阵作为引导,在局部的搜索范围上实现细粒度的组合代价矩阵,其次提出基于残差的动态注意力机制,其根据中间结果信息自适应地生成空间上的注意力分布,并且通过迁移实验证明了该方法的有效性,最后在各大公开数据集上的对比实验结果表明,相较于其他方法,EDNet++方法能够达到算法精度和实时性的良好平衡。
准确快速的深度估计对于机器人导航、三维重建、自动驾驶等应用具有重要意义。双目立体匹配作为一种深度估计的算法,被广泛运用在各个领域。双目立体匹配任务是在左右视图间进行相同像素的匹配,并且计算相同像素的距离偏差(俗称视差)。
传统方法则以人工设计的特征提取和匹配成本聚合算法为主,对于那些无纹理和重复纹理的区域匹配效果较差。卷积神经网络(CNNs)已经被广泛采用来克服传统立体匹配中的难点。文献[
经典的立体匹配网络流程包括特征提取、构建代价体积、特征聚合和视差计算4个步
基于CNN的匹配代价计算方法对立体匹配精度有很大的贡献。有2种常用的匹配代价计算方法。一种是使用二
在立体匹配任务中,残差学习策略被广泛用于精化视差估
提出的EDNet++网络结构如

图1 EDNet++框架图总览
Fig. 1 Overview of proposed EDNet++
提出了两阶段的组合代价矩阵,通过一阶段的相似度矩阵得到粗粒度视差结果,在二阶段,在局部视差搜索范围的基础上使用相似度矩阵和4D代价矩阵结合的方式构建代价矩阵,见

图2 两阶段代价矩阵构建流程
Fig. 2 Overview of two-stage cost volume construction
在第1阶段,给定一对立体图像特征fL和fR,相似度代价矩阵计算如
(1) |
式中:为2个特征向量x1和x2的内积;N为输入特征的通道数,代价矩阵的形状为N×D×H×W;d为视差搜索范围D内的某一个视差值,空间大小为H×W。fL和fR分别代表左视角图像特征和右视角图像特征。
假设在一阶段视差估计网络中已经通过相似性代价矩阵和聚合网络获得了粗粒度的基准视差图s-1。接下来需要设置初始平面数n和初始平面间隔来自定义二阶段的视差搜索范围。相对视差范围定义为
(2) |
基准视差图s-1的尺寸H和W与特征图的fL和fR相同,下一步则根据基准视差s-1对特征图进行变形,建立第2阶段的组合代价矩阵。其中第2阶段的代价矩阵的计算方法为
(3) |
式中:M代表组合代价计算;为坐标点(x,y)在基准视差图s-1对应的视差值。该算法将特征点转移到基准视差上,并使用它作为每个像素搜索的中心点,如

图3 视差搜索范围的变化
Fig. 3 Change in disparity search range
在第2阶段,将基于拼接的4D代价矩阵信息融合进来,4D代价矩阵的构建方式定义为
(4) |
其中T为特征拼接操作,在得到形状为N×D×C×H×W的4D矩阵后,使用3个三维卷积进行聚合,将其压缩为N×D×1×H×W的形状。最后将相似度矩阵和压缩4D代价矩阵级联形成组合代价矩阵。
提出一个基于动态注意力的多尺度残差模块,引导残差网络更多地关注在当前尺度下空间中那些不准确的区域。假设当前尺度是c(1/原图分辨率),根据在上一个尺度c-1下的视差估计的上采样结果,可以根据对右图进行采样得到合成的左图,如
(5) |
根据合成的左图和真实左图可以得到误差图,为
(6) |
一个3层的基于2D卷积的网络被用于接收由误差图、粗粒度视差图和左右视图拼接而成的输入。
来自解码器网络的上卷积特征映射和来自编码器网络的对应尺度的特征会和注意力模块的输入相拼接,然后与注意力分布图在空间维度上相乘后形成残差特征,为
(7) |
代表sigmoid函数。该残差特征会输入二维卷积堆叠网络,输出尺度c下的残差视差rc,最终预测视差结果定义为
(8) |
如

图4 注意力分布图在不同尺度上的可视化
Fig. 4 Attention map in different scales
4个公共数据集用于训练和测试本文提出的EDNet++。
SceneFlow:SceneFlow数据
Kitti:Kitti 2012和Kitti 2015都是真实场景的数据集,全分辨率为1 242×375。这2个数据集的深度真值由激光雷达产生,因此只有稀疏的真值可用。总共有400对图像用于训练,400对用于评估。
Middlebury:Middlebury数据集是在真实场景中由高分辨率的结构化照明捕获的。它只有15对训练用的双目图片和15对测试用的双目图片,所以在训练时很可能会引起过拟合。
ETH3D:ETH3D数据集包括27个训练帧和20个测试帧,涵盖各种室内和室外场景。
在Scene Flow数据集上用像素点平均误差(EPE)、1像素误差和3像素误差来评估模型。像素点平均误差计算像素的平均视差误差,1像素误差和3像素误差分别测量EPE大于1像素和大于3像素的平均百分比。官方指标(例如D1-all)报告用于KITTI 2012和KITTI 2015数据集的评估。
用PyTorc
两阶段的代价矩阵构建方法让EDNet++相对于EDNe
网络结构 | Middlebury | KITTI2012 | KITTI2015 | ETH3D | |||||
---|---|---|---|---|---|---|---|---|---|
B2 | B4 | E | 像素误差百分比大于3 | E | 像素误差百分比大于3 | E | B2 | B4 | |
一阶段代价矩阵 | 54.00 | 41.20 | 20.40 | 43.70 | 8.00 | 48.30 | 10.78 | 10.31 | 6.23 |
二阶段代价矩阵 | 45.10 | 30.80 | 11.80 | 15.70 | 1.90 | 14.90 | 2.29 | 6.54 | 2.96 |
在Middlebury数据集上最显著的改善是平均像素误差,下降了42%。EDNet++在KITTI 2015上测试时,在误差大于3像素和EPE这2个指标方面的性能分别提高了66%和77%,在KITTI 2012上测试时相同指标的性能分别提高了62%和76%。
主要的立体匹配聚合网络可分为优化网络(如Sterone

图5 基于注意力的残差模块在两类聚合网络中的应用
Fig. 5 Application of attention-based residual module into two kinds of aggregation networks
网络框架 | 代价矩阵 | 残差结构 | 指标结果 | |||
---|---|---|---|---|---|---|
原始 | 组合代价矩阵 | 原始 | 动态注意力 | EPE | 时间/s | |
StereoNe | √ | √ | 1.55 | 0.169 | ||
StereoNet-A | √ | √ | 1.37 | 0.172 | ||
StereoDRNe | √ | √ | 1.33 | 0.171 | ||
StereoDRNet-A | √ | √ | 1.23 | 0.175 | ||
PSMNe | √ | √ | 1.09 | 0.338 | ||
PSMNet-A | √ | √ | 1.05 | 0.343 | ||
AANe | √ | √ | 1.60 | 0.143 | ||
AANet-A | √ | √ | 1.50 | 0.150 | ||
AANet-CA | √ | √ | 1.27 | 0.281 | ||
DispNe | √ | √ | 2.11 | 0.056 | ||
DispNet-A | √ | √ | 2.11 | 0.068 | ||
DispNet-CA | √ | √ | 2.00 | 0.073 | ||
FADNe | √ | √ | 1.74 | 0.077 | ||
FADNet-A | √ | √ | 1.63 | 0.086 | ||
FADNet-CA | √ | √ | 1.61 | 0.092 |
可以看到所有的网络在通过基于注意力的残差网络迁移后精度都得到了提高,相应地在时间复杂度上也有些许上升。改善最大的是AANe
将提出的算法模型与现有的最先进的方法在推理速度、内存消耗和准确率方面进行比较,使用的数据集有Sceneflow、KITTI 2015和KITTI 2012。
如
方法 | EPE | 时间/s |
---|---|---|
PSMNe | 1.09 | 0.453 |
CFNet | 0.97 | 0.180 |
GwcNet | 0.76 | 0.254 |
Bi3D | 0.73 | 内存溢出 |
ACVNet | 0.43 | 0.225 |
AANet++ | 0.72 | 0.068 |
EDNet | 0.68 | 0.059 |
EDNet++ | 0.69 | 0.051 |
注: 推理时间是在单个NVIDIA 2080ti GPU上测试的结果,分辨率为576×960。
在Kitti数据集上,本文将对比实验分为2组,如
方法 | N/% | A/% | 时间/s | ||
---|---|---|---|---|---|
f | a | f | a | ||
GANe | 3.37 | 1.73 | 3.82 | 1.93 | 0.360 |
GCNe | 5.58 | 2.61 | 6.16 | 2.87 | 0.900 |
MC-CN | 7.64 | 3.33 | 8.88 | 3.89 | 67.000 |
H | 3.43 | 1.87 | 3.63 | 2.02 | 0.140 |
CS | 3.55 | 1.78 | 4.03 | 1.59 | 0.600 |
DeepPruner- | 3.18 | 1.95 | 3.56 | 2.15 | 0.180 |
Bi3 | 3.11 | 1.79 | 3.48 | 1.95 | 0.480 |
ACVNe | 3.07 | 1.65 | 0.200 | ||
CFNe | 1.73 | 1.88 | 0.180 | ||
EDNe (本文模型) | 3.33 | 2.31 | 3.88 | 2.53 | 0.050 |
EDNet++ (本文模型) | 3.14 | 2.62 | 3.69 | 2.83 | 0.045 |
AANe | 4.93 | 2.32 | 5.39 | 2.55 | 0.075 |
DeepPruner- | 3.18 | 1.95 | 3.56 | 2.59 | 0.060 |
FADNe | 3.07 | 2.59 | 3.50 | 2.82 | 0.050 |
RLStere | 4.76 | 2.38 | 5.38 | 2.64 | 0.038 |
MADNe | 8.41 | 4.27 | 9.20 | 4.66 | 0.020 |
EDNe (本文模型) | 3.33 | 2.31 | 3.88 | 2.53 | 0.050 |
EDNet++ (本文模型) | 3.14 | 2.62 | 3.69 | 2.83 | 0.045 |
注; 加粗表示最佳结果;加下划线表示次优。
方法 | 内存/GB | GFLOPs | 时间/s |
---|---|---|---|
PSMNe | 4.83 | 937.9 | 0.393 |
GANe | 6.53 | 1936.98 | 2.43 |
GwcNe | 4.27 | 899.99 | 0.272 |
Bi3 | 10.74 | 4212.05 | 0.899 |
EDNe | 2.52 | 162.92 | 0.053 |
EDNet++ (本文模型) | 2.78 | 167.59 | 0.047 |

图6 KITTI 2015测试集的视差预测结果Fig, 6 Results of disparity prediction for KITTI 2015 testing data
在Middlebury数据集上测试了模型的泛化能力。所有模型都在Sceneflow上进行训练。由

图7 Middlebury 2014数据集的模型泛化能力可视化
Fig. 7 Evaluation of model generalization on Middlebury 2014 dataset
提出了一个高效的双目立体匹配网络框架,其中包括两阶段的组合代价矩阵和多尺度动态注意力残差模块。采用两阶段的理论将相似度矩阵和基于特征拼接的4D代价矩阵相结合,使模型的学习能力提高的同时,大幅提高算法的泛化能力,同时还生成了具有更少参数的代价矩阵。此外,多尺度动态注意力模块的使用大幅提高了残差学习框架的效率,并通过大量迁移实验证明了该模块在其他由粗到细粒度的框架的网络中也具有良好表现。以KITTI和Sceneflow数据集证明了该方法的优越性。
作者贡献声明
王志成:论文撰写、深度神经网络设计。
王泽灏:论文撰写、深度神经网络设计、实验实施。
参考文献
KENDALL A, MARTIROSYAN H, DASGUPTA S, et al. End-to-end learning of geometry and context for deep stereo regression[C]//2017 IEEE International Conference on Computer Vision (ICCV). Venice: IEEE, 2017: 66-75. [百度学术]
CHANG J, CHEN Y. Pyramid stereo matching network[C]//2018 IEEE/CVF Conference on Computer Vision and Pattern Recognition. Salt Lake City: IEEE, 2018: 5410-5418. [百度学术]
GUO X, YANG K, YANG W, et al. Group-wise correlation stereo network[C]//2019 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR). Long Beach: IEEE, 2019: 3268-3277. [百度学术]
ZHANG F, PRISACARIU V, YANG R, et al. Ga-net: Guided aggregation net for end-to-end stereo matching[C]//2019 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR). Long Beach: IEEE, 2019: 185-194. [百度学术]
MAYER N, ILG E, H ̈ AUSSER P , et al. A large dataset to train convolutional networks for disparity, optical flow, and scene flow estimation[C]//2016 IEEE Conference on Computer Vision and Pattern Recognition (CVPR). Las Vegas: IEEE, 2016: 4040-4048. [百度学术]
LIANG Z, FENG Y, GUO Y, et al. Learning for disparity estimation through feature constancy[C]//2018 IEEE/CVF Conference on Computer Vision and Pattern Recognition. Salt Lake City: IEEE, 2018: 2811-2820. [百度学术]
YANG G, ZHAO H, SHI J, et al. Segstereo: Exploiting semantic information for disparity estimation[C]//Proceedings of the European Conference on Computer Vision (ECCV). Munich: IEEE, 2018: 636-651. [百度学术]
PANG J, SUN W, REN J S, et al. Cascade residual learning: A two-stage convolutional neural network for stereo matching[C]//2017 IEEE International Conference on Computer Vision Workshops (ICCVW). Venice: IEEE, 2017: 878-886. [百度学术]
SCHARSTEIN D, SZELISKI R. A taxonomy and evaluation of dense two-frame stereo correspondence algorithms[J]. International Journal of Computer Vision, 2002, 47: 7. [百度学术]
ZBONTAR J, LECUN Y. Stereo matching by training a convolutional neural network to compare image patches[J]. Journal of Machine Learning Research, 2016, 17(65): 1. [百度学术]
DOSOVITSKIY A, FISCHER P, ILG E, et al. Flownet: Learning optical flow with convolutional networks[C]//2015 IEEE International Conference on Computer Vision (ICCV). Santiago: IEEE, 2015: 2758-2766. [百度学术]
CHEN Z, SUN X, WANG L, et al. A deep visual correspondence embedding model for stereo matching costs[C]//2015 IEEE International Conference on Computer Vision (ICCV). Santiago: IEEE, 2015: 972-980. [百度学术]
FENG Y, LIANG Z, LIU H. Efficient deep learning for stereo matching with larger image patches[C]//2017 10th International Congress on Image and Signal Processing, BioMedical Engineering and Informatics (CISP-BMEI). Shanghai: IEEE, 2017: 1-5. [百度学术]
NIE G, CHENG M, LIU Y, et al. Multi-level context ultra-aggregation for stereo matching[C]//2019 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR). Long Beach: IEEE, 2019: 3278-3286. [百度学术]
HUANG G, LIU Z, VAN DER Maaten L, et al. Densely connected convolutional networks[C]//2017 IEEE Conference on Computer Vision and Pattern Recognition (CVPR). Honolulu: IEEE, 2017: 2261-2269. [百度学术]
GU X, FAN Z, ZHU S, et al. Cascade cost volume for high-resolution multi-view stereo and stereo matching[C]//2020 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR). Seattle: IEEE, 2020: 2492-2501. [百度学术]
SHEN Z, DAI Y, RAO Z. Cfnet: Cascade and fused cost volume for robust stereo matching[C]//2021 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR). Nashville: IEEE, 2021: 13901-13910. [百度学术]
KHAMIS S, FANELLO S, RHEMANN C, et al. Stereonet: Guided hierarchical refinement for real-time edge-aware depth prediction[C]//Proceedings of the European Conference on Computer Vision (ECCV). Venice: IEEE, 2018: 573-590. [百度学术]
GIDARIS S, KOMODAKIS N. Detect , replace, refine: Deep structured prediction for pixel wise labeling[C]//2017 IEEE Conference on Computer Vision and Pattern Recognition (CVPR). Honolulu: IEEE, 2017: 7187-7196. [百度学术]
JIE Z, WANG P, LING Y, et al. Left-right comparative recurrent model for stereo matching[C]//2018 IEEE/CVF Conference on Computer Vision and Pattern Recognition. Salt Lake City: IEEE, 2018: 3838-3846. [百度学术]
YU A, GUO W, LIU B, et al. Attention aware cost volume pyramid based multi-view stereo network for 3d reconstruction[J]. ISPRS Journal of Photogrammetry and Remote Sensing. Netherlands: Elsevier, 2021, 175: 448. [百度学术]
STUCKER C, SCHINDLER K. Resdepth: Learned residual stereo reconstruction[C]//2020 IEEE/CVF Conference on Computer Vision and Pattern Recognition Workshops (CVPRW). Seattle: IEEE, 2020: 707-716. [百度学术]
RONNEBERGER O, FISCHER P, BROX T. U-net: convolutional networks for biomedical image segmentation[C]//2015 Medical Image Computing and Computer-Assisted Intervention (MICCAI). Munich: Springer Nature, 2015: 234-241. [百度学术]
WANG Y, LAI Z, HUANG G, et al. Anytime stereo image depth estimation on mobile devices[C]//2019 International Conference on Robotics and Automation (ICRA). Montreal: IEEE, 2019: 5893-5900. [百度学术]
CHENG X, ZHONG Y, HARANDI M, et al. Hierarchical neural architecture search for deep stereo matching[J]. Advances in Neural Information Processing Systems. Vancouver: IEEE, 2020, 33: 22158. [百度学术]
PASZKE A, GROSS S, MASSA F, et al. Pytorch: An imperative style, high-performance deep learning library[C]//WALLACH H, LAROCHELLE H, BEYGELZIMER A, et al. Advances in Neural Information Processing Systems: volume 32. Curran Associates, Inc., Vancouver: IEEE, 2019:8026-8037. [百度学术]
ZHANG S, WANG Z, WANG Q, et al. Ednet: Efficient disparity estimation with cost volume combination and attention-based spatial residual[C]//2021 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR). Nashville: IEEE, 2021: 5433-5442 [百度学术]
CHABRA R, STRAUB J, SWEENY C, et al. Stereodrnet: Dilated residual stereo net[J]. 2019 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR). Long Beach: IEEE, 2019: 11786-11795. [百度学术]
WANG Q, SHI S, ZHENG S, et al. FADNet: A fast and accurate network for disparity estimation[C]//2020 IEEE/International Conference on Robotics and Automation (ICRA). Paris: IEEE, 2020: 101-107. [百度学术]
XU H, ZHANG J, et al. Aanet: Adaptive aggregation network for efficient stereo matching[C]//Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR). Seattle: IEEE, 2020: 1956-1965. [百度学术]
XU G, CHENG J, GUO P, et al. Attention concatenation volume for accurate and efficient stereo matching[C]//Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition. New Orleans: IEEE, 2022: 12981-12990. [百度学术]
ZBONTAR J, LECUN Y. Computing the stereo matching cost with a convolutional neural network[C]//2015 IEEE Conference on Computer Vision and Pattern Recognition (CVPR). Boston: IEEE, 2015: 1592-1599. [百度学术]
YIN Z, DARRELL T, YU F. Hierarchical discrete distribution decomposition for match density estimation[C]//2019 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR). Long Beach: IEEE, 2019: 6037-6046. [百度学术]
DUGGAL S, WANG S, MA W, et al. Deeppruner: Learning efficient stereo matching via differentiable patchmatch[C]//2019 IEEE/CVF International Conference on Computer Vision (ICCV). Seoul: IEEE, 2019: 4383-4392. [百度学术]
BADKI A, TROCCOLI A, KIM K, et al. Bi3d: Stereo depth estimation via binary classifications[C]//Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR). Seattle: IEEE, 2020: 1597-1605. [百度学术]
YANG M, WU F, LI W. Rlstereo: Real-time stereo matching based on reinforcement learning[J]. IEEE Transactions on Image Processing, 2021, 30: 9442. [百度学术]
TONIONI A, TOSI F, POGGI M, et al. Real-time self-adaptive deep stereo[C]//2019 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR). Long Beach: IEEE, 2019: 195-204. [百度学术]