microsoft_computer_vision 0.2.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f36b1cff970f4eafa24a19dea852152a2636fac2
4
- data.tar.gz: 022932f1b58a209d7803355a919afb3de408b450
3
+ metadata.gz: 9f5c9be4fccfb7897067556f61c9f059857dcb63
4
+ data.tar.gz: 44eabddfb4f57e193be2838b07b348419da4d192
5
5
  SHA512:
6
- metadata.gz: 5163041e33d342db5d9801ea61678e5b2fafd73375912e46a60c138463fe61af30c79296cc7439f0d3d3269380a0b35c1abda1dfee4c685c6bda20990ceb9432
7
- data.tar.gz: d1acbc502f9529945fa413fe683252f4c6de334f35fcf7570f23328d764caab9725c8f89425dd7757de1a11e1f6e60bc29d231548044ea8617345cb67b26191c
6
+ metadata.gz: 51d0bb5b552e1997f53ffe6e8d69a2457a1121fc3afd1acaaa8b6e193243bd75c63601a7a30c28e6354a22bcb47b7c57acb2fc9ef45bd94faaf7a09f70c621b0
7
+ data.tar.gz: 8213498f365128c7651c66f7ec16f143f3eab2ed5d15bca17ab81c30b8f6f99afac61945ee778d291001149f6bd8fdbcc9e142d596f1351311a190ab56c690dc
data/README.md CHANGED
@@ -27,6 +27,14 @@ $ gem install microsoft_computer_vision
27
27
 
28
28
  ## Usage
29
29
 
