【问题标题】:Conversion from dual fisheye coordinates to equirectangular coordinates双鱼眼坐标到等角坐标的转换
【发布时间】:2018-04-03 15:29:00
【问题描述】:

以下link 建议我们可以使用以下等式将双鱼眼坐标转换为等角坐标:

// 2D fisheye to 3D vector
phi = r * aperture / 2
theta = atan2(y, x)

// 3D vector to longitude/latitude
longitude = atan2(Py, Px)
latitude = atan2(Pz, (Px^2 + Py^2)^(0.5))

// 3D vector to 2D equirectangular
x = longitude / PI
y = 2 * latitude / PI

我应用上述方程来编写我的源代码,如下所示:

const float FOV = 220.0f * PI / 180.0f;
float r = sqrt(u*u + v*v);
float theta = atan2(v, u);
float phi = r * FOV * 0.5f;
float px = u;
float py = r * sin(phi);
float pz = v;
float longitude = atan2(py, px); // theta
float latitude = atan2(pz, sqrt(px*px + py*py)); // phi
x = longitude / PI;
y = 2.0f * latitude / PI;

不幸的是,我的数学不够好,无法理解这一点,并且不确定我是否正确编写了上面的代码,我试图猜测 px、py 和 pz 的值。

假设我的相机 FOV 为 220 度,相机分辨率为 2880x1440,我希望重叠区域的后置摄像头点 (358, 224) 和重叠区域的前置摄像头点 (2563, 197)都将映射到接近 (2205, 1009) 的坐标。但是实际映射点分别是(515.966370,1834.647949)和(1644.442017,1853.060669),它们都离(2205,1009)很远。请建议如何修复上述代码。非常感谢!

【问题讨论】:

    标签: c++ fisheye spherical-coordinate


    【解决方案1】:

    您正在构建 equirectangular 图像,所以我建议您使用逆映射。

    从您正在绘制的目标图像中的像素位置开始。将 2D 位置转换为经度/纬度。然后将其转换为单位球体表面上的 3D 点。然后从 3D 点转换为 2D 鱼眼源图像中的某个位置。在 Paul Bourke 页面中,您将从底部方程开始,然后是最右边的方程,然后是最顶部的方程。

    使用像 90° 长 0° 纬度这样的标志点来验证结果在每个步骤中是否有意义。

    最终结果应该是源鱼眼图像中 [-1..+1] 范围内的位置。根据需要重新映射到像素或 UV。由于源被分成两个眼睛图像,因此您还需要从目标(等距)经度到正确的源子图像的映射。

    【讨论】:

      猜你喜欢
      • 2017-09-30
      • 2011-11-09
      • 2014-06-18
      • 1970-01-01
      • 1970-01-01
      • 2017-02-05
      • 1970-01-01
      • 2017-03-04
      • 1970-01-01
      相关资源
      最近更新 更多