panomosity 0.1.8 → 0.1.9

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
- SHA1:
3
- metadata.gz: 43fd51dc7dedb7340d1d49debb7988ba41c222a6
4
- data.tar.gz: ac8eda0d88511b85458b34bb98828a145dac89de
2
+ SHA256:
3
+ metadata.gz: f9429ab38b6928e5b0e731cdedbeeab3e95afba20549ee2acb01c3ee0afda0bf
4
+ data.tar.gz: 2aa31fef07b269239cfd09bd4e877f5d897caf7f09eef1c13079564b293e4fa1
5
5
  SHA512:
6
- metadata.gz: b653e9c508061364866c37876161d45aee8aa376ebcdbaa4f909342fc6b21e73f8966759eb3b687e8f69be8d4370f0c0c129f0667a93e6dbbe42d28d68499b4e
7
- data.tar.gz: 32c89ec697236944332d1928c2793b7b062ddfc52b04b1bb80e0517448808c84bed473709fa4256cde17cdcd3c4433b6a7f61da5b3a1c95b511bd49ba18ad084
6
+ metadata.gz: 9c594323f23c9e778737b6a309cce0b006f9e64c500f978075ab9da6e7fec5448df780a90fd4332b0562ccffb597261397e31fdaaa2bae7315009c15a60e6a1f
7
+ data.tar.gz: 0a1e815356032d427326cecce3ee4668dbbad3b806499854088bf27c061919f075015d5ebf08c379294f3c63a723b765180461720453c62fee31c05d16b70510
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- panomosity (0.1.7)
4
+ panomosity (0.1.9)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -4,7 +4,7 @@
4
4
  module Panomosity
5
5
  class ControlPoint
6
6
  @@attributes = %i(n N x y X Y t)
7
- @@calculated_attributes = %i(dist px py pdist conn_type)
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,7 +55,7 @@ module Panomosity
55
55
  distance = angle * radius
56
56
  cp.dist = distance
57
57
 
58
- # Pixel distance
58
+ # pixel distance
59
59
  x1 = (image1.w / 2.0) - cp.x1 + image1.d
60
60
  y1 = (image1.h / 2.0) - cp.y1 + image1.e
61
61
  x2 = (image2.w / 2.0) - cp.x2 + image2.d
@@ -63,9 +63,17 @@ module Panomosity
63
63
 
64
64
  cp.px = x1 - x2
65
65
  cp.py = y1 - y2
66
- pixel_distance = Math.sqrt(cp.px**2 + cp.py**2)
67
- cp.pdist = pixel_distance
66
+ cp.pdist = Math.sqrt(cp.px ** 2 + cp.py ** 2)
67
+
68
+ # pixel distance including roll
69
+ r = image1.r * Math::PI / 180
70
+ cp.prx = image1.d - image2.d + Math.cos(r) * (cp.x2 - cp.x1) - Math.sin(r) * (cp.y2 - cp.y1)
71
+ cp.pry = image1.e - image2.e + Math.cos(r) * (cp.y2 - cp.y1) - Math.sin(r) * (cp.x2 - cp.x1)
72
+ cp.prdist = Math.sqrt(cp.prx ** 2 + cp.pry ** 2)
73
+
68
74
  cp.conn_type = image1.d == image2.d ? :vertical : :horizontal
75
+ cp.i1 = image1
76
+ cp.i2 = image2
69
77
  end
70
78
  end
71
79
 
@@ -192,13 +192,14 @@ module Panomosity
192
192
  # Uses image magick to crop centers
193
193
  def crop_centers
194
194
  logger.info 'cropping centers'
195
- scale_factor = @csv.each_line.first.split(',').last.to_f
195
+ scale_factor = @csv_file.split(/\n/).first.split(',').last.to_f
196
+ percent = (scale_factor*100).round
197
+ logger.debug "cropping to #{percent}%"
196
198
  unless @options[:without_cropping]
197
199
  images = Image.parse(@input_file)
198
200
  images.each do |image|
199
201
  geometry = `identify -verbose #{image.name} | grep Geometry`.strip
200
202
  _, width, height = *geometry.match(/(\d{2,5})x(\d{2,5})(\+|\-)\d{1,5}(\+|\-)\d{1,5}/)
201
- percent = (scale_factor*100).round
202
203
  width_offset = (width.to_f * (1 - scale_factor) / 2).round
203
204
  height_offset = (height.to_f * (1 - scale_factor) / 2).round
204
205
  logger.debug "cropping #{image.name}"
@@ -226,13 +227,13 @@ module Panomosity
226
227
  d_diffs = []
227
228
  ds.each_with_index do |_, i|
228
229
  next if i == 0
229
- d_diffs.push((ds[i] - ds[i-1]).abs / 2)
230
+ d_diffs.push((ds[i] - ds[i-1]).abs * (1-scale_factor))
230
231
  end
231
232
 
232
233
  e_diffs = []
233
234
  es.each_with_index do |_, i|
234
235
  next if i == 0
235
- e_diffs.push((es[i] - es[i-1]).abs / 2)
236
+ e_diffs.push((es[i] - es[i-1]).abs * (1-scale_factor))
236
237
  end
237
238
 
238
239
  d_map = Hash[ds.map.with_index { |d, i| i == 0 ? [d, d] : [d, d - d_diffs[0..(i-1)].reduce(:+)] }]
@@ -599,7 +600,7 @@ module Panomosity
599
600
  control_points = ControlPoint.calculate_distances(images, panorama_variable)
600
601
 
601
602
  control_points.each do |cp|
602
- logger.debug "#{cp.to_s.sub(/\n/, '')} dist #{cp.dist} pixel_dist #{cp.px},#{cp.py},#{cp.pdist} conn_type #{cp.conn_type}"
603
+ logger.debug "#{cp.to_s.sub(/\n/, '')} dist #{cp.dist.round(4)} pixel_dist #{cp.px.round(4)},#{cp.py.round(4)},#{cp.pdist.round(4)} pixel_r_dist #{cp.prx.round(4)},#{cp.pry.round(4)},#{cp.prdist.round(4)} conn_type #{cp.conn_type}"
603
604
  end
604
605
  end
605
606
 
@@ -1,3 +1,3 @@
1
1
  module Panomosity
2
- VERSION = '0.1.8'
2
+ VERSION = '0.1.9'
3
3
  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.8
4
+ version: 0.1.9
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-09-24 00:00:00.000000000 Z
11
+ date: 2018-09-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -102,7 +102,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
102
102
  version: '0'
103
103
  requirements: []
104
104
  rubyforge_project:
105
- rubygems_version: 2.4.6
105
+ rubygems_version: 2.7.3
106
106
  signing_key:
107
107
  specification_version: 4
108
108
  summary: Wrapper for the PTO file parsing needed for PanoTools.