average per-pixel disparity error: EPE及不同间隔值下的偏差曲线 ...

打印 上一主题 下一主题

主题 2042|帖子 2042|积分 6126

写在前面



  • 本文内容
    先容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=N1​i=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
在1280
720分辨率下,f=910(pixel)
当物距为Z=1m(1000mm)时:
d = 55910/1000 = 50.05(pixel)
当存在双目匹配偏差且偏差为pe=0.42(pixel时), d = d+pe = 50.47,
Z’ = 55
910/50.47 = 991.67(mm)
深度偏差为abs: Ze=Z’ - Z=8.33mm, relative: 8.33/1000 = 0.833%
代码
  1. import numpy as np
  2. import matplotlib.pyplot as plt
  3. def computeEPE(baseline, fx, depth, pe):
  4.     bf = baseline * fx
  5.     d_pixel = bf / depth
  6.     abs_error = abs(bf / (d_pixel + pe) - depth)
  7.     relative_error = abs(abs_error / depth)
  8.     return abs_error, relative_error
  9. if __name__ == "__main__":
  10.     # "EPE" computes average per-pixel disparity error
  11.     epe_list = [0.34, 0.42, 0.50]
  12.     # # 250mm - 1000mm
  13.     distance_list = [250, 500, 600, 700, 800, 900, 1000]
  14.     # 250mm - 10000mm
  15.     # distance_list = [
  16.     #     250,
  17.     #     500,
  18.     #     1000,
  19.     #     2000,
  20.     #     3000,
  21.     #     4000,
  22.     #     5000,
  23.     #     6000,
  24.     #     7000,
  25.     #     8000,
  26.     #     9000,
  27.     #     10000,
  28.     # ]
  29.     # realsense 415 base_line=55mm 1920x1080 focal=910
  30.     focal = 910  
  31.     base_line = 55
  32.     # 为每个 epe 值绘制一张图
  33.     for epe in epe_list:
  34.         abs_error_list = []
  35.         relative_error_list = []
  36.         for distance in distance_list:
  37.             abs_error, relative_error = computeEPE(base_line, focal, distance, epe)
  38.             abs_error_list.append(abs_error)
  39.             relative_error_list.append(relative_error)
  40.         # 创建一个包含两个子图的图表
  41.         plt.figure(figsize=(12, 6))
  42.         # 第一个子图:绝对误差
  43.         plt.subplot(1, 2, 1)
  44.         plt.plot(distance_list, abs_error_list, label="Absolute Error", marker="o")
  45.         plt.xlabel("Distance (mm)")
  46.         plt.ylabel("Absolute Error")
  47.         plt.title(f"Absolute Error vs Distance (EPE={epe})")
  48.         plt.grid(True)
  49.         # 第二个子图:相对误差
  50.         plt.subplot(1, 2, 2)
  51.         plt.plot(distance_list, relative_error_list, label="Relative Error", marker="x")
  52.         plt.xlabel("Distance (mm)")
  53.         plt.ylabel("Relative Error")
  54.         plt.title(f"Relative Error vs Distance (EPE={epe})")
  55.         plt.grid(True)
  56.         # 调整布局,防止重叠
  57.         plt.tight_layout()
  58.         plt.show()
复制代码
效果曲线
epe=0.34

epe=0.42

epe=0.5

参考

FoundationStereo: Zero-Shot Stereo Matching


主要做激光/影像三维重修,配准、分割等常用点云算法,熟悉open3d、pcl等开源点云库,技术交流、咨询可私信

免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

x
回复

使用道具 举报

0 个回复

倒序浏览

快速回复

您需要登录后才可以回帖 登录 or 立即注册

本版积分规则

笑看天下无敌手

论坛元老
这个人很懒什么都没写!
快速回复 返回顶部 返回列表