panomosity 0.1.39 → 0.1.40

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d0babb2f2886451531b10cafb8fb2b8ccce33edd260247d1a100001120c3af57
4
- data.tar.gz: 93c56a79260969f6a77c87d019bbd5efb11c6bcd908fd6ea05f5ad13334c2b3a
3
+ metadata.gz: 508c47f3caa59487c8e85f4787044dd174b9e43a63fce0ee0ecfc210c88ecef7
4
+ data.tar.gz: d7e9a8a263379d90f984746e0b3f2215943322418c59ce4f9f25012563fbce82
5
5
  SHA512:
6
- metadata.gz: 2f373113dd8fbb7e70045e94cd20d97342f1d955f64b221208288246f8fbcc486e05785e518769d51b73096029b8570861929a9eb10fd1ed0081c448d9111895
7
- data.tar.gz: e82ff01175bbf2010e102fceae0acc512517ac51037b2e70a1b893ecd6325c0afc251e4a3525fe003528a557b5849590c56229b3c51edab896eb4a79b71bc4d0
6
+ metadata.gz: 73a953315be6abba6b26a8371dbf5f0ad131fbae1733b59c12e243d6e31e531a2b9bf3e908b2d5b5d03423ef3006347dd15be55dafcd38c019735e57ea998ad4
7
+ data.tar.gz: 380b7ac01f1306116cbdc2c5982760f2495ca107321a6564bfca266b449e6c631ec8752b40228e12b8ffb8127f8f3305c3451a93a5ba2a084a91f3bd838ad30d
@@ -1,31 +1,38 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- panomosity (0.1.38)
4
+ panomosity (0.1.39)
5
+ write_xlsx
5
6
 
6
7
  GEM
7
8
  remote: https://rubygems.org/
8
9
  specs:
9
10
  coderay (1.1.2)
10
- diff-lcs (1.3)
11
+ diff-lcs (1.4.4)
11
12
  method_source (0.9.0)
12
13
  pry (0.11.3)
13
14
  coderay (~> 1.1.0)
14
15
  method_source (~> 0.9.0)
15
16
  rake (10.5.0)
16
- rspec (3.8.0)
17
- rspec-core (~> 3.8.0)
18
- rspec-expectations (~> 3.8.0)
19
- rspec-mocks (~> 3.8.0)
20
- rspec-core (3.8.0)
21
- rspec-support (~> 3.8.0)
22
- rspec-expectations (3.8.1)
17
+ rspec (3.9.0)
18
+ rspec-core (~> 3.9.0)
19
+ rspec-expectations (~> 3.9.0)
20
+ rspec-mocks (~> 3.9.0)
21
+ rspec-core (3.9.2)
22
+ rspec-support (~> 3.9.3)
23
+ rspec-expectations (3.9.2)
23
24
  diff-lcs (>= 1.2.0, < 2.0)
24
- rspec-support (~> 3.8.0)
25
- rspec-mocks (3.8.0)
25
+ rspec-support (~> 3.9.0)
26
+ rspec-mocks (3.9.1)
26
27
  diff-lcs (>= 1.2.0, < 2.0)
27
- rspec-support (~> 3.8.0)
28
- rspec-support (3.8.0)
28
+ rspec-support (~> 3.9.0)
29
+ rspec-support (3.9.3)
30
+ rubyzip (2.3.0)
31
+ write_xlsx (0.85.9)
32
+ rubyzip (>= 1.0.0)
33
+ zip-zip
34
+ zip-zip (0.3)
35
+ rubyzip (>= 1.0.0)
29
36
 
30
37
  PLATFORMS
31
38
  ruby
@@ -1,14 +1,16 @@
1
1
  require 'logger'
2
2
  require 'json'
3
3
  require 'csv'
4
+ require 'panomosity/xlsx_writer'
4
5
 
5
6
  module Panomosity
6
7
  class Runner
7
8
  include Panomosity::Utils
9
+ include Panomosity::XLSXWriter
8
10
 
9
11
  attr_reader :logger
10
12
 
11
- AVAILABLE_COMMANDS = %w(
13
+ AVAILABLE_COMMANDS = %w[
12
14
  add_calibration_flag
13
15
  apply_calibration_values
14
16
  check_position_changes
@@ -20,6 +22,7 @@ module Panomosity
20
22
  crop_centers
21
23
  diagnose
22
24
  export_control_point_csv
25
+ export_panorama_attributes_to_csv
23
26
  fix_conversion_errors
24
27
  fix_unconnected_image_pairs
25
28
  generate_border_line_control_points
@@ -34,7 +37,7 @@ module Panomosity
34
37
  prepare_for_pr0ntools
35
38
  remove_anchor_variables
36
39
  standardize_roll
37
- )
40
+ ]
38
41
 
39
42
  def initialize(options)
40
43
  @options = options
@@ -299,7 +302,7 @@ module Panomosity
299
302
  panorama.calculate_neighborhoods
300
303
 
301
304
  filename = 'control_points.csv'
302
- headers = %w(image_1_name image_2_name image_1_id image_2_id type width height d1 e1 d2 e2 x1 y1 x2 y2 rx ry r)
305
+ headers = %w[image_1_name image_2_name image_1_id image_2_id type width height d1 e1 d2 e2 x1 y1 x2 y2 rx ry r]
303
306
  CSV.open(filename, 'w+') do |csv|
304
307
  csv << headers
305
308
  panorama.control_points.each do |cp|
@@ -490,6 +493,70 @@ module Panomosity
490
493
  puts panorama.attributes.to_json
491
494
  end
492
495
 
