panomosity 0.1.31 → 0.1.32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ccef3c9690bcf25e476c65a9f25ef883049ccb26f98695dc58a7b0b8bdf5f868
4
- data.tar.gz: e31c54fb190df4d63892dff79b6ccfae9e233cf63b6aae8ade8ad05c983299a6
3
+ metadata.gz: 50e125a826a4accf978aa182be59f36de59c7697254b3eabd27b6fb831fb319d
4
+ data.tar.gz: 4b53136c72ddba3fd1515cd5b9aea76fa747abfff344ad9e485ad2026e407209
5
5
  SHA512:
6
- metadata.gz: 4921ab8f4d713a3e92ba8bab50a8ae3412e05ac7dabe7deb1344fc46434c1064f3fae845e2219f5888deebd87be050c1a9e71566cd92998aa2bd7d704d051954
7
- data.tar.gz: b48fdc2849592a0015efa842080b49ede5dadb48ef0a394c9d8a0ffe2e9f30ce6705717ed7abf2d11d3bfabdf42a4810507b0467eae81727a4bbb87ac22a2e06
6
+ metadata.gz: 21a995367c4d62e67ccbdda9a18587cd7ddefc3399e585307bb8b47c7390276074889f8cccbc267c062eed3a46052dc55796fe0280ad9e27635642a758f0de73
7
+ data.tar.gz: da2f34870a506e6b32d4a2be111b614fe2056b049df905d9c5738efa13ffb64c0f45fe02ac4b86f042ee8c692b7610e032ef8f0e0e94ddc835bc925226e79728
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- panomosity (0.1.30)
4
+ panomosity (0.1.32)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -4,7 +4,7 @@
4
4
  module Panomosity
5
5
  class ControlPoint
6
6
  @@attributes = %i(n N x y X Y t g)
7
- @@calculated_attributes = %i(dist px py pdist prx pry prdist conn_type i1 i2 roll)
7
+ @@calculated_attributes = %i(dist px py pdist prx pry prdist conn_type i1 i2)
8
8
 
9
9
  def self.parse(pto_file, cp_type: nil, compact: false)
10
10
  @control_points = pto_file.each_line.map do |line|
@@ -55,31 +55,26 @@ module Panomosity
55
55
  distance = angle * radius
56
56
  cp.dist = distance
57
57
 
58
+ cp.i1 = image1
59
+ cp.i2 = image2
60
+
58
61
  # pixel distance
59
- x1 = (image1.w / 2.0) - cp.x1 + image1.d
60
- y1 = (image1.h / 2.0) - cp.y1 + image1.e
61
- x2 = (image2.w / 2.0) - cp.x2 + image2.d
62
- y2 = (image2.h / 2.0) - cp.y2 + image2.e
62
+ # NOTE d,e distances are highest on the top-left and lowest at the bottom-right
63
+ # control point coordinates are highest on bottom-right and lowest on the top-left
64
+ x1 = (cp.i1.w / 2.0) - cp.x1 + cp.i1.d
65
+ y1 = (cp.i1.h / 2.0) - cp.y1 + cp.i1.e
66
+ x2 = (cp.i2.w / 2.0) - cp.x2 + cp.i2.d
67
+ y2 = (cp.i2.h / 2.0) - cp.y2 + cp.i2.e
63
68
 
64
69
  cp.px = x1 - x2
65
70
  cp.py = y1 - y2
66
71
  cp.pdist = Math.sqrt(cp.px ** 2 + cp.py ** 2)
67
72
 
68
73
  # pixel distance including roll
69
- cp.conn_type = image1.column == image2.column ? :vertical : :horizontal
70
74
  r = image1.r * Math::PI / 180
71
-
72
- if cp.conn_type == :horizontal
73
- cp.roll = Math.atan(-(cp.y2 - cp.y1) / (cp.x2 - cp.x1)) * 180.0 / Math::PI
74
- else
75
- cp.roll = Math.atan((cp.x2 - cp.x1) / (cp.y2 - cp.y1)) * 180.0 / Math::PI
76
- end
77
- cp.prx = image1.d - image2.d + Math.cos(r) * (cp.x2 - cp.x1) - Math.sin(r) * (cp.y2 - cp.y1)
78
- cp.pry = image1.e - image2.e + Math.cos(r) * (cp.y2 - cp.y1) + Math.sin(r) * (cp.x2 - cp.x1)
75
+ cp.prx = Math.cos(r) * cp.px - Math.sin(r) * cp.py
76
+ cp.pry = Math.cos(r) * cp.py + Math.sin(r) * cp.px
79
77
  cp.prdist = Math.sqrt(cp.prx ** 2 + cp.pry ** 2)
