panomosity 0.1.19 → 0.1.20
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 +16 -7
- data/lib/panomosity/neighborhood.rb +9 -6
- data/lib/panomosity/neighborhood_group.rb +1 -1
- data/lib/panomosity/pair.rb +28 -9
- data/lib/panomosity/panorama.rb +10 -2
- data/lib/panomosity/version.rb +1 -1
- data/lib/panomosity.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: 29ffa367e9aa586c70f99b092cc16361d782228b43d7403f526480736f077786
|
4
|
+
data.tar.gz: 6d0d06a32d28236b703ed604189c3a9548badf9ddf8c883aacbf846bee165296
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 285fa9879122939d631ed74395948b702c626e2e0104d1cd9d1a346c58bbbcb90c8d134826d97c9c70e94256e582b4afdbff95cdc6b988c04e12ca10bce0beb0
|
7
|
+
data.tar.gz: 98c7bcabe7f5a3e2d4435c8d44fbe5496a7ec3bdbe5b5dff498d7d6022f346e65bc76bae1f7cfe4c1dfaeb68bd57acd65bc2980a1daf60293c657e7541bd8e5d
|
data/Gemfile.lock
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
|
4
4
|
module Panomosity
|
5
5
|
class ControlPoint
|
6
|
-
@@attributes = %i(n N x y X Y t)
|
6
|
+
@@attributes = %i(n N x y X Y t g)
|
7
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)
|
@@ -161,18 +161,27 @@ module Panomosity
|
|
161
161
|
vertical? || horizontal?
|
162
162
|
end
|
163
163
|
|
164
|
+
def generated?
|
165
|
+
!g.nil?
|
166
|
+
end
|
167
|
+
|
168
|
+
def not_generated?
|
169
|
+
!generated?
|
170
|
+
end
|
171
|
+
|
164
172
|
def to_s
|
165
|
-
|
173
|
+
attrs = generated? ? @@attributes : (@@attributes - %i(g))
|
174
|
+
line_values = attrs.map { |attribute| "#{attribute}#{self.send(attribute)}" }
|
166
175
|
"c #{line_values.join(' ')}\n"
|
167
176
|
end
|
168
177
|
|
169
178
|
def ==(o)
|
170
179
|
n1 == o.n1 &&
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
180
|
+
n2 == o.n2 &&
|
181
|
+
x1.floor == o.x1.floor &&
|
182
|
+
x2.floor == o.x2.floor &&
|
183
|
+
y1.floor == o.y1.floor &&
|
184
|
+
y2.floor == o.y2.floor
|
176
185
|
end
|
177
186
|
|
178
187
|
def recalculate_pixel_distance
|
@@ -14,25 +14,28 @@ module Panomosity
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def calculate
|
17
|
+
# Do not include generated control points in neighborhood calculations
|
18
|
+
pair_control_points = pair.control_points.select(&:not_generated?)
|
19
|
+
|
17
20
|
# Instead of setting a static distance use a distance that is dependent on the type of connection
|
18
21
|
if pair.horizontal?
|
19
22
|
@pair_distance = (pair.first_image.h * 0.1).round
|
20
|
-
@control_points =
|
23
|
+
@control_points = pair_control_points.select do |cp|
|
21
24
|
cp.x1.between?(center.x1 - distance, center.x1 + distance) && cp.y1.between?(center.y1 - pair_distance, center.y1 + pair_distance)
|
22
25
|
end
|
23
26
|
else
|
24
27
|
@pair_distance = (pair.first_image.w * 0.1).round
|
25
|
-
@control_points =
|
28
|
+
@control_points = pair_control_points.select do |cp|
|
26
29
|
cp.x1.between?(center.x1 - pair_distance, center.x1 + pair_distance) && cp.y1.between?(center.y1 - distance, center.y1 + distance)
|
27
30
|
end
|
28
31
|
end
|
29
32
|
|
30
|
-
@prdist_avg, @prdist_std = *calculate_average_and_std(values: control_points.map(&:prdist))
|
31
|
-
@prx_avg, @prx_std = *calculate_average_and_std(values: control_points.map(&:prx))
|
32
|
-
@pry_avg, @pry_std = *calculate_average_and_std(values: control_points.map(&:pry))
|
33
|
+
@prdist_avg, @prdist_std = *calculate_average_and_std(values: control_points.map(&:prdist), ignore_empty: true)
|
34
|
+
@prx_avg, @prx_std = *calculate_average_and_std(values: control_points.map(&:prx), ignore_empty: true)
|
35
|
+
@pry_avg, @pry_std = *calculate_average_and_std(values: control_points.map(&:pry), ignore_empty: true)
|
33
36
|
|
34
37
|
# add in control points that have similar distances (within std)
|
35
|
-
@control_points_within_std =
|
38
|
+
@control_points_within_std = pair_control_points.select { |c| c.prdist.between?(center.prdist - prdist_std, center.prdist + prdist_std) }
|
36
39
|
self
|
37
40
|
end
|
38
41
|
|
@@ -98,7 +98,7 @@ module Panomosity
|
|
98
98
|
|
99
99
|
def calculate
|
100
100
|
@neighborhoods = total_neighborhoods.select { |n| (n.prdist_avg - center.prdist_avg).abs <= center.prdist_std }
|
101
|
-
@control_points = neighborhoods.map(&:control_points_within_std).flatten.uniq
|
101
|
+
@control_points = neighborhoods.map(&:control_points_within_std).flatten.uniq(&:raw)
|
102
102
|
@x_avg = calculate_average(values: control_points.map(&:px))
|
103
103
|
@y_avg = calculate_average(values: control_points.map(&:py))
|
104
104
|
@prdist_avg = center.prdist_avg
|
data/lib/panomosity/pair.rb
CHANGED
@@ -23,7 +23,7 @@ module Panomosity
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def good_control_points_to_keep
|
26
|
-
@pairs.map(&:good_control_points_to_keep).flatten.uniq
|
26
|
+
@pairs.map(&:good_control_points_to_keep).flatten.uniq(&:raw)
|
27
27
|
end
|
28
28
|
|
29
29
|
def unconnected
|
@@ -83,6 +83,12 @@ module Panomosity
|
|
83
83
|
log_detailed_neighborhood_info(name: :vertical, pairs: @vertical_pairs)
|
84
84
|
end
|
85
85
|
|
86
|
+
def self.calculate_neighborhood_groups
|
87
|
+
NeighborhoodGroup.parse_info(@panorama)
|
88
|
+
NeighborhoodGroup.calculate(name: :horizontal, pairs: @horizontal_pairs)
|
89
|
+
NeighborhoodGroup.calculate(name: :vertical, pairs: @vertical_pairs)
|
90
|
+
end
|
91
|
+
|
86
92
|
def self.log_detailed_neighborhood_info(name: :horizontal, pairs: [])
|
87
93
|
return unless @panorama.options[:very_verbose]
|
88
94
|
logger.debug "showing #{name} pair information"
|
@@ -98,12 +104,6 @@ module Panomosity
|
|
98
104
|
end
|
99
105
|
end
|
100
106
|
|
101
|
-
def self.calculate_neighborhood_groups
|
102
|
-
NeighborhoodGroup.parse_info(@panorama)
|
103
|
-
NeighborhoodGroup.calculate(name: :horizontal, pairs: @horizontal_pairs)
|
104
|
-
NeighborhoodGroup.calculate(name: :vertical, pairs: @vertical_pairs)
|
105
|
-
end
|
106
|
-
|
107
107
|
def self.info
|
108
108
|
logger.debug "total number of control points: #{@pairs.map(&:control_points).flatten.count}"
|
109
109
|
logger.debug 'displaying horizontal pair info'
|
@@ -117,6 +117,25 @@ module Panomosity
|
|
117
117
|
logger.debug "control points: x_dist,x_std: #{x_dist},#{x_std} | y_dist,y_std: #{y_dist},#{y_std} | dist,std: #{dist},#{std}"
|
118
118
|
logger.debug "total number of neighborhoods: #{pair.neighborhoods.count}"
|
119
119
|
logger.debug "total number single cp neighborhoods: #{pair.neighborhoods.select{|n| n.control_points.count == 1}.count}"
|
120
|
+
logger.debug "total number generated control points: #{pair.control_points.select(&:generated?).count}"
|
121
|
+
pair.neighborhoods.each do |neighborhood|
|
122
|
+
logger.debug neighborhood.info
|
123
|
+
logger.debug "neighborhood: distance,pair_distance: #{neighborhood.distance},#{neighborhood.pair_distance} | total number of control points: #{neighborhood.control_points.count}"
|
124
|
+
logger.debug "neighborhood: center prdist: #{neighborhood.center.prdist} | total number of control points within std: #{neighborhood.control_points_within_std.count}"
|
125
|
+
end
|
126
|
+
end
|
127
|
+
logger.debug 'displaying vertical pair info'
|
128
|
+
logger.debug "total number of vertical control points: #{@vertical_pairs.map(&:control_points).flatten.count}"
|
129
|
+
@vertical_pairs.each do |pair|
|
130
|
+
logger.debug pair.info
|
131
|
+
logger.debug "total number of control points: #{pair.control_points.count}"
|
132
|
+
x_dist, x_std = *calculate_average_and_std(values: pair.control_points.map(&:prx))
|
133
|
+
y_dist, y_std = *calculate_average_and_std(values: pair.control_points.map(&:pry))
|
134
|
+
dist, std = *calculate_average_and_std(values: pair.control_points.map(&:prdist))
|
135
|
+
logger.debug "control points: x_dist,x_std: #{x_dist},#{x_std} | y_dist,y_std: #{y_dist},#{y_std} | dist,std: #{dist},#{std}"
|
136
|
+
logger.debug "total number of neighborhoods: #{pair.neighborhoods.count}"
|
137
|
+
logger.debug "total number single cp neighborhoods: #{pair.neighborhoods.select{|n| n.control_points.count == 1}.count}"
|
138
|
+
logger.debug "total number generated control points: #{pair.control_points.select(&:generated?).count}"
|
120
139
|
pair.neighborhoods.each do |neighborhood|
|
121
140
|
logger.debug neighborhood.info
|
122
141
|
logger.debug "neighborhood: distance,pair_distance: #{neighborhood.distance},#{neighborhood.pair_distance} | total number of control points: #{neighborhood.control_points.count}"
|
@@ -133,7 +152,7 @@ module Panomosity
|
|
133
152
|
end
|
134
153
|
|
135
154
|
def to_s
|
136
|
-
pair.map(&:id)
|
155
|
+
pair.map(&:id).to_s.gsub(' ', '')
|
137
156
|
end
|
138
157
|
|
139
158
|
def info
|
@@ -181,7 +200,7 @@ module Panomosity
|
|
181
200
|
end
|
182
201
|
|
183
202
|
def good_control_points_to_keep(count: 3)
|
184
|
-
control_points_to_keep = good_neighborhoods_within_std(count: count).map(&:control_points_within_std).flatten.uniq
|
203
|
+
control_points_to_keep = good_neighborhoods_within_std(count: count).map(&:control_points_within_std).flatten.uniq(&:raw)
|
185
204
|
|
186
205
|
# Keep all our control points if we have less than 10
|
187
206
|
if control_points.count >= 10
|
data/lib/panomosity/panorama.rb
CHANGED
@@ -19,11 +19,16 @@ module Panomosity
|
|
19
19
|
Pair.calculate_neighborhoods(self)
|
20
20
|
control_points_to_keep = Pair.good_control_points_to_keep
|
21
21
|
bad_control_points = control_points.reject { |cp| control_points_to_keep.map(&:raw).include?(cp.raw) }
|
22
|
-
|
22
|
+
far_control_points = control_points.select { |cp| cp.prdist > 50 }
|
23
|
+
control_points_to_clean = (bad_control_points + far_control_points).uniq(&:raw)
|
24
|
+
|
25
|
+
# log warnings
|
26
|
+
control_point_ratio = control_points_to_clean.count.to_f / control_points.count
|
23
27
|
logger.warn "Removing more than 30% (#{(control_point_ratio*100).round(4)}%) of control points. May potentially cause issues." if control_point_ratio >= 0.3
|
24
28
|
control_point_pair_ratio = Pair.without_enough_control_points(ignore_connected: true).count.to_f / Pair.all.count
|
25
29
|
logger.warn "More than 50% (#{(control_point_pair_ratio*100).round(4)}%) of pairs have fewer than 3 control points. May potentially cause issues." if control_point_pair_ratio >= 0.5
|
26
|
-
|
30
|
+
|
31
|
+
control_points_to_clean
|
27
32
|
end
|
28
33
|
|
29
34
|
def fix_unconnected_image_pairs
|
@@ -122,6 +127,9 @@ module Panomosity
|
|
122
127
|
control_point[:x] += i.w * 0.25
|
123
128
|
control_point[:X] += i.w * 0.25
|
124
129
|
end
|
130
|
+
# marks the control point as generated
|
131
|
+
|
132
|
+
control_point[:g] = 0
|
125
133
|
control_point.to_s
|
126
134
|
end.join
|
127
135
|
end
|
data/lib/panomosity/version.rb
CHANGED
data/lib/panomosity.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.20
|
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-11-
|
11
|
+
date: 2018-11-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|