Skip to content

Instantly share code, notes, and snippets.

@szymonbaranowski

szymonbaranowski/request.rb Secret

Created Mar 11, 2016
Embed
What would you like to do?
%w[annotate_image batch feature image vision].each do |serv|
require_relative "#{serv}"
end
module Services
module Builders
class Request
FEATURE_TYPES = %w(
SAFE_SEARCH_DETECTION FACE_DETECTION
LABEL_DETECTION TEXT_DETECTION
LANDMARK_DETECTION LOGO_DETECTION
).freeze
def initialize(image_path)
@image_path = image_path
@features = []
end
def call
vision = Services::Builders::Vision.new.call
FEATURE_TYPES.each { |type| @features << Services::Builders::Feature.new(type).call }
image = Services::Builders::Image.new(@image_path).call
annotate_image = Services::Builders::AnnotateImage.new(image, @features).call
batch_annotate = Services::Builders::BatchAnnotateImages.new([annotate_image]).call
vision.annotate_image(batch_annotate).to_h[:responses].first
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.