Module: Panomosity

Defined in:
lib/panomosity/image.rb,
lib/panomosity.rb,
lib/panomosity/pair.rb,
lib/panomosity/utils.rb,
lib/panomosity/errors.rb,
lib/panomosity/runner.rb,
lib/panomosity/measure.rb,
lib/panomosity/version.rb,
lib/panomosity/panorama.rb,
lib/panomosity/optimizer.rb,
lib/panomosity/xlsx_writer.rb,
lib/panomosity/neighborhood.rb,
lib/panomosity/control_point.rb,
lib/panomosity/panorama_variable.rb,
lib/panomosity/neighborhood_group.rb,
lib/panomosity/optimisation_variable.rb,
lib/panomosity/generalized_neighborhood.rb

Overview

Example of a control point line c n26 N26 x887.4 y1056.72 X1128.12 Y1077.12 t2

Defined Under Namespace

Modules: Utils, XLSXWriter Classes: ControlPoint, GeneralizedNeighborhood, Image, Measure, Neighborhood, NeighborhoodGroup, NoSimilarNeighborhoodsError, OptimisationVariable, Optimizer, Pair, Panorama, PanoramaVariable, Runner

Constant Summary collapse

VERSION =
'0.1.41'

Class Method Summary collapse

Class Method Details

.loggerObject



127
128
129
130
131
132
133
134
135
136
# File 'lib/panomosity.rb', line 127

def self.logger
  if @logger.nil?
    @logger = Logger.new(STDOUT)
    @logger.level = Logger::DEBUG
    @logger.formatter = proc do |severity, datetime, progname, msg|
      "[#{datetime}][#{severity}] #{msg}\n"
    end
  end
  @logger
end

.parse(arguments) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# File 'lib/panomosity.rb', line 22

def self.parse(arguments)
  options = {}
  OptionParser.new do |parser|
    parser.banner = 'Usage: panomosity command [options]'
    parser.separator ''
    parser.separator 'Specific options:'

    parser.on('-i', '--input PTO', 'Input PTO file') do |pto|
      options[:input] = pto
    end

    parser.on('-o', '--output PTO', 'Output PTO file') do |pto|
      options[:output] = pto
    end

    parser.on('-c', '--csv [CSV]', 'CSV file for reference') do |csv|
      options[:csv] = csv
    end

    parser.on('-k', '--compare [PTO]', 'Compare PTO file for reference') do |pto|
      options[:compare] = pto
    end

    parser.on('-r', '--report [REPORT]', 'Include a report (when adding calibration control points)') do |report|
      options[:report] = report
    end

    parser.on('--without-cropping', 'Do not crop when running "crop_centers" (usually when the original run failed)') do |wc|
      options[:without_cropping] = wc
    end

    parser.on('--remove-equal-signs', 'Remove equal signs when running "convert_equaled_image_parameters" (necessary when parsing the PTO file using Panotools)') do |eq|
      options[:remove_equal_signs] = eq
    end

    parser.on('--max-removal FRAC', Float, 'Max fraction of control points to be removed when running "clean_control_points" that are statistical outliers') do |mr|
      options[:max_removal] = mr
    end

    parser.on('--res RES', 'Resolution of images for nona_grid') do |res|
      options[:res] = res
    end

    parser.on('-v', '--[no-]verbose', 'Run verbosely') do |v|
      options[:verbose] = v
    end

    parser.on('--verbosity LEVEL', Integer, 'Set verbosity level') do |v|
      options[:verbosity] = v
    end

    parser.on('--report-type TYPE', 'Type of report to create (only when running create_calibration_report)') do |type|
      options[:report_type] = type
    end

    parser.on('--darwin', 'Sets a flag to indicate the operating system') do |type|
      options[:darwin] = type
    end

    parser.on('--version', 'Show the installed version') do
      puts VERSION
      exit
    end

    parser.on('--regional-distance-similarities-count COUNT', Integer, 'Set the minimum amount of regional control point counts for determining similar neighborhoods (default: 3)') do |count|
      options[:regional_distance_similarities_count] = count
    end

    parser.on('--max-reduction-attempts COUNT', Integer, 'Set the max reduction attempts when removing neighborhood outliers (default: 2)') do |count|
      options[:max_reduction_attempts] = count
    end

    desc = <<~DESC
      Set distances to use when determining neighborhood region size in pairs
      Use JSON e.g. '{"x1": 150, "x2": 30}'
      Defaults:
        Vertical pair is x is 10% of image width and y is 100px 
        Horizontal pair is x is 100px and y is 10% of image height
    DESC
    parser.on('--distances [DISTANCE_JSON]', desc) do |distances|
      options[:distances] = JSON.parse(distances) rescue nil
    end

    parser.on('--distances-horizontal [DISTANCE_JSON]', 'Same as above but only affects horizontal image pairs') do |distances|
      options[:regional_distance_similarities_count] = JSON.parse(distances) rescue nil
    end

    parser.on('--distances-vertical [DISTANCE_JSON]', 'Same as above but only affects vertical image pairs') do |distances|
      options[:regional_distance_similarities_count] = JSON.parse(distances) rescue nil
    end

    parser.on('-h', '--help', 'Display this screen') do
      puts parser
      exit
    end

    parser.parse!(arguments)
  end

  # default options
  options[:verbosity] ||= 0
  runner = Runner.new(options)
  runner.run(ARGV[0])
end