Partial Panoramas using ROI in PTViewer

From PanoTools.org Wiki
(Difference between revisions)
Jump to: navigation, search
Line 27: Line 27:
  
 
Since we know the ROI Width of the picture as well as the Horizontal Field of View (HFOV), we can calculate the field of view for 1 pixel.
 
Since we know the ROI Width of the picture as well as the Horizontal Field of View (HFOV), we can calculate the field of view for 1 pixel.
In this case 180� / 800 pixels = 0.2�/px
+
In this case  
 +
<pre>
 +
180� / 800 pixels = 0.2�/px
 +
</pre>
  
 
With that we can calculate the Vertical Field of View (VFOV)
 
With that we can calculate the Vertical Field of View (VFOV)
 +
<pre>
 
VFOV = 541 px * 0.2�/px = 108�
 
VFOV = 541 px * 0.2�/px = 108�
 +
</pre>
  
 
The objective is to place the ROI picture inside the 360�x180� panorama with the horizon in the ROI image over the horizontal 0� line, and the middle of the ROI image at compass-angle the picture was taken as (or in the middle of the panorama if compass-direction is not important).
 
The objective is to place the ROI picture inside the 360�x180� panorama with the horizon in the ROI image over the horizontal 0� line, and the middle of the ROI image at compass-angle the picture was taken as (or in the middle of the panorama if compass-direction is not important).
Line 37: Line 42:
 
To do that we first need to calculate the total size of the panorama image, of which the ROI image is a part of.  
 
To do that we first need to calculate the total size of the panorama image, of which the ROI image is a part of.  
 
The calculation is similar to the previous calculation but then the other way around. Since we know the degrees, we can calculate the number of pixels.
 
The calculation is similar to the previous calculation but then the other way around. Since we know the degrees, we can calculate the number of pixels.
 +
<pre>
 
Panorama Width (Pwidth) = 360� / 0.2�/px = 1800 px
 
Panorama Width (Pwidth) = 360� / 0.2�/px = 1800 px
 
Panorama Height (Pheigth) = 180� / 0.2/px = 900 px
 
Panorama Height (Pheigth) = 180� / 0.2/px = 900 px
 +
</pre>
  
== x and y offset ==
+
== x and y insert point ==
To calculate the x and y offset of where the picture needs to be placed we calculate the following
+
To calculate the x and y position of the insertion point (the point where the picture needs to be placed)
  
We know that the horizon in the large panorama is halfway.
+
We can calculate that by taking half of the panorama height and subtracting the horizon position in the ROI.
900 px / 2 =  450 px
+
<pre>
By subtracting the horizon position we end up with the Y offset.
+
Y Offset = 900px/2 227px = 223px
Y Offset = 450 px 227 px = 223 px
+
</pre>
  
 
Similarly we can calculate the x offset.  
 
Similarly we can calculate the x offset.  
In most circumstances, you either don�t know, or don�t care about the direction the picture was taken. In that case it is good practice to place the ROI in the middle of the large pano where 0� is the middle of the picture.
+
In most circumstances, you either don�t know, or don�t care about the direction the picture was taken. In that case it is good practice to place the ROI in the middle of the large pano where 0� is the middle of the picture. You can do this by taking half of the total panorama width and subtracting half the size of the picture  
You can do this by taking half of the total panorama width 1800 px / 2 = 900 px
+
<pre>
And subtracting half the size of the picture (in this case 800 px / 2 = 400 px)
+
X Offset = 1800px/2 800px/2 = 500 px
X Offset = 900 px 400 px = 500 px
+
</pre>
  
 
== panmin, panmax, tiltmin and tiltmax ==
 
== panmin, panmax, tiltmin and tiltmax ==
Line 61: Line 68:
  
 
Because the ROI is horizontally in the middle, you may pan half the width of the image to the left and right, converted to degrees.
 
Because the ROI is horizontally in the middle, you may pan half the width of the image to the left and right, converted to degrees.
 +
<pre>
 
Minimum pan = -800px/2 * 0.2�/px = -80�
 
Minimum pan = -800px/2 * 0.2�/px = -80�
 
Maximum pan = 800px/2 * 0.2�/px = 80�
 
Maximum pan = 800px/2 * 0.2�/px = 80�
 +
</pre>
  
 
The minumum tilt is calculated as the position of the horizon, converted to degrees.
 
The minumum tilt is calculated as the position of the horizon, converted to degrees.
 +
<pre>
 
Minimum tilt = -227px * 0.2�/px = -45.4� => 45�
 
Minimum tilt = -227px * 0.2�/px = -45.4� => 45�
 +
