Class: MicrosoftComputerVision::Client
- Inherits:
-
Object
- Object
- MicrosoftComputerVision::Client
- Defined in:
- lib/microsoft_computer_vision/client.rb
Instance Method Summary collapse
- #analyze(image_path, options) ⇒ Object
- #describe(image_path, options) ⇒ Object
- #domain_model(image_path, options) ⇒ Object
- #domain_models ⇒ Object
-
#initialize(subscription_key, location = "westus") ⇒ Client
constructor
A new instance of Client.
- #ocr(image_path, options) ⇒ Object
- #tag(image_path) ⇒ Object
- #thumbnail(image_path, options) ⇒ Object
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, ) analyze = Api::Analyze.new([:visual_features], [: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, ) describe = Api::Describe.new([: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, ) domain_model = Api::DomainModel.new([:model]) post_image_path(domain_model.uri(@api_base_url), image_path) end |
#domain_models ⇒ Object
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, ) ocr = Api::OCR.new([:language], [: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, ) thumbnail = Api::Thumbnail.new([:width], [:height], [:smart_cropping]) post_image_path(thumbnail.uri(@api_base_url), image_path) end |