Class: Percept::LineDetector
- Inherits:
-
Object
- Object
- Percept::LineDetector
- Includes:
- Utils
- Defined in:
- lib/percept/line_detector.rb
Instance Attribute Summary collapse
-
#image ⇒ Object
Returns the value of attribute image.
Instance Method Summary collapse
Methods included from Utils
#color_tolerance, #scaled_color
Instance Attribute Details
#image ⇒ Object
Returns the value of attribute image.
7 8 9 |
# File 'lib/percept/line_detector.rb', line 7 def image @image end |
Instance Method Details
#detect_lines(image) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/percept/line_detector.rb', line 34 def detect_lines(image) self.image = image lines = detect_lines_in_rows if lines.empty? Percept.config.maximize_color_tolerance! @columns = nil lines = detect_lines_in_rows end lines.remove_short_lines! lines end |
#find_lines(row, row_number) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/percept/line_detector.rb', line 9 def find_lines(row, row_number) start_index = nil lines = LineCollection.new row.each_with_index do |pixel, index| if pixel.blackish? start_index ||= index elsif divot?(row, index) next elsif start_index if index - start_index > slope_length lines << Line.new( start_x: start_index, end_x: index, start_y: row_number, row: row, image: image, ) end start_index = nil end end lines end |