【问题标题】:Need help for proper rectilinear projection of equirectangular panoramic image需要帮助进行等距矩形全景图像的正确直线投影
【发布时间】:2014-03-27 01:01:30
【问题描述】:

使用下面的算法,当投影平面与赤道相切时(等角矩形图像的中心线),投影图像看起来是直线的。

但是当投影平面倾斜时,(py0 !=panorama.height/2),线条会扭曲。

下面算法中的最后两条“线”需要“修正”,以便在目标平面的中心线与等矩形的中心线不在同一水平线上时调整 px 和/或 py图片。

  // u,v,w :
  //     Normalized 3D coordinates of the destination pixel

  // elevation, azimuth:
  //     Angles between the origin (sphere center) and the destination pixel

  // px0, py0 :
  //     2D coordinates in the equirectangular image for the
  //     the destination plane center (long*scale,lat*scale)

  // px, py:
  //     2D coordinates of the source pixel in the equirectangular image
  //     (long*scale,lat*scale)

  angularStep=2*PI/panorama.width;
  elevation=asin(v/sqrt(u*u+v*v+w*w));
  azimuth=-PI/2+atan2(w,u);
  px=px0+azimuth/angularStep;
  py=py0+elevation/angularStep;

我可以计算每个目标像素的法线与球体的交点 p,然后使用可用的 C 代码将笛卡尔坐标转换为 long/lat:

但我知道有一种更简单且耗时少得多的方法,包括调整等距矩形图像 (px,py) 中的源像素坐标,知道投影平面中心与“球体”。

你能帮忙吗?

【问题讨论】:

    标签: 3d trigonometry panoramas projective-geometry


    【解决方案1】:

    我设法使用 webgl 着色器 http://mathworld.wolfram.com/GnomonicProjection.html 中的 gnomonic 投影公式来实现这一点

                float angleOfView   
    
                float phi1          
                float lambda0     //centre of output projection
    
                float x = PI2*(vTextureCoord.s - 0.5) ;  //input texture coordinates, 
                float y = PI2*(vTextureCoord.t - 0.5 ); 
    
                float p = sqrt(x*x + y*y);
    
                float c = atan(p, angleOfView); 
    
                float phi = asin( cos(c)*sin(phi1) + y*sin(c)*cos(phi1)/p );
    
                float lambda = lambda0 + atan( x*sin(c), (p*cos(phi1)*cos(c) - y*sin(phi1)*sin(c)));
    
                vec2 tc = vec2((lambda /(PI*2.0) + 0.5, (phi/PI) + 0.5); //reprojected texture coordinates 
    
                vec4 texSample  =  texture2D(tEqui, tc); //sample using new coordinates
    

    【讨论】:

    • 嗨。我一直在寻找解决方案,我发现您的答案似乎效果很好。但我有个问题。你为什么将这些公式应用于开始的纹理坐标和最后的 lambda 和 phi?也是PI2,PI * 2?
    猜你喜欢
    • 1970-01-01
    • 2010-11-06
    • 1970-01-01
    • 2011-10-03
    • 2012-02-10
    • 2014-02-28
    • 2014-04-23
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多