Class: Panomosity::Neighborhood
- Inherits:
-
Object
- Object
- Panomosity::Neighborhood
- Includes:
- Utils
- Defined in:
- lib/panomosity/neighborhood.rb
Instance Attribute Summary collapse
-
#center ⇒ Object
Returns the value of attribute center.
-
#control_points ⇒ Object
Returns the value of attribute control_points.
-
#control_points_within_std ⇒ Object
Returns the value of attribute control_points_within_std.
-
#distance ⇒ Object
Returns the value of attribute distance.
-
#pair ⇒ Object
Returns the value of attribute pair.
-
#pair_distance ⇒ Object
Returns the value of attribute pair_distance.
-
#prdist_avg ⇒ Object
Returns the value of attribute prdist_avg.
-
#prdist_std ⇒ Object
Returns the value of attribute prdist_std.
-
#prx_avg ⇒ Object
Returns the value of attribute prx_avg.
-
#prx_std ⇒ Object
Returns the value of attribute prx_std.
-
#pry_avg ⇒ Object
Returns the value of attribute pry_avg.
-
#pry_std ⇒ Object
Returns the value of attribute pry_std.
Instance Method Summary collapse
- #calculate ⇒ Object
- #info ⇒ Object
-
#initialize(center:, pair:, distance:) ⇒ Neighborhood
constructor
A new instance of Neighborhood.
Methods included from Utils
#calculate_average, #calculate_average_and_std, #remove_outliers
Constructor Details
#initialize(center:, pair:, distance:) ⇒ Neighborhood
Returns a new instance of Neighborhood.
10 11 12 13 14 |
# File 'lib/panomosity/neighborhood.rb', line 10 def initialize(center:, pair:, distance:) @center = center @pair = pair @distance = distance end |
Instance Attribute Details
#center ⇒ Object
Returns the value of attribute center.
7 8 9 |
# File 'lib/panomosity/neighborhood.rb', line 7 def center @center end |
#control_points ⇒ Object
Returns the value of attribute control_points.
7 8 9 |
# File 'lib/panomosity/neighborhood.rb', line 7 def control_points @control_points end |
#control_points_within_std ⇒ Object
Returns the value of attribute control_points_within_std.
7 8 9 |
# File 'lib/panomosity/neighborhood.rb', line 7 def control_points_within_std @control_points_within_std end |
#distance ⇒ Object
Returns the value of attribute distance.
7 8 9 |
# File 'lib/panomosity/neighborhood.rb', line 7 def distance @distance end |
#pair ⇒ Object
Returns the value of attribute pair.
7 8 9 |
# File 'lib/panomosity/neighborhood.rb', line 7 def pair @pair end |
#pair_distance ⇒ Object
Returns the value of attribute pair_distance.
7 8 9 |
# File 'lib/panomosity/neighborhood.rb', line 7 def pair_distance @pair_distance end |
#prdist_avg ⇒ Object
Returns the value of attribute prdist_avg.
7 8 9 |
# File 'lib/panomosity/neighborhood.rb', line 7 def prdist_avg @prdist_avg end |
#prdist_std ⇒ Object
Returns the value of attribute prdist_std.
7 8 9 |
# File 'lib/panomosity/neighborhood.rb', line 7 def prdist_std @prdist_std end |
#prx_avg ⇒ Object
Returns the value of attribute prx_avg.
7 8 9 |
# File 'lib/panomosity/neighborhood.rb', line 7 def prx_avg @prx_avg end |
#prx_std ⇒ Object
Returns the value of attribute prx_std.
7 8 9 |
# File 'lib/panomosity/neighborhood.rb', line 7 def prx_std @prx_std end |
#pry_avg ⇒ Object
Returns the value of attribute pry_avg.
7 8 9 |
# File 'lib/panomosity/neighborhood.rb', line 7 def pry_avg @pry_avg end |
#pry_std ⇒ Object
Returns the value of attribute pry_std.
7 8 9 |
# File 'lib/panomosity/neighborhood.rb', line 7 def pry_std @pry_std end |
Instance Method Details
#calculate ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/panomosity/neighborhood.rb', line 16 def calculate # Do not include generated control points in neighborhood calculations pair_control_points = pair.control_points.select(&:not_generated?) # Instead of setting a static distance use a distance that is dependent on the type of connection if pair.horizontal? @pair_distance = (pair.first_image.h * 0.1).round @control_points = pair_control_points.select do |cp| cp.x1.between?(center.x1 - distance, center.x1 + distance) && cp.y1.between?(center.y1 - pair_distance, center.y1 + pair_distance) end else @pair_distance = (pair.first_image.w * 0.1).round @control_points = pair_control_points.select do |cp| cp.x1.between?(center.x1 - pair_distance, center.x1 + pair_distance) && cp.y1.between?(center.y1 - distance, center.y1 + distance) end end @prdist_avg, @prdist_std = *calculate_average_and_std(values: control_points.map(&:prdist), ignore_empty: true) @prx_avg, @prx_std = *calculate_average_and_std(values: control_points.map(&:prx), ignore_empty: true) @pry_avg, @pry_std = *calculate_average_and_std(values: control_points.map(&:pry), ignore_empty: true) if Pair.panorama.calibration? && @control_points.count == 2 # If we are viewing calibration control points we are going to have fewer of them. Increase the standard # deviation so that more control points are included std = prdist_std * 4 @control_points_within_std = pair_control_points.select { |c| c.prdist.between?(center.prdist - std, center.prdist + std) } else # add in control points that have similar distances (within std) @control_points_within_std = pair_control_points.select { |c| c.prdist.between?(center.prdist - prdist_std, center.prdist + prdist_std) } end self end |
#info ⇒ Object
51 52 53 |
# File 'lib/panomosity/neighborhood.rb', line 51 def info "neighborhood: center: (#{center.x1},#{center.y1}) | prx_avg,prx_std: #{prx_avg},#{prx_std} | pry_avg,pry_std: #{pry_avg},#{pry_std} | prdist_avg,prdist_std: #{prdist_avg},#{prdist_std}" end |