Hi. I'm having an issue related to converting my hotspots' cylindrical coordinates to width/height coordinates.
Context: I have thousands of hotspots defined throughout hundreds of my cylindrical panoramas.
Now I need to get their width/height pixel location equivalents on the original images.
Converting ath -> x works perfectly fine, however for atv there's a varying vertical offset I'm getting.
I'm using formulas posted by Klaus in a different thread:
|
Source code
|
1
2
3
4
5
|
ath = ((x / width) - 0.5) * hfov
atv = ((y / height) - 0.5) * vfov
where for cylindrical panorama:
hfov = 360
vfov = 360 * arctan(height/width * PI) / PI
|
Example:
1. I have an image of size: 28133 x 6608.
2. I make a panorama out of it using makepano and following settings:
|
Source code
|
1
2
3
4
5
|
makepano -config=base.config -panotype=cylinder -hfov=360 -vfov=auto -voffset=0
...
converttocube=true
converttocubelimit=360x30
maxcubesize=2048
|
Note: makepano generates
vlookatmin="-36.424" and vlookatmax="36.424"
3. In the viewer using textfield plugin showing draggable cursor's ath/atv I pick an exact point eg. top of a mountain.
It gives me following coordinates: ath="-74.99364949868569" atv="-19.815171882512473"
What produces aforementioned ath/atv coordinates is a result of an action:
|
Source code
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
<action name="draghotspot">
<![CDATA[
if(%1 != dragging,
spheretoscreen(ath, atv, hotspotcenterx, hotspotcentery);
sub(drag_adjustx, mouse.stagex, hotspotcenterx);
sub(drag_adjusty, mouse.stagey, hotspotcentery);
draghotspot(dragging);
,
if(pressed,
sub(dx, mouse.stagex, drag_adjustx);
sub(dy, mouse.stagey, drag_adjusty);
screentosphere(dx, dy, ath, atv);
copy(print_ath, ath);
copy(print_atv, atv);
txtadd(plugin[hotspotinfo].html, '<hotspot name="', get(name), '" ath="', get(print_ath), '" atv="', get(print_atv), '"/>');
set(pointer_name, get(name));
set(pointer_ath, get(ath));
set(pointer_atv, get(atv));
delayedcall(0, draghotspot(dragging) );
);
);
]]></action>
|
4. When I store the ath/atv output and render a panorama with this hotspot and its atv/atv layered it points exactly in the place I picked. It's been working for years for hundreds of panoramas.
5. Now the very same point on the source image has following XY px coordinates: 8206, 1690
Calculating manually ath and atv gives following results:
|
Source code
|
1
2
3
4
|
Image: 28133 x 6608
ath = -74.993068638254007748906977570824
vfov = 360 * arctan( 6608/28133 * PI ) / PI = 72.8480327
atv = -17.7930878901
|
That proves that the ath is correct but in atv -> height conversion there's a difference of -2.022083992412473 degrees (viewer yields -19.815171882512473 as mentioned above, but it should yield
-17.7930878901).
Note: looking at different points in height yields good conversion in the middle (ath = 0), but the further the point from the middle of the image horizon the offset is bigger. Given that I feel it's related to cylindrical-cubic projection?
Any help appreciated.
Firstly, why the viewer is yielding incorrect atv or what I've been doing wrong for years?
Secondly, how to convert existing points (ath, atv) to width/height pixel values?
Thanks