80
-
81
- cp.i1 = image1
82
- cp.i2 = image2
83
78
  end
84
79
  end
85
80
 
@@ -192,14 +187,9 @@ module Panomosity
192
187
 
193
188
  def recalculate_pixel_distance
194
189
  r = i1.r * Math::PI / 180
195
- self.prx = i1.d - i2.d + Math.cos(r) * (x2 - x1) - Math.sin(r) * (y2 - y1)
196
- self.pry = i1.e - i2.e + Math.cos(r) * (y2 - y1) - Math.sin(r) * (x2 - x1)
190
+ self.prx = Math.cos(r) * px - Math.sin(r) * py
191
+ self.pry = Math.cos(r) * py + Math.sin(r) * px
197
192
  self.prdist = Math.sqrt(prx ** 2 + pry ** 2)
198
- if conn_type == :horizontal
199
- self.roll = Math.atan(-(y2 - y1) / (x2 - x1)) * 180.0 / Math::PI
200
- else
201
- self.roll = Math.atan((x2 - x1) / (y2 - y1)) * 180.0 / Math::PI
202
- end
203
193
  end
204
194
 
205
195
  def detailed_info
@@ -30,15 +30,17 @@ module Panomosity
30
30
  logger.info "applying custom values of xh_avg: #{xh_avg}, yh_avg: #{yh_avg}, xv_avg: #{xv_avg}, yv_avg: #{yv_avg}"
31
31
  end
32
32
 
33
- Pair.calculate_neighborhoods(panorama)
34
- Pair.calculate_neighborhood_groups
33
+ unless xh_avg && yh_avg && xv_avg && yv_avg
34
+ Pair.calculate_neighborhoods(panorama)
35
+ Pair.calculate_neighborhood_groups
36
+ end
35
37
 
36
38
  ds = images.map(&:d).uniq.sort
37
39
  es = images.map(&:e).uniq.sort
38
40
 
39
41
  # get the average error for the best neighborhood group
40
- x_avg = xh_avg || NeighborhoodGroup.horizontal.first.x_avg
41
- y_avg = yv_avg || NeighborhoodGroup.vertical.first.y_avg
42
+ x_avg = xh_avg || NeighborhoodGroup.horizontal.first.rx_avg
43
+ y_avg = yv_avg || NeighborhoodGroup.vertical.first.ry_avg
42
44
 
43
45
  # start horizontally
44
46
  d_map = {}
@@ -55,8 +57,8 @@ module Panomosity
55
57
  logger.debug "created e_map #{e_map}"
56
58
 
57
59
  # add in the other offset
58
- x_avg = xv_avg || NeighborhoodGroup.vertical.first.x_avg
59
- y_avg = yh_avg || NeighborhoodGroup.horizontal.first.y_avg
60
+ x_avg = xv_avg || NeighborhoodGroup.vertical.first.rx_avg
61
+ y_avg = yh_avg || NeighborhoodGroup.horizontal.first.ry_avg
60
62
 
61
63
  de_map = {}
62
64
  d_map.each_with_index do |(dk,dv),di|
@@ -20,5 +20,15 @@ module Panomosity
20
20
  logger.debug "average #{name}: #{average_value}" if logger
21
21
  average_value
22
22
  end
23
+
24
+ def remove_outliers(method: :value, values: [], logger: nil)
25
+ avg, std = *calculate_average_and_std(values: values.map(&method))
26
+ while std >= 0.1
27
+ values.select! { |c| (avg - c.send(method)).abs <= std }
28
+ avg, std = *calculate_average_and_std(values: values.map(&method))
29
+ logger.debug [avg , std, values.count].to_s if logger
30
+ end
31
+ values
32
+ end
23
33
  end
24
34
  end
@@ -1,3 +1,3 @@
1
1
  module Panomosity
2
- VERSION = '0.1.31'
2
+ VERSION = '0.1.32'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: panomosity
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.31
4
+ version: 0.1.32
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oliver Garcia
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-12-12 00:00:00.000000000 Z
11
+ date: 2018-12-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler