Class: MicrosoftComputerVision::Client

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

Instance Method Summary collapse

Constructor Details

#initialize(subscription_key, location = "westus") ⇒ Client

Returns a new instance of Client.



3
4
5
6
# File 'lib/microsoft_computer_vision/client.rb', line 3

def initialize(subscription_key, location = "westus")
  @subscription_key = subscription_key
  @api_base_url = "https://#{location}.api.cognitive.microsoft.com/vision/v1.0"
end

Instance Method Details

#analyze(image_path, options) ⇒ Object



8
9
10
11
# File 'lib/microsoft_computer_vision/client.rb', line 8

def analyze(image_path, options)
  analyze = Api::Analyze.new(options[:visual_features], options[:details])
  post_image_path(analyze.uri(@api_base_url), image_path)
end

#describe(image_path, options) ⇒ Object



13
14
15
16
# File 'lib/microsoft_computer_vision/client.rb', line 13

def describe(image_path, options)
  describe = Api::Describe.new(options[:max_candidates])
  post_image_path(describe.uri(@api_base_url), image_path)
end

#domain_model(image_path, options) ⇒ Object



28
29
30
31
# File 'lib/microsoft_computer_vision/client.rb', line 28

def domain_model(image_path, options)
  domain_model = Api::DomainModel.new(options[:model])
  post_image_path(domain_model.uri(@api_base_url), image_path)
end

#domain_modelsObject



23
24
25
26
# File 'lib/microsoft_computer_vision/client.rb', line 23

def domain_models
  domain_models = Api::DomainModels.new()
  get(domain_models.uri(@api_base_url), {}.to_json)
end

#ocr(image_path, options) ⇒ Object



33
34
35
36
# File 'lib/microsoft_computer_vision/client.rb', line 33

def ocr(image_path, options)
  ocr = Api::OCR.new(options[:language], options[:detect_orientation])
  post_image_path(ocr.uri(@api_base_url), image_path)
end

#tag(image_path) ⇒ Object



38
39
40
41
# File 'lib/microsoft_computer_vision/client.rb', line 38

def tag(image_path)
  tag = Api::Tag.new()
  post_image_path(tag.uri(@api_base_url), image_path)
end

#thumbnail(image_path, options) ⇒ Object



18
19
20
21
# File 'lib/microsoft_computer_vision/client.rb', line 18

def thumbnail(image_path, options)
  thumbnail = Api::Thumbnail.new(options[:width], options[:height], options[:smart_cropping])
  post_image_path(thumbnail.uri(@api_base_url), image_path)
end