Class: Mindee::V2::Product::Crop::CropItem
- Inherits:
-
Object
- Object
- Mindee::V2::Product::Crop::CropItem
- Defined in:
- lib/mindee/v2/product/crop/crop_item.rb
Overview
Result of a cropped document region.
Instance Attribute Summary collapse
-
#location ⇒ V2::Parsing::Field::FieldLocation
readonly
Coordinates of the detected object on the document.
-
#object_type ⇒ String
readonly
Type or classification of the detected object.
Instance Method Summary collapse
-
#extract_from_file(input_source) ⇒ ExtractedImage
Extract all crop items from this page.
-
#initialize(server_response) ⇒ CropItem
constructor
A new instance of CropItem.
-
#to_s ⇒ String
String representation.
Constructor Details
#initialize(server_response) ⇒ CropItem
Returns a new instance of CropItem.
15 16 17 18 |
# File 'lib/mindee/v2/product/crop/crop_item.rb', line 15 def initialize(server_response) @object_type = server_response['object_type'] @location = Mindee::V2::Parsing::Field::FieldLocation.new(server_response['location']) end |
Instance Attribute Details
#location ⇒ V2::Parsing::Field::FieldLocation (readonly)
Returns Coordinates of the detected object on the document.
12 13 14 |
# File 'lib/mindee/v2/product/crop/crop_item.rb', line 12 def location @location end |
#object_type ⇒ String (readonly)
Returns Type or classification of the detected object.
10 11 12 |
# File 'lib/mindee/v2/product/crop/crop_item.rb', line 10 def object_type @object_type end |
Instance Method Details
#extract_from_file(input_source) ⇒ ExtractedImage
Extract all crop items from this page
30 31 32 33 34 |
# File 'lib/mindee/v2/product/crop/crop_item.rb', line 30 def extract_from_file(input_source) Image::ImageExtractor.extract_multiple_images_from_source( input_source, @location.page, [@location.polygon] )[0] end |
#to_s ⇒ String
String representation.
22 23 24 |
# File 'lib/mindee/v2/product/crop/crop_item.rb', line 22 def to_s "* :Location: #{location}\n :Object Type: #{object_type}" end |