496
+ def export_panorama_attributes_to_csv
497
+ panorama = Panorama.new(@input_file, @options)
498
+ panorama.calculate_neighborhoods
499
+
500
+ logger.info "Making #{Dir.pwd}/#{@input}_attributes Directory"
501
+
502
+ dir = "#{Dir.pwd}/#{@input}_attributes"
503
+ Dir.mkdir(dir) unless File.exists?(dir)
504
+
505
+ logger.info "Done. Moving into #{dir} Directory"
506
+
507
+ Dir.chdir "#{@input}_attributes"
508
+
509
+ logger.info "Making control_points.csv"
510
+
511
+ filename = 'control_points.csv'
512
+ headers = %w[image_1_name image_2_name image_1_id image_2_id type width height d1 e1 d2 e2 x1 y1 x2 y2 rx ry r]
513
+ CSV.open(filename, 'w+') do |csv|
514
+ csv << headers
515
+ panorama.control_points.each do |cp|
516
+ pair = Pair.all.find { |p| p.control_points.include?(cp) }
517
+ csv << [cp.i1.name, cp.i2.name, cp.i1.id, cp.i2.id, pair.type, cp.i1.w, cp.i1.h, cp.i1.d, cp.i1.e,
518
+ cp.i2.d, cp.i2.e, cp.x1, cp.y1, cp.x2, cp.y2, cp.px, cp.py, cp.pdist]
519
+ end
520
+ end
521
+
522
+ logger.info "Done. Check for #{filename}"
523
+
524
+ attributes = panorama.attributes
525
+
526
+ logger.info "Making cp_pairs.csv"
527
+
528
+ filename = 'cp_pairs.csv'
529
+ headers = attributes[:pairs].first.keys
530
+ CSV.open(filename,"w") do |csv|
531
+ csv << headers
532
+ attributes[:pairs].each do |pair|
533
+ csv << pair.values
534
+ end
535
+ end
536
+
537
+ logger.info "Done. Check for #{filename}"
538
+
539
+ logger.info "Making neighborhood_pairs.csv"
540
+
541
+ filename = 'neighborhood_pairs.csv'
542
+ headers = ['data_type', attributes[:similar_neighborhoods].first.keys].flatten
543
+ CSV.open(filename,'w') do |csv|
544
+ csv << headers
545
+ attributes[:similar_neighborhoods].each do |neighborhood|
546
+ csv << ['similar_neighborhoods', neighborhood.values].flatten(1)
547
+ end
548
+ attributes[:neighborhoods_by_similar_neighborhood].each do |neighborhood|
549
+ csv << ['neighborhoods_by_similar_neighborhood', neighborhood.values].flatten(1)
550
+ end
551
+ end
552
+
553
+ logger.info "Done. Check for #{filename}"
554
+
555
+ csv_to_xlsx(['control_points.csv', 'cp_pairs.csv', 'neighborhood_pairs.csv'], 'attributes')
556
+
557
+ Dir.chdir '..'
558
+ end
559
+
493
560
  def import_control_point_csv
494
561
  logger.info 'importing control point csv'
495
562
  panorama = Panorama.new(@input_file, @options)
@@ -1,3 +1,3 @@
1
1
  module Panomosity
2
- VERSION = '0.1.39'
2
+ VERSION = '0.1.40'
3
3
  end
@@ -0,0 +1,40 @@
1
+ require 'write_xlsx'
2
+
3
+ module Panomosity
4
+ module XLSXWriter
5
+ SEPERATE_CSV_COLUMNS = /,(?![^\[]*\])/.freeze
6
+
7
+
8
+ def csv_to_xlsx(input_files, output_file)
9
+ input_files = Array(input_files)
10
+
11
+ logger.info "Creating #{output_file}.xlsx"
12
+
13
+ workbook = WriteXLSX.new("#{output_file}.xlsx")
14
+
15
+ input_files.each do |csv|
16
+ logger.info "Creating #{csv} Worksheet"
17
+
18
+ worksheet = workbook.add_worksheet(csv)
19
+
20
+ seperate_csv_columns = /,(?![^\[]*\])/
21
+
22
+ File.open(csv, "r") do |f|
23
+ f.each_line do |rows|
24
+ cells = rows.split(SEPERATE_CSV_COLUMNS)
25
+
26
+ cells.each_with_index do |cell, column|
27
+ row = f.lineno - 1
28
+ data = cell.tr_s('"', '').strip
29
+ worksheet.write(row, column, data)
30
+ end
31
+ end
32
+ end
33
+ end
34
+
35
+ workbook.close
36
+
37
+ logger.info "Done. Check for #{output_file}.xlsx"
38
+ end
39
+ end
40
+ end
@@ -24,4 +24,6 @@ Gem::Specification.new do |spec|
24
24
  spec.add_development_dependency 'bundler', '~> 1.16'
25
25
  spec.add_development_dependency 'rake', '~> 10.0'
26
26
  spec.add_development_dependency 'rspec', '~> 3.0'
27
+ spec.add_runtime_dependency 'write_xlsx'
28
+
27
29
  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.39
4
+ version: 0.1.40
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oliver Garcia
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-09-30 00:00:00.000000000 Z
11
+ date: 2020-10-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: write_xlsx
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
55
69
  description: Custom scripts to help with PTO parsing and different strategies.
56
70
  email:
57
71
  - ogarci5@gmail.com
@@ -91,6 +105,7 @@ files:
91
105
  - lib/panomosity/runner.rb
92
106
  - lib/panomosity/utils.rb
93
107
  - lib/panomosity/version.rb
108
+ - lib/panomosity/xlsx_writer.rb
94
109
  - panomosity.gemspec
95
110
  homepage: https://github.com/elevatesystems/panomosity
96
111
  licenses: