This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%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