Class: Mindee::Parsing::Common::OCR::MVisionV1
- Inherits:
-
Object
- Object
- Mindee::Parsing::Common::OCR::MVisionV1
- Defined in:
- lib/mindee/parsing/common/ocr/mvision_v1.rb
Overview
Mindee Vision V1.
Instance Attribute Summary collapse
-
#pages ⇒ Array<OCRPage>
readonly
List of pages.
Instance Method Summary collapse
-
#initialize(prediction) ⇒ MVisionV1
constructor
A new instance of MVisionV1.
-
#reconstruct_vertically(coordinates, page_id, x_margin) ⇒ Mindee::Parsing::Common::OCR::OCRLine
Constructs a line from a column, located underneath given coordinates start.
- #to_s ⇒ String
Constructor Details
#initialize(prediction) ⇒ MVisionV1
Returns a new instance of MVisionV1.
14 15 16 17 18 19 |
# File 'lib/mindee/parsing/common/ocr/mvision_v1.rb', line 14 def initialize(prediction) @pages = [] # : Array[Mindee::Parsing::Common::OCR::OCRPage] prediction['pages'].each do |page_prediction| @pages.push(OCRPage.new(page_prediction)) end end |
Instance Attribute Details
#pages ⇒ Array<OCRPage> (readonly)
List of pages.
11 12 13 |
# File 'lib/mindee/parsing/common/ocr/mvision_v1.rb', line 11 def pages @pages end |
Instance Method Details
#reconstruct_vertically(coordinates, page_id, x_margin) ⇒ Mindee::Parsing::Common::OCR::OCRLine
Constructs a line from a column, located underneath given coordinates start.
37 38 39 40 41 42 43 44 45 |
# File 'lib/mindee/parsing/common/ocr/mvision_v1.rb', line 37 def reconstruct_vertically(coordinates, page_id, x_margin) line_arr = OCRLine.new([]) @pages[page_id].all_lines.each do |line| line.each do |word| line_arr.push(word) if Geometry.below?(word.polygon, coordinates, x_margin / 2, x_margin * 2) end end line_arr end |
#to_s ⇒ String
22 23 24 25 26 27 28 29 |
# File 'lib/mindee/parsing/common/ocr/mvision_v1.rb', line 22 def to_s out_str = String.new @pages.map do |page| out_str << "\n" out_str << page.to_s end out_str.strip end |