Its code implementation is:
// Step 4. 亚像素插值, 使用最佳匹配点及其左右相邻点构成抛物线来得到最小sad的亚像素坐标
// 使用3点拟合抛物线的方式,用极小值代替之前计算的最优是差值
// \ / <- 由视差为14,15,16的相似度拟合的抛物线
// . .(16)
// .14 .(15) <- int/uchar最佳视差值
// .
// (14.5)<- 真实的视差值
// deltaR = 15.5 - 16 = -0.5
// 公式参考opencv sgbm源码中的亚像素插值公式
// 或论文<<On Building an Accurate Stereo Matching System on Graphics Hardware>> 公式7
const float dist1 = vDists[L+bestincR-1];
const float dist2 = vDists[L+bestincR];
const float dist3 = vDists[L+bestincR+1];
const float deltaR = (dist1-dist3)/(2.0f*(dist1+dist3-2.0f*dist2));
The deltaR here is , the specific formula is as follows:
subpixel ineterpolation sub-pixel interpolation (conic curve fitting parallax value)
The derivation here is as follows:
That is, const float deltaR = (dist1-dist3)/(2.0f*(dist1+dist3-2.0f*dist2)); deltaR in the above formula is when h is 1
Reference: [Algorithm] Concise Analysis of OpenCV-SGBM Algorithm and Source Code_JinSu_'s Blog-CSDN Blog