Module: Tracksperanto::UVCoordinates

Included in:
Export::SynthEyes, Import::Syntheyes, Tool::LensDisto
Defined in:
lib/tracksperanto/uv_coordinates.rb

Overview

For Syntheyes, zero is at the optical center of the image, and goes positive right and up. The corners get the [-1..1] coordinates respectively. Since Tracksperanto works in absolute pixels we need to convert to and from these cords. Note that Syntheyes actually assumes the center of the first pixel to be at -1,1 so a small adjustment is necessary to maintain subpixel accuracy.

Instance Method Summary collapse

Instance Method Details

#absolute_to_uv(abs_x, abs_y, w, h) ⇒ Object

Convert absoilute X and Y values off the BL corner into Syntheyes UV coordinates



10
11
12
# File 'lib/tracksperanto/uv_coordinates.rb', line 10

def absolute_to_uv(abs_x, abs_y, w, h)
  [convert_to_uv(abs_x, w), convert_to_uv(abs_y, h) * -1]
end

#convert_from_uv(uv_value, absolute_side) ⇒ Object

Convert Syntheyes UV value into absoilute pixel value off the BL corner



20
21
22
23
24
# File 'lib/tracksperanto/uv_coordinates.rb', line 20

def convert_from_uv(uv_value, absolute_side)
  # Account for the fact that Syntheyes assumes the
  # pixel values to be at the center of the pixel
  abs_value = (((uv_value.to_f / 2.0) + 0.5) * (absolute_side.to_f - 1)) + 0.5
end

#convert_to_uv(abs_value, absolute_side) ⇒ Object

Convert absoilute pixel value off the BL corner into Syntheyes UV coordinate



15
16
17
# File 'lib/tracksperanto/uv_coordinates.rb', line 15

def convert_to_uv(abs_value, absolute_side)
  uv_value = (((abs_value.to_f - 0.5) / (absolute_side.to_f - 1)) - 0.5) * 2.0
end