写在前面
- 本文内容
先容epe的概念,作用;
由epe推导出的不同间隔下的物理偏差曲线
一句话简单理解:epe是用于深度估计、以像素为单元的偏差度量方式
- 平台/环境
python
- 转载请注明出处:
https
EPE
FoundationStereo: Zero-Shot Stereo Matching文中的描述是:
“EPE” computes average per-pixel disparity error. “BP-X” computes the percentage of pixels where the disparity error is larger than X pixels. “D1” computes the percentage of pixels whose disparity error is larger than 3 pixels and 5% of the ground-truth disparity
在深度估计中,EPE(End-Point Error,端点偏差) 是一种用于权衡预测视差(disparity)与真实视差之间偏差的指标。其焦点头脑是逐像素比力预测值与真实值的差异,并计算全局均匀偏差。以下是详细解释:
1. 视差与深度的关系
- 视差(Disparity) 是立体视觉中左右图像中对应点的程度位移(单元为像素)。通过视差可以推导深度(depth):
[ 深度 = 焦距 × 基线间隔 视差 ] [\text{深度} = \frac{\text{焦距} \times \text{基线间隔}}{\text{视差}} ] [深度=视差焦距×基线间隔]
视差越小,物体间隔越远;视差越大,物体间隔越近。
2. EPE 的计算方法
EPE 的定义非常简单:
[ EPE = 1 N ∑ i = 1 N ∣ 预测视差 i − 真实视差 i ] [\text{EPE} = \frac{1}{N} \sum_{i=1}^{N} | \text{预测视差}_i - \text{真实视差}_i] [EPE=N1i=1∑N∣预测视差i−真实视差i]
其中:
- N是图像中有效像素的总数(通常会忽略无真实值的像素)。
- 对每个像素的预测偏差取绝对值(L1 范数),然后计算全部像素的均匀值。
3. EPE 的特点
- 直观性:直接反映模型在每个像素上的预测精度。
- 单元一致性:视差单元为像素,EPE 的单元也是像素。例如,EPE=1 表现均匀每个像素的预测偏差为 1 像素。
- 局限性:仅权衡数值偏差,不反映结构偏差(如边沿模糊或物体形状错误)。
4. 与其他指标的关系
- MAE(Mean Absolute Error):与 EPE 等价,但 EPE 更常用于视差/光流任务。
- RMSE(Root Mean Square Error):对偏差取平方后开根号,对大偏差更敏感。
- Bad Pixel Rate:像素偏差率( BP-X,Bad Pixel-X),通常计算的是视差偏差大于某个阈值(如 3 像素)的像素占总像素的比例。而 EPE 则是全部像素偏差的均匀值。EPE 更能反映整体的偏差,而像素偏差率更关注偏差较大的像素的比例。
5. 为何使用 EPE?
在深度估计任务中,视差是中心效果(终极深度需通过几何公式转换)。EPE 直接评估视差预测的精确性,是模型性能的焦点指标。较小的 EPE 意味着更精确的深度估计。
举例
假设预测视差图某像素值为 30,真实值为 28,则偏差为 ( ∣ 30 − 28 ∣ = 2 ) (|30-28|=2) (∣30−28∣=2)。若全图均匀此类偏差为 1.5 像素,则 EPE=1.5。
总结
EPE 是深度估计中权衡视差预测精度的底子指标,通过逐像素偏差的均匀值反映模型性能,值越小表现模型越准确。
计算
根据深度-视差计算原理
Z = b ∗ f d , d = b ∗ f Z Z=\frac{b*f}{d}, d=\frac{b*f}{Z} Z=db∗f,d=Zb∗f
以415传感器实际数据为例:
传感器(ov2740)大小:2.7288mm1.5498mm
基线b=55mm
在1280720分辨率下,f=910(pixel)
当物距为Z=1m(1000mm)时:
d = 55910/1000 = 50.05(pixel)
当存在双目匹配偏差且偏差为pe=0.42(pixel时), d = d+pe = 50.47,
Z’ = 55910/50.47 = 991.67(mm)
深度偏差为abs: Ze=Z’ - Z=8.33mm, relative: 8.33/1000 = 0.833%
代码
- import numpy as np
- import matplotlib.pyplot as plt
- def computeEPE(baseline, fx, depth, pe):
- bf = baseline * fx
- d_pixel = bf / depth
- abs_error = abs(bf / (d_pixel + pe) - depth)
- relative_error = abs(abs_error / depth)
- return abs_error, relative_error
- if __name__ == "__main__":
- # "EPE" computes average per-pixel disparity error
- epe_list = [0.34, 0.42, 0.50]
- # # 250mm - 1000mm
- distance_list = [250, 500, 600, 700, 800, 900, 1000]
- # 250mm - 10000mm
- # distance_list = [
- # 250,
- # 500,
- # 1000,
- # 2000,
- # 3000,
- # 4000,
- # 5000,
- # 6000,
- # 7000,
- # 8000,
- # 9000,
- # 10000,
- # ]
- # realsense 415 base_line=55mm 1920x1080 focal=910
- focal = 910
- base_line = 55
- # 为每个 epe 值绘制一张图
- for epe in epe_list:
- abs_error_list = []
- relative_error_list = []
- for distance in distance_list:
- abs_error, relative_error = computeEPE(base_line, focal, distance, epe)
- abs_error_list.append(abs_error)
- relative_error_list.append(relative_error)
- # 创建一个包含两个子图的图表
- plt.figure(figsize=(12, 6))
- # 第一个子图:绝对误差
- plt.subplot(1, 2, 1)
- plt.plot(distance_list, abs_error_list, label="Absolute Error", marker="o")
- plt.xlabel("Distance (mm)")
- plt.ylabel("Absolute Error")
- plt.title(f"Absolute Error vs Distance (EPE={epe})")
- plt.grid(True)
- # 第二个子图:相对误差
- plt.subplot(1, 2, 2)
- plt.plot(distance_list, relative_error_list, label="Relative Error", marker="x")
- plt.xlabel("Distance (mm)")
- plt.ylabel("Relative Error")
- plt.title(f"Relative Error vs Distance (EPE={epe})")
- plt.grid(True)
- # 调整布局,防止重叠
- plt.tight_layout()
- plt.show()
复制代码 效果曲线
epe=0.34

epe=0.42

epe=0.5

参考
FoundationStereo: Zero-Shot Stereo Matching
完
主要做激光/影像三维重修,配准、分割等常用点云算法,熟悉open3d、pcl等开源点云库,技术交流、咨询可私信
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。 |