Class: Wildfire::Converter::Analizer
- Inherits:
-
Core
- Object
- Core
- Wildfire::Converter::Analizer
show all
- Defined in:
- lib/wildfire/converter/analizer.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(big_cvmat) ⇒ Analizer
4
5
6
7
|
# File 'lib/wildfire/converter/analizer.rb', line 4
def initialize(big_cvmat)
@big_cvmat = big_cvmat
@resizer = Resizer.new(@big_cvmat)
end
|
Instance Method Details
#contours ⇒ Object
44
45
46
47
48
49
50
51
|
# File 'lib/wildfire/converter/analizer.rb', line 44
def contours
greyed = Transformer.grey(@resizer.to_small)
blurred = Transformer.blur(greyed)
cannied = Transformer.canny(blurred)
input_and_output = cannied.dup
execute_contour_find(input_and_output)
end
|
#execute_contour_find(mat) ⇒ Object
53
54
55
56
57
58
59
60
61
|
# File 'lib/wildfire/converter/analizer.rb', line 53
def execute_contour_find(mat)
contour_mat = temp_mat
output_array_of_arrays_contours = Std::Vector::Cv_Mat.new
Cv.find_contours(mat, output_array_of_arrays_contours, contour_mat,
CV_RETR_LIST, CV_CHAIN_APPROX_SIMPLE)
output_array_of_arrays_contours
end
|
#longest_contour ⇒ Object
36
37
38
39
40
41
42
|
# File 'lib/wildfire/converter/analizer.rb', line 36
def longest_contour
sorted_by_length = contours.to_a.sort_by do |contour|
Cv.arc_length(contour, false)
end
sorted_by_length.last
end
|
#shaped_points ⇒ Object
9
10
11
|
# File 'lib/wildfire/converter/analizer.rb', line 9
def shaped_points
page_contour.to_a.map { |p| @resizer.big_point(p) }
end
|
#shaped_rect(rect) ⇒ Object
13
14
15
16
17
18
19
20
21
|
# File 'lib/wildfire/converter/analizer.rb', line 13
def shaped_rect(rect)
top = rect.tl
bottom = rect.br
Cv::Rect.new(top.x * @resizer.to_big_ratio,
top.y * @resizer.to_big_ratio,
(bottom.x - top.x) * @resizer.to_big_ratio,
(bottom.y - top.y) * @resizer.to_big_ratio)
end
|