2014-02-25 6 views
5

Mit dem Algorithmus unten, wenn die Projektionsebene Tangente an den Äquator (die Mittellinie der equirectangular Bild), projizierte Bild sieht geradlinig.Brauchen Sie Hilfe für richtig geradlinige Projektion von equirectangular Panorama-Bild

Rectilinear image

Aber wenn die Projektionsebene geneigt ist, (PY0! = Panorama.height/2), sind die Linien verzogen.

Warped image

die beiden letzten „Linien“ im Algorithmus muss unten „korrigiert“ werden, um px und/oder py, wenn die Mittellinie der Zielebene anzupassen nicht auf dem gleichen Niveau ist als die Mittellinie des equirectangular Bildes.

// 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; 

ich den Schnittpunkt p zwischen dem normalen jedem Zielpixel berechnen kann und die Kugel, dann wandeln kartesische Koordinaten zu lang/lat mit dem verfügbaren Code C:

projection

Aber ich weiß, dass es eine einfachere und viel weniger zeitaufwendige Methode, bei der die Quellpixelkoordinaten in einem equirektangulären Bild (px, py) mit dem Längen-/Breitengrad (px0, py0) eingestellt werden, bei dem der Mittelpunkt der Projektionsebene die "Kugel" schneidet.

Könnten Sie bitte helfen?

Antwort

0

ich es geschafft, dies in einem webgl Shader http://mathworld.wolfram.com/GnomonicProjection.html

  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 
+0

Hallo mit der Formel für gnomonic Projektion zur Arbeit zu kommen. Ich suchte nach einer Lösung dafür und ich fand deine Antwort, die gut zu funktionieren scheint. Ich habe jedoch eine Frage. Warum wenden Sie diese Formeln auf die Texturkoordinaten am Anfang und auf das Lambda und Phi am Ende an? Ist auch PI2, PI * 2? – Solidus