Class: Wildfire::Converter::Resizer

Inherits:
Core
  • Object
show all
Defined in:
lib/wildfire/converter/resizer.rb

Constant Summary

Constants inherited from Core

Core::RED

Instance Method Summary collapse

Methods inherited from Core

#generate_path, #quick_save, #save, #temp_mat

Constructor Details

#initialize(original, small_height: 500.0) ⇒ Resizer



4
5
6
7
# File 'lib/wildfire/converter/resizer.rb', line 4

def initialize(original, small_height: 500.0)
  @original = original
  @small_height = small_height
end

Instance Method Details

#big_point(coords) ⇒ Object

def big_point(point)

big = point.map { |xy| (xy * to_big_ratio).to_i }
Cv::Point.new(*big)

end



35
36
37
# File 'lib/wildfire/converter/resizer.rb', line 35

def big_point(coords)
  coords.map { |coord| (coord * to_big_ratio).to_i }
end

#small_sizeObject



15
16
17
18
19
20
# File 'lib/wildfire/converter/resizer.rb', line 15

def small_size
  new_size = @original.size.dup
  new_size.height = @small_height
  new_size.width = new_size.height * to_small_ratio
  new_size
end

#to_big_coords(rect) ⇒ Object



39
40
41
# File 'lib/wildfire/converter/resizer.rb', line 39

def to_big_coords(rect)
  rect.map { |coords| big_point(coords) }
end

#to_big_ratioObject



26
27
28
# File 'lib/wildfire/converter/resizer.rb', line 26

def to_big_ratio
  @original.size.height / @small_height
end

#to_smallObject



9
10
11
12
13
# File 'lib/wildfire/converter/resizer.rb', line 9

def to_small
  new_sized_mat = temp_mat
  Cv.resize(@original, new_sized_mat, small_size)
  new_sized_mat
end

#to_small_ratioObject



22
23
24
# File 'lib/wildfire/converter/resizer.rb', line 22

def to_small_ratio
  @original.size.width / @original.size.height.to_f
end