Class: ReceiptDataExtraction::Extract

Inherits:
Object
  • Object
show all
Defined in:
lib/receipt_data_extraction.rb

Class Method Summary collapse

Class Method Details

.call_vision_api(image) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/receipt_data_extraction.rb', line 7

def self.call_vision_api(image)
    image_annotator = Google::Cloud::Vision::ImageAnnotator.new
    response = image_annotator.text_detection(
        image: image,
        max_results: 1 # optional, defaults to 10
    )
    text_detected = ""
    response.responses.each do |res|
        text_detected << res.text_annotations[0].description
    end
  return text_detected
end