panomosity 0.1.30 → 0.1.31
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 +4 -4
- data/Gemfile.lock +1 -1
- data/lib/panomosity/control_point.rb +14 -3
- data/lib/panomosity/neighborhood_group.rb +5 -7
- data/lib/panomosity/optimizer.rb +30 -0
- data/lib/panomosity/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ccef3c9690bcf25e476c65a9f25ef883049ccb26f98695dc58a7b0b8bdf5f868
|
|
4
|
+
data.tar.gz: e31c54fb190df4d63892dff79b6ccfae9e233cf63b6aae8ade8ad05c983299a6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4921ab8f4d713a3e92ba8bab50a8ae3412e05ac7dabe7deb1344fc46434c1064f3fae845e2219f5888deebd87be050c1a9e71566cd92998aa2bd7d704d051954
|
|
7
|
+
data.tar.gz: b48fdc2849592a0015efa842080b49ede5dadb48ef0a394c9d8a0ffe2e9f30ce6705717ed7abf2d11d3bfabdf42a4810507b0467eae81727a4bbb87ac22a2e06
|
data/Gemfile.lock
CHANGED
|
@@ -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)
|
|
7
|
+
@@calculated_attributes = %i(dist px py pdist prx pry prdist conn_type i1 i2 roll)
|
|
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|
|
|
@@ -66,12 +66,18 @@ module Panomosity
|
|
|
66
66
|
cp.pdist = Math.sqrt(cp.px ** 2 + cp.py ** 2)
|
|
67
67
|
|
|
68
68
|
# pixel distance including roll
|
|
69
|
+
cp.conn_type = image1.column == image2.column ? :vertical : :horizontal
|
|
69
70
|
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
|
|
70
77
|
cp.prx = image1.d - image2.d + Math.cos(r) * (cp.x2 - cp.x1) - Math.sin(r) * (cp.y2 - cp.y1)
|
|
71
|
-
cp.pry = image1.e - image2.e + Math.cos(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)
|
|
72
79
|
cp.prdist = Math.sqrt(cp.prx ** 2 + cp.pry ** 2)
|
|
73
80
|
|
|
74
|
-
cp.conn_type = image1.column == image2.column ? :vertical : :horizontal
|
|
75
81
|
cp.i1 = image1
|
|
76
82
|
cp.i2 = image2
|
|
77
83
|
end
|
|
@@ -189,6 +195,11 @@ module Panomosity
|
|
|
189
195
|
self.prx = i1.d - i2.d + Math.cos(r) * (x2 - x1) - Math.sin(r) * (y2 - y1)
|
|
190
196
|
self.pry = i1.e - i2.e + Math.cos(r) * (y2 - y1) - Math.sin(r) * (x2 - x1)
|
|
191
197
|
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
|
|
192
203
|
end
|
|
193
204
|
|
|
194
205
|
def detailed_info
|
|
@@ -6,7 +6,7 @@ module Panomosity
|
|
|
6
6
|
extend Panomosity::Utils
|
|
7
7
|
|
|
8
8
|
attr_accessor :center, :total_neighborhoods, :neighborhoods, :control_points, :prdist_avg, :prdist_std, :x_avg,
|
|
9
|
-
:y_avg
|
|
9
|
+
:rx_avg, :y_avg, :ry_avg
|
|
10
10
|
|
|
11
11
|
class << self
|
|
12
12
|
attr_accessor :logger
|
|
@@ -81,10 +81,7 @@ module Panomosity
|
|
|
81
81
|
end
|
|
82
82
|
|
|
83
83
|
neighborhood_groups.max_by(5) { |ng| ng.control_points.count }.each do |ng|
|
|
84
|
-
logger.debug "#{ng.prdist_avg} #{ng.prdist_std} #{ng.control_points.count} x#{ng.x_avg} y#{ng.y_avg}"
|
|
85
|
-
logger.debug "#{calculate_average(values: ng.control_points.map(&:pdist))} x#{calculate_average(values: ng.control_points.map(&:px))} y#{calculate_average(values: ng.control_points.map(&:py))}"
|
|
86
|
-
|
|
87
|
-
ng.control_points.each { |point| logger.debug point.detailed_info }
|
|
84
|
+
logger.debug "#{ng.prdist_avg} #{ng.prdist_std} #{ng.control_points.count} x#{ng.x_avg} y#{ng.y_avg} rx#{ng.rx_avg} ry#{ng.ry_avg}"
|
|
88
85
|
end
|
|
89
86
|
|
|
90
87
|
self.neighborhood_groups = neighborhood_groups.sort_by { |ng| -ng.control_points.count }
|
|
@@ -103,9 +100,10 @@ module Panomosity
|
|
|
103
100
|
@neighborhoods = total_neighborhoods.select { |n| (n.prdist_avg - center.prdist_avg).abs <= center.prdist_std }
|
|
104
101
|
@control_points = neighborhoods.map(&:control_points_within_std).flatten.uniq(&:raw)
|
|
105
102
|
@x_avg = calculate_average(values: control_points.map(&:px))
|
|
103
|
+
@rx_avg = calculate_average(values: control_points.map(&:prx))
|
|
106
104
|
@y_avg = calculate_average(values: control_points.map(&:py))
|
|
107
|
-
@
|
|
108
|
-
@prdist_std =
|
|
105
|
+
@ry_avg = calculate_average(values: control_points.map(&:pry))
|
|
106
|
+
@prdist_avg, @prdist_std = *calculate_average_and_std(values: control_points.map(&:prdist))
|
|
109
107
|
self
|
|
110
108
|
end
|
|
111
109
|
|
data/lib/panomosity/optimizer.rb
CHANGED
|
@@ -90,6 +90,15 @@ module Panomosity
|
|
|
90
90
|
return
|
|
91
91
|
end
|
|
92
92
|
|
|
93
|
+
roll = calculate_estimated_roll
|
|
94
|
+
if roll
|
|
95
|
+
logger.debug "using calculated horizontal roll #{roll}"
|
|
96
|
+
images.each do |image|
|
|
97
|
+
image.r = roll
|
|
98
|
+
end
|
|
99
|
+
return
|
|
100
|
+
end
|
|
101
|
+
|
|
93
102
|
# we grab the top 5 neighborhood groups and get the average distance for them and average that
|
|
94
103
|
dist_avg = calculate_average_distance
|
|
95
104
|
|
|
@@ -143,5 +152,26 @@ module Panomosity
|
|
|
143
152
|
panorama.control_points = ControlPoint.calculate_distances(panorama.images, panorama.variable)
|
|
144
153
|
calculate_average_distance
|
|
145
154
|
end
|
|
155
|
+
|
|
156
|
+
def calculate_estimated_roll
|
|
157
|
+
return
|
|
158
|
+
# setting to 0
|
|
159
|
+
images.each do |image|
|
|
160
|
+
image.r = 0.0
|
|
161
|
+
end
|
|
162
|
+
Pair.calculate_neighborhoods(panorama)
|
|
163
|
+
Pair.calculate_neighborhood_groups
|
|
164
|
+
cps = NeighborhoodGroup.horizontal.first.control_points
|
|
165
|
+
avg, std = *calculate_average_and_std(values: cps.map(&:roll))
|
|
166
|
+
# 0.1 degrees of std
|
|
167
|
+
while std > 0.1
|
|
168
|
+
cps.select!{|c| (avg - c.roll).abs <= std}
|
|
169
|
+
avg, std = *calculate_average_and_std(values: cps.map(&:roll))
|
|
170
|
+
end
|
|
171
|
+
avg
|
|
172
|
+
rescue
|
|
173
|
+
logger.debug 'estimating roll failed'
|
|
174
|
+
nil
|
|
175
|
+
end
|
|
146
176
|
end
|
|
147
177
|
end
|
data/lib/panomosity/version.rb
CHANGED
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.
|
|
4
|
+
version: 0.1.31
|
|
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-
|
|
11
|
+
date: 2018-12-12 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|