Sie sind nicht angemeldet.

1

Donnerstag, 20. November 2014, 05:48

How to get the absolute coordinates of a point in panorama

Hi,

I want to get the absolute coordinates of a point in panorama.

In flat image



In panorama,is there any way to get the absolute coordinates of this point(result: x:200px y:100px)







Thanks

2

Donnerstag, 20. November 2014, 09:14

Hi,

you could first use the screentosphere() action to get the position in degrees and then remap them linearly to the pixelsize of the source image.

Here a full example code that does everything automatically for multires-cube panos (it takes the source pano size from largest multires level):

Quellcode

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<!-- first get the h/v coordinates in degrees from the current mouse position -->
screentosphere(mouse.x, mouse.y, h, v);

<!-- get the highest/largest multires level index (0-based) -->
sub(largestlevelindex, image.level.count, 1);

<!-- get the width of the largest levels -->
copy(cubewidth, image.level[get(largestlevelindex)].tiledimagewidth);

<!-- calculate the spherical pano size --> 
mul(spherewidth, cubewidth, Math.PI);
mul(sphereheight, spherewidth, 0.5);

<!-- linearly map the degrees values to the pixel positions -->
div(px, h, 360);
add(px, 0.5);
mul(px, spherewidth);
roundval(px);
div(py, v, 180);
add(py, 0.5);
mul(py, sphereheight);
roundval(py);

<!-- done - trace the results -->
trace('pixelpos=',px,'/',py);


Best regards,
Klaus