30
+ ### CLI
31
+
32
+ ```
33
+ $ mscv analyze /path/to/image --subscription_key your_subscription_key
34
+ ```
35
+
36
+ ### Ruby
37
+
30
38
  ```ruby
31
39
  require 'microsoft_computer_vision'
32
40
 
@@ -10,8 +10,8 @@ module MicrosoftComputerVision::Api
10
10
  @details = details
11
11
  end
12
12
 
13
- def uri
14
- uri = URI("#{MicrosoftComputerVision::Client::API_BASE}#{ENDPOINT}")
13
+ def uri(api_base_url)
14
+ uri = URI("#{api_base_url}#{ENDPOINT}")
15
15
  uri.query = URI.encode_www_form(params)
16
16
 
17
17
  uri
@@ -9,8 +9,8 @@ module MicrosoftComputerVision::Api
9
9
  @max_candidates = max_candidates
10
10
  end
11
11
 
12
- def uri
13
- uri = URI("#{MicrosoftComputerVision::Client::API_BASE}#{ENDPOINT}")
12
+ def uri(api_base_url)
13
+ uri = URI("#{api_base_url}#{ENDPOINT}")
14
14
  uri.query = URI.encode_www_form(params)
15
15
 
16
16
  uri
@@ -9,8 +9,8 @@ module MicrosoftComputerVision::Api
9
9
  @model = model
10
10
  end
11
11
 
12
- def uri
13
- URI("#{MicrosoftComputerVision::Client::API_BASE}#{ENDPOINT}/#{@model}/analyze")
12
+ def uri(api_base_url)
13
+ URI("#{api_base_url}#{ENDPOINT}/#{@model}/analyze")
14
14
  end
15
15
  end
16
16
  end
@@ -5,8 +5,8 @@ module MicrosoftComputerVision::Api
5
5
 
6
6
  ENDPOINT = '/models'
7
7
 
8
- def uri
9
- URI("#{MicrosoftComputerVision::Client::API_BASE}#{ENDPOINT}")
8
+ def uri(api_base_url)
9
+ URI("#{api_base_url}#{ENDPOINT}")
10
10
  end
11
11
  end
12
12
  end
@@ -10,8 +10,8 @@ module MicrosoftComputerVision::Api
10
10
  @detect_orientation = detect_orientation
11
11
  end
12
12
 
13
- def uri
14
- uri = URI("#{MicrosoftComputerVision::Client::API_BASE}#{ENDPOINT}")
13
+ def uri(api_base_url)
14
+ uri = URI("#{api_base_url}#{ENDPOINT}")
15
15
  uri.query = URI.encode_www_form(params)
16
16
 
17
17
  uri
@@ -5,8 +5,8 @@ module MicrosoftComputerVision::Api
5
5
 
6
6
  ENDPOINT = '/tag'
7
7
 
8
- def uri
9
- URI("#{MicrosoftComputerVision::Client::API_BASE}#{ENDPOINT}")
8
+ def uri(api_base_url)
9
+ URI("#{api_base_url}#{ENDPOINT}")
10
10
  end
11
11
  end
12
12
  end
@@ -11,8 +11,8 @@ module MicrosoftComputerVision::Api
11
11
  @smart_cropping = smart_cropping
12
12
  end
13
13
 
14
- def uri
15
- uri = URI("#{MicrosoftComputerVision::Client::API_BASE}#{ENDPOINT}")
14
+ def uri(api_base_url)
15
+ uri = URI("#{api_base_url}#{ENDPOINT}")
16
16
  uri.query = URI.encode_www_form(params)
17
17
 
18
18
  uri
@@ -1,45 +1,43 @@
1
1
  module MicrosoftComputerVision
2
2
  class Client
3
-
4
- API_BASE = 'https://api.projectoxford.ai/vision/v1.0'
5
-
6
- def initialize(subscription_key)
3
+ def initialize(subscription_key, location = "westus")
7
4
  @subscription_key = subscription_key
5
+ @api_base_url = "https://#{location}.api.cognitive.microsoft.com/vision/v1.0"
8
6
  end
9
7
 
10
8
  def analyze(image_path, options)
11
9
  analyze = Api::Analyze.new(options[:visual_features], options[:details])
12
- post_image_path(analyze.uri, image_path)
10
+ post_image_path(analyze.uri(@api_base_url), image_path)
13
11
  end
14
12
 
15
13
  def describe(image_path, options)
16
14
  describe = Api::Describe.new(options[:max_candidates])
17
- post_image_path(describe.uri, image_path)
15
+ post_image_path(describe.uri(@api_base_url), image_path)
18
16
  end
19
17
 
20
18
  def thumbnail(image_path, options)
21
19
  thumbnail = Api::Thumbnail.new(options[:width], options[:height], options[:smart_cropping])
22
- post_image_path(thumbnail.uri, image_path)
20
+ post_image_path(thumbnail.uri(@api_base_url), image_path)
23
21
  end
24
22
 
25
23
  def domain_models
26
24
  domain_models = Api::DomainModels.new()
27
- get(domain_models.uri, {}.to_json)
25
+ get(domain_models.uri(@api_base_url), {}.to_json)
28
26
  end
29
27
 
30
28
  def domain_model(image_path, options)
31
29
  domain_model = Api::DomainModel.new(options[:model])
32
- post_image_path(domain_model.uri, image_path)
30
+ post_image_path(domain_model.uri(@api_base_url), image_path)
33
31
  end
34
32
 
35
33
  def ocr(image_path, options)
36
34
  ocr = Api::OCR.new(options[:language], options[:detect_orientation])
37
- post_image_path(ocr.uri, image_path)
35
+ post_image_path(ocr.uri(@api_base_url), image_path)
38
36
  end
39
37
 
40
38
  def tag(image_path)
41
39
  tag = Api::Tag.new()
42
- post_image_path(tag.uri, image_path)
40
+ post_image_path(tag.uri(@api_base_url), image_path)
43
41
  end
44
42
 
45
43
  private
@@ -1,3 +1,3 @@
1
1
  module MicrosoftComputerVision
2
- VERSION = '0.2.0'
2
+ VERSION = '1.0.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: microsoft_computer_vision
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - henteko
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-04 00:00:00.000000000 Z
11
+ date: 2017-08-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: commander
@@ -129,8 +129,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
129
129
  version: '0'
130
130
  requirements: []
131
131
  rubyforge_project:
132
- rubygems_version: 2.4.5
132
+ rubygems_version: 2.5.1
133
133
  signing_key:
134
134
  specification_version: 4
135
135
  summary: This is a very basic wrapper for the Microsoft Computer Vision API.
136
136
  test_files: []
137
+ has_rdoc: