Skip to content

Instantly share code, notes, and snippets.

@szymonbaranowski
Created March 11, 2016 11:21
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
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