Class: Mindee::V2::Product::Crop::CropItem

Inherits:
Object
  • Object
show all
Defined in:
lib/mindee/v2/product/crop/crop_item.rb

Overview

Result of a cropped document region.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(server_response) ⇒ CropItem

Returns a new instance of CropItem.

Parameters:

  • server_response (Hash)

    Hash representation of the JSON returned by the service.



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

#locationV2::Parsing::Field::FieldLocation (readonly)

Returns Coordinates of the detected object on the document.

Returns:



12
13
14
# File 'lib/mindee/v2/product/crop/crop_item.rb', line 12

def location
  @location
end

#object_typeString (readonly)

Returns Type or classification of the detected object.

Returns:

  • (String)

    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

Parameters:

Returns:

  • (ExtractedImage)


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_sString

String representation.

Returns:

  • (String)


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