Skip to content

Instantly share code, notes, and snippets.

@szymonbaranowski
Created March 11, 2016 11:21
Show Gist options
  • Save szymonbaranowski/acdcc7ca39ee2f9031ab to your computer and use it in GitHub Desktop.
Save szymonbaranowski/acdcc7ca39ee2f9031ab to your computer and use it in GitHub Desktop.
%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