Class: Mindee::V1::Parsing::Standard::PositionField
- Inherits:
-
Object
- Object
- Mindee::V1::Parsing::Standard::PositionField
- Defined in:
- lib/mindee/v1/parsing/standard/position_field.rb
Overview
An element's position on the image
Instance Attribute Summary collapse
- #bounding_box ⇒ Mindee::Geometry::Quadrilateral readonly
- #polygon ⇒ Mindee::Geometry::Polygon readonly
- #quadrangle ⇒ Mindee::Geometry::Quadrilateral readonly
- #rectangle ⇒ Mindee::Geometry::Quadrilateral readonly
- #value ⇒ Mindee::Geometry::Polygon readonly
Instance Method Summary collapse
-
#initialize(prediction, page_id) ⇒ PositionField
constructor
A new instance of PositionField.
-
#to_s ⇒ String
String representation.
Constructor Details
#initialize(prediction, page_id) ⇒ PositionField
Returns a new instance of PositionField.
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/mindee/v1/parsing/standard/position_field.rb', line 22 def initialize(prediction, page_id) unless prediction['polygon'].nil? || prediction['polygon'].empty? @polygon = Mindee::Geometry::Polygon.new(prediction['polygon']) end @quadrangle = to_quadrilateral(prediction, 'quadrangle') @rectangle = to_quadrilateral(prediction, 'rectangle') @bounding_box = to_quadrilateral(prediction, 'bounding_box') @page_id = page_id || prediction['page_id'] @value = @polygon end |
Instance Attribute Details
#bounding_box ⇒ Mindee::Geometry::Quadrilateral (readonly)
18 19 20 |
# File 'lib/mindee/v1/parsing/standard/position_field.rb', line 18 def bounding_box @bounding_box end |
#polygon ⇒ Mindee::Geometry::Polygon (readonly)
10 11 12 |
# File 'lib/mindee/v1/parsing/standard/position_field.rb', line 10 def polygon @polygon end |
#quadrangle ⇒ Mindee::Geometry::Quadrilateral (readonly)
14 15 16 |
# File 'lib/mindee/v1/parsing/standard/position_field.rb', line 14 def quadrangle @quadrangle end |
#rectangle ⇒ Mindee::Geometry::Quadrilateral (readonly)
16 17 18 |
# File 'lib/mindee/v1/parsing/standard/position_field.rb', line 16 def rectangle @rectangle end |
#value ⇒ Mindee::Geometry::Polygon (readonly)
12 13 14 |
# File 'lib/mindee/v1/parsing/standard/position_field.rb', line 12 def value @value end |
Instance Method Details
#to_s ⇒ String
String representation.
38 39 40 41 42 43 44 45 |
# File 'lib/mindee/v1/parsing/standard/position_field.rb', line 38 def to_s return "Polygon with #{@polygon.size} points." if @polygon&.size&.positive? return "Polygon with #{@bounding_box.size} points." if @bounding_box&.size&.positive? return "Polygon with #{@rectangle.size} points." if @rectangle&.size&.positive? return "Polygon with #{@quadrangle.size} points." if @quadrangle&.size&.positive? '' end |