Class: Iguvium::CV

Inherits:
Object
  • Object
show all
Defined in:
lib/iguvium/cv.rb

Overview

Performs all the computer vision job except table composition. Edge detection is performed using simplified two-directional version of Canny edge detection operator applied to rows and columns as integer vectors

Defined Under Namespace

Classes: Recognized

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(image) ⇒ CV

Prepares image for recognition: initial blur

Parameters:



41
42
43
44
# File 'lib/iguvium/cv.rb', line 41

def initialize(image)
  @blurred = blur(image)
  @image = to_narray(image).to_a
end

Instance Attribute Details

#blurredObject (readonly)

Returns the value of attribute blurred.



46
47
48
# File 'lib/iguvium/cv.rb', line 46

def blurred
  @blurred
end

#boxes=(value) ⇒ Array<Range, Range>

Returns X range, Y range.

Returns:

  • (Array<Range, Range>)

    X range, Y range



# File 'lib/iguvium/cv.rb', line 30


#imageObject (readonly)

Returns the value of attribute image.



46
47
48
# File 'lib/iguvium/cv.rb', line 46

def image
  @image
end

#lines=(value) ⇒ Hash

Returns :vertical and :horizontal lines. Horizontal lines are [Array<Range, Integer>], vertical have [Integer] on x position.

Returns:

  • (Hash)

    :vertical and :horizontal lines. Horizontal lines are [Array<Range, Integer>], vertical have [Integer] on x position



# File 'lib/iguvium/cv.rb', line 30


Instance Method Details

#recognizeRecognized

Returns lines most probably forming table cells and tables’ outer borders as boxes.

Returns:

  • (Recognized)

    lines most probably forming table cells and tables’ outer borders as boxes



50
51
52
53
54
55
56
# File 'lib/iguvium/cv.rb', line 50

def recognize
  Recognized.new(lines, boxes)
  # {
  #   lines: lines,
  #   boxes: boxes
  # }
end