panomosity 0.1.26 → 0.1.27
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/neighborhood.rb +11 -2
- data/lib/panomosity/optimizer.rb +19 -6
- data/lib/panomosity/pair.rb +3 -3
- data/lib/panomosity/panorama.rb +48 -4
- data/lib/panomosity/runner.rb +43 -3
- data/lib/panomosity/version.rb +1 -1
- data/lib/panomosity.rb +4 -0
- 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: fb9cd44443d6029de5bf647ded91415c328b0f3b8feb4394229fbb303d95974b
|
4
|
+
data.tar.gz: 97d16176f84f7a169915582dfb28ad46afcbdef45ce832552990851255e86f93
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ed134bb47e7f1f1fb5f51c821c006cc5c7c16635d909ee13b3b0e9cbeafd97e2e1e497b3ac66ec094dd6dcd25783c622e5c74a76888619f0b31ecd371e041958
|
7
|
+
data.tar.gz: 84d9ce2ba7d27d610b6b2a62e6ac2099caecd96532dd37593a78ffe1a970214204180436c136caafd07ea0f1aa22a8578618e08b34da2e6ad4c5c1848873e142
|
data/Gemfile.lock
CHANGED
@@ -34,8 +34,17 @@ module Panomosity
|
|
34
34
|
@prx_avg, @prx_std = *calculate_average_and_std(values: control_points.map(&:prx), ignore_empty: true)
|
35
35
|
@pry_avg, @pry_std = *calculate_average_and_std(values: control_points.map(&:pry), ignore_empty: true)
|
36
36
|
|
37
|
-
|
38
|
-
|
37
|
+
|
38
|
+
if Pair.panorama.calibration? && @control_points.count == 2
|
39
|
+
# If we are viewing calibration control points we are going to have fewer of them. Increase the standard
|
40
|
+
# deviation so that more control points are included
|
41
|
+
std = prdist_std * 4
|
42
|
+
@control_points_within_std = pair_control_points.select { |c| c.prdist.between?(center.prdist - std, center.prdist + std) }
|
43
|
+
else
|
44
|
+
# add in control points that have similar distances (within std)
|
45
|
+
@control_points_within_std = pair_control_points.select { |c| c.prdist.between?(center.prdist - prdist_std, center.prdist + prdist_std) }
|
46
|
+
end
|
47
|
+
|
39
48
|
self
|
40
49
|
end
|
41
50
|
|
data/lib/panomosity/optimizer.rb
CHANGED
@@ -25,7 +25,11 @@ module Panomosity
|
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
-
def run_position_optimizer
|
28
|
+
def run_position_optimizer(xh_avg: nil, yh_avg: nil, xv_avg: nil, yv_avg: nil)
|
29
|
+
if xh_avg || yh_avg || xv_avg || yv_avg
|
30
|
+
logger.info "applying custom values of xh_avg: #{xh_avg}, yh_avg: #{yh_avg}, xv_avg: #{xv_avg}, yv_avg: #{yv_avg}"
|
31
|
+
end
|
32
|
+
|
29
33
|
Pair.calculate_neighborhoods(panorama)
|
30
34
|
Pair.calculate_neighborhood_groups
|
31
35
|
|
@@ -33,8 +37,8 @@ module Panomosity
|
|
33
37
|
es = images.map(&:e).uniq.sort
|
34
38
|
|
35
39
|
# get the average error for the best neighborhood group
|
36
|
-
x_avg = NeighborhoodGroup.horizontal.first.x_avg
|
37
|
-
y_avg = NeighborhoodGroup.vertical.first.y_avg
|
40
|
+
x_avg = xh_avg || NeighborhoodGroup.horizontal.first.x_avg
|
41
|
+
y_avg = yv_avg || NeighborhoodGroup.vertical.first.y_avg
|
38
42
|
|
39
43
|
# start horizontally
|
40
44
|
d_map = {}
|
@@ -51,8 +55,8 @@ module Panomosity
|
|
51
55
|
logger.debug "created e_map #{e_map}"
|
52
56
|
|
53
57
|
# add in the other offset
|
54
|
-
x_avg = NeighborhoodGroup.vertical.first.x_avg
|
55
|
-
y_avg = NeighborhoodGroup.horizontal.first.y_avg
|
58
|
+
x_avg = xv_avg || NeighborhoodGroup.vertical.first.x_avg
|
59
|
+
y_avg = yh_avg || NeighborhoodGroup.horizontal.first.y_avg
|
56
60
|
|
57
61
|
de_map = {}
|
58
62
|
d_map.each_with_index do |(dk,dv),di|
|
@@ -73,10 +77,19 @@ module Panomosity
|
|
73
77
|
end
|
74
78
|
end
|
75
79
|
|
76
|
-
def run_roll_optimizer
|
80
|
+
def run_roll_optimizer(apply_roll: nil)
|
77
81
|
r = images.map(&:r).first
|
78
82
|
original_roll = r
|
79
83
|
logger.debug "current roll #{r}"
|
84
|
+
|
85
|
+
if apply_roll
|
86
|
+
logger.info "apply rolling custom roll #{apply_roll}"
|
87
|
+
images.each do |image|
|
88
|
+
image.r = apply_roll
|
89
|
+
end
|
90
|
+
return
|
91
|
+
end
|
92
|
+
|
80
93
|
# we grab the top 5 neighborhood groups and get the average distance for them and average that
|
81
94
|
dist_avg = calculate_average_distance
|
82
95
|
|
data/lib/panomosity/pair.rb
CHANGED
@@ -8,7 +8,7 @@ module Panomosity
|
|
8
8
|
attr_accessor :pair, :control_points, :neighborhoods, :type
|
9
9
|
|
10
10
|
class << self
|
11
|
-
attr_accessor :logger
|
11
|
+
attr_accessor :panorama, :logger
|
12
12
|
|
13
13
|
def horizontal
|
14
14
|
@horizontal_pairs
|
@@ -22,8 +22,8 @@ module Panomosity
|
|
22
22
|
@pairs
|
23
23
|
end
|
24
24
|
|
25
|
-
def good_control_points_to_keep
|
26
|
-
@pairs.map(
|
25
|
+
def good_control_points_to_keep(count: 3)
|
26
|
+
@pairs.map { |pair| pair.good_control_points_to_keep(count: count) }.flatten.uniq(&:raw)
|
27
27
|
end
|
28
28
|
|
29
29
|
def unconnected
|
data/lib/panomosity/panorama.rb
CHANGED
@@ -19,8 +19,12 @@ module Panomosity
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def clean_control_points
|
22
|
-
|
23
|
-
|
22
|
+
if calibration?
|
23
|
+
Pair.calculate_neighborhoods(self, distance: 30)
|
24
|
+
else
|
25
|
+
Pair.calculate_neighborhoods(self, distance: 100)
|
26
|
+
end
|
27
|
+
control_points_to_keep = Pair.good_control_points_to_keep(count: 2)
|
24
28
|
bad_control_points = control_points.reject { |cp| control_points_to_keep.map(&:raw).include?(cp.raw) }
|
25
29
|
# far_control_points = control_points.select { |cp| cp.prdist > 50 }
|
26
30
|
control_points_to_clean = bad_control_points.uniq(&:raw)
|
@@ -37,7 +41,11 @@ module Panomosity
|
|
37
41
|
def fix_unconnected_image_pairs
|
38
42
|
logger.info 'finding unconnected image pairs'
|
39
43
|
|
40
|
-
|
44
|
+
if calibration?
|
45
|
+
Pair.calculate_neighborhoods(self, distance: 30)
|
46
|
+
else
|
47
|
+
Pair.calculate_neighborhoods(self, distance: 100)
|
48
|
+
end
|
41
49
|
Pair.calculate_neighborhood_groups
|
42
50
|
|
43
51
|
unconnected_image_pairs = Pair.unconnected
|
@@ -137,7 +145,7 @@ module Panomosity
|
|
137
145
|
end.join
|
138
146
|
end
|
139
147
|
|
140
|
-
def
|
148
|
+
def get_neighborhood_info
|
141
149
|
Pair.calculate_neighborhoods(self)
|
142
150
|
Pair.calculate_neighborhood_groups
|
143
151
|
Pair.info
|
@@ -282,6 +290,42 @@ module Panomosity
|
|
282
290
|
end
|
283
291
|
end
|
284
292
|
|
293
|
+
def create_calibration_report
|
294
|
+
# create a file if one doesn't exist
|
295
|
+
filename = 'calibration_report.json'
|
296
|
+
unless File.file?(filename)
|
297
|
+
logger.info 'creating calibration_report.json since one does not exist'
|
298
|
+
File.open(filename, 'w+') { |f| f.puts '{}' }
|
299
|
+
end
|
300
|
+
|
301
|
+
calibration_report = JSON.parse(File.read(filename))
|
302
|
+
|
303
|
+
if @options[:report_type] == 'position'
|
304
|
+
if calibration?
|
305
|
+
Pair.calculate_neighborhoods(self, distance: 30)
|
306
|
+
else
|
307
|
+
Pair.calculate_neighborhoods(self, distance: 100)
|
308
|
+
end
|
309
|
+
Pair.calculate_neighborhood_groups
|
310
|
+
|
311
|
+
xh_avg = NeighborhoodGroup.horizontal.first.x_avg
|
312
|
+
yh_avg = NeighborhoodGroup.horizontal.first.y_avg
|
313
|
+
xv_avg = NeighborhoodGroup.vertical.first.x_avg
|
314
|
+
yv_avg = NeighborhoodGroup.vertical.first.y_avg
|
315
|
+
calibration_report['position'] = {
|
316
|
+
xh_avg: xh_avg,
|
317
|
+
yh_avg: yh_avg,
|
318
|
+
xv_avg: xv_avg,
|
319
|
+
yv_avg: yv_avg
|
320
|
+
}
|
321
|
+
else
|
322
|
+
calibration_report['roll'] = images.first.r
|
323
|
+
end
|
324
|
+
|
325
|
+
logger.info 'writing calibration_report.json'
|
326
|
+
File.open(filename, 'w+') { |f| f.puts calibration_report.to_json }
|
327
|
+
end
|
328
|
+
|
285
329
|
def calibration?
|
286
330
|
!!@input.split(/\n/).find { |line| '#panomosity calibration true' }
|
287
331
|
end
|
data/lib/panomosity/runner.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'logger'
|
2
|
+
require 'json'
|
2
3
|
|
3
4
|
module Panomosity
|
4
5
|
class Runner
|
@@ -8,11 +9,13 @@ module Panomosity
|
|
8
9
|
|
9
10
|
AVAILABLE_COMMANDS = %w(
|
10
11
|
add_calibration_flag
|
12
|
+
apply_calibration_values
|
11
13
|
check_position_changes
|
12
14
|
clean_control_points
|
13
15
|
convert_equaled_image_parameters
|
14
16
|
convert_horizontal_lines
|
15
17
|
convert_translation_parameters
|
18
|
+
create_calibration_report
|
16
19
|
crop_centers
|
17
20
|
diagnose
|
18
21
|
fix_conversion_errors
|
@@ -20,7 +23,7 @@ module Panomosity
|
|
20
23
|
generate_border_line_control_points
|
21
24
|
get_columns_and_rows
|
22
25
|
get_control_point_info
|
23
|
-
|
26
|
+
get_neighborhood_info
|
24
27
|
merge_image_parameters
|
25
28
|
nona_grid
|
26
29
|
optimize
|
@@ -64,6 +67,37 @@ module Panomosity
|
|
64
67
|
save_file
|
65
68
|
end
|
66
69
|
|
70
|
+
def apply_calibration_values
|
71
|
+
logger.info "applying calibration values from #{@report}"
|
72
|
+
panorama = Panorama.new(@input_file, @options)
|
73
|
+
optimizer = Optimizer.new(panorama)
|
74
|
+
calibration_report = JSON.parse(@report_file)
|
75
|
+
|
76
|
+
if calibration_report.fetch('position')
|
77
|
+
logger.info 'calibration_report.json included position, applying position values'
|
78
|
+
optimizer.run_position_optimizer(xh_avg: calibration_report['position']['xh_avg'],
|
79
|
+
yh_avg: calibration_report['position']['yh_avg'],
|
80
|
+
xv_avg: calibration_report['position']['xv_avg'],
|
81
|
+
yv_avg: calibration_report['position']['yv_avg'])
|
82
|
+
end
|
83
|
+
|
84
|
+
if calibration_report.fetch('roll')
|
85
|
+
logger.info 'calibration_report.json included roll, applying roll values'
|
86
|
+
optimizer.run_roll_optimizer(apply_roll: calibration_report.fetch('roll'))
|
87
|
+
end
|
88
|
+
|
89
|
+
@lines = @input_file.each_line.map do |line|
|
90
|
+
image = optimizer.images.find { |i| i.raw == line }
|
91
|
+
if image
|
92
|
+
image.to_s
|
93
|
+
else
|
94
|
+
next line
|
95
|
+
end
|
96
|
+
end.compact
|
97
|
+
|
98
|
+
save_file
|
99
|
+
end
|
100
|
+
|
67
101
|
def check_position_changes
|
68
102
|
logger.info 'checking position changes'
|
69
103
|
original_images = Image.parse(@input_file)
|
@@ -175,6 +209,12 @@ module Panomosity
|
|
175
209
|
save_file
|
176
210
|
end
|
177
211
|
|
212
|
+
def create_calibration_report
|
213
|
+
logger.info "creating #{@options[:report_type]} calibration report"
|
214
|
+
panorama = Panorama.new(@input_file, @options)
|
215
|
+
panorama.create_calibration_report
|
216
|
+
end
|
217
|
+
|
178
218
|
# Uses image magick to crop centers
|
179
219
|
def crop_centers
|
180
220
|
logger.info 'cropping centers'
|
@@ -413,10 +453,10 @@ module Panomosity
|
|
413
453
|
end
|
414
454
|
end
|
415
455
|
|
416
|
-
def
|
456
|
+
def get_neighborhood_info
|
417
457
|
logger.info 'getting detailed neighborhood info'
|
418
458
|
panorama = Panorama.new(@input_file, @options)
|
419
|
-
panorama.
|
459
|
+
panorama.get_neighborhood_info
|
420
460
|
end
|
421
461
|
|
422
462
|
def merge_image_parameters
|
data/lib/panomosity/version.rb
CHANGED
data/lib/panomosity.rb
CHANGED
@@ -66,6 +66,10 @@ module Panomosity
|
|
66
66
|
options[:verbosity] = v
|
67
67
|
end
|
68
68
|
|
69
|
+
parser.on('--report-type TYPE', 'Type of report to create (only when running create_calibration_report)') do |type|
|
70
|
+
options[:report_type] = type
|
71
|
+
end
|
72
|
+
|
69
73
|
parser.on('-h', '--help', 'Display this screen') do
|
70
74
|
puts parser
|
71
75
|
exit
|
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.27
|
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-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|