panomosity 0.1.31 → 0.1.32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/panomosity/control_point.rb +14 -24
- data/lib/panomosity/optimizer.rb +8 -6
- data/lib/panomosity/utils.rb +10 -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: 50e125a826a4accf978aa182be59f36de59c7697254b3eabd27b6fb831fb319d
|
4
|
+
data.tar.gz: 4b53136c72ddba3fd1515cd5b9aea76fa747abfff344ad9e485ad2026e407209
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 21a995367c4d62e67ccbdda9a18587cd7ddefc3399e585307bb8b47c7390276074889f8cccbc267c062eed3a46052dc55796fe0280ad9e27635642a758f0de73
|
7
|
+
data.tar.gz: da2f34870a506e6b32d4a2be111b614fe2056b049df905d9c5738efa13ffb64c0f45fe02ac4b86f042ee8c692b7610e032ef8f0e0e94ddc835bc925226e79728
|
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)
|
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
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
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
|
-
|
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 =
|
196
|
-
self.pry =
|
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
|
data/lib/panomosity/optimizer.rb
CHANGED
@@ -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
|
-
|
34
|
-
|
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.
|
41
|
-
y_avg = yv_avg || NeighborhoodGroup.vertical.first.
|
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.
|
59
|
-
y_avg = yh_avg || NeighborhoodGroup.horizontal.first.
|
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|
|
data/lib/panomosity/utils.rb
CHANGED
@@ -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
|
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.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-
|
11
|
+
date: 2018-12-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|