Class: Mindee::V2::Product::Crop::CropResult

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

Overview

Result of a crop utility inference.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(server_response) ⇒ CropResult

Returns a new instance of CropResult.

Parameters:

  • server_response (Hash)

    Hash representation of the JSON returned by the service.



15
16
17
18
19
20
21
# File 'lib/mindee/v2/product/crop/crop_result.rb', line 15

def initialize(server_response)
  @crops = if server_response.key?('crops')
             server_response['crops'].map do |crop|
               CropItem.new(crop)
             end
           end
end

Instance Attribute Details

#cropsArray<Cropitem> (readonly)

Returns List of results of cropped document regions.

Returns:

  • (Array<Cropitem>)

    List of results of cropped document regions.



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

def crops
  @crops
end

Instance Method Details

#extract_from_input_source(input_source) ⇒ Image::ExtractedImages

Apply the crop inference to a file and return a list of extracted images.

Parameters:

Returns:



27
28
29
# File 'lib/mindee/v2/product/crop/crop_result.rb', line 27

def extract_from_input_source(input_source)
  FileOperation::Crop.extract_crops(input_source, @crops)
end

#to_sString

String representation.

Returns:

  • (String)


33
34
35
36
37
# File 'lib/mindee/v2/product/crop/crop_result.rb', line 33

def to_s
  crops_str = @crops.join("\n")

  "Crops\n=====\n#{crops_str}"
end