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
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 |