</pre>
 +
 
The maximum tilt is calculated as the height of the ROI minus the position of the horizon, converted to degrees.
 
The maximum tilt is calculated as the height of the ROI minus the position of the horizon, converted to degrees.
 +
<pre>
 
Maximum tilt = (541px � 227px) * 0.2�/px = 62.8� => 62�
 
Maximum tilt = (541px � 227px) * 0.2�/px = 62.8� => 62�
 +
</pre>
  
 
Because the ptviewer does not take fractions of degrees, you throw away the fraction.
 
Because the ptviewer does not take fractions of degrees, you throw away the fraction.
Line 74: Line 88:
  
 
Good luck.
 
Good luck.
 +
 +
Richard Korff

Revision as of 16:55, 19 March 2005

If you have a panorama that is not fully 360�x180�, and you still want to use PTViewer to immerse your audience into your panorama, there are a few methods to do that.

You can expand your Panorama with blank space around, and use the normal way of displaying a panorama in PTViewer. The disadvantage of this is that if you put this picture online, the download times can be significantly longer because of all the blank space.

To avoid this, it is possible to use a Region Of Interest picture (ROI) to display the panorama. This will only download the partial panorama. We will have to tell PTViewer where to place the picture, and how far the user may pan left and right, and how much they can tilt up and down.

Note this is not an explanation of the syntax of PTViewer, rather a tutorial on how to calculate the different parameters. For the syntax on PTViewer you can visit : PTViewer Documentation

Contents

Gathering Information

Sample image

From the ROI picture we need to get some basic information :

  • Width in pixels (ROI Width) 800 px
  • Height in pixels (ROI Height) 541 px
  • Position of the horizon from the top of the picture (Horizon pos) 227 px

From the sticther we should be able to get the Horizontal Field of View (HFOV) 160�

From these 4 numbers we should be able to calculate the parameters necessary for PTViewer to display a partial panorama.

Calculating the parameters for PTViewer

Sample overview


Since we know the ROI Width of the picture as well as the Horizontal Field of View (HFOV), we can calculate the field of view for 1 pixel. In this case

180� / 800 pixels = 0.2�/px

With that we can calculate the Vertical Field of View (VFOV)

VFOV = 541 px * 0.2�/px = 108�

The objective is to place the ROI picture inside the 360�x180� panorama with the horizon in the ROI image over the horizontal 0� line, and the middle of the ROI image at compass-angle the picture was taken as (or in the middle of the panorama if compass-direction is not important).

pwidth and pheight

To do that we first need to calculate the total size of the panorama image, of which the ROI image is a part of. The calculation is similar to the previous calculation but then the other way around. Since we know the degrees, we can calculate the number of pixels.

Panorama Width (Pwidth) = 360� / 0.2�/px = 1800 px
Panorama Height (Pheigth) = 180� / 0.2/px = 900 px

x and y insert point

To calculate the x and y position of the insertion point (the point where the picture needs to be placed)

We can calculate that by taking half of the panorama height and subtracting the horizon position in the ROI.

Y Offset = 900px/2 � 227px = 223px

Similarly we can calculate the x offset. In most circumstances, you either don�t know, or don�t care about the direction the picture was taken. In that case it is good practice to place the ROI in the middle of the large pano where 0� is the middle of the picture. You can do this by taking half of the total panorama width and subtracting half the size of the picture

X Offset = 1800px/2 � 800px/2 = 500 px

panmin, panmax, tiltmin and tiltmax

To limit the freedom the user has in moving around your pano, you want to restrict the pan and tilt angles.

To calculate this is relatively easy with the information we have gathered above. The pan and tilt angles are calculated in degrees.

Because the ROI is horizontally in the middle, you may pan half the width of the image to the left and right, converted to degrees.

Minimum pan = -800px/2 * 0.2�/px = -80�
Maximum pan = 800px/2 * 0.2�/px = 80�

The minumum tilt is calculated as the position of the horizon, converted to degrees.

Minimum tilt = -227px * 0.2�/px = -45.4� => 45�

The maximum tilt is calculated as the height of the ROI minus the position of the horizon, converted to degrees.

Maximum tilt = (541px � 227px) * 0.2�/px = 62.8� => 62�

Because the ptviewer does not take fractions of degrees, you throw away the fraction.

Using these numbers in PTViewer should give you a good partial panorama. If you see blank space at the sides of the panorama, you may want to make a 1 degree change to the minimum and maximum pan and tilt untill it does not show up anymore.

Good luck.

Richard Korff

Personal tools
Namespaces

Variants
Actions
Navigation
tools
Tools