microsoft_computer_vision 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rspec +2 -0
- data/README.md +4 -1
- data/Rakefile +4 -0
- data/bin/mscv +5 -0
- data/example/all.rb +21 -38
- data/lib/microsoft_computer_vision/api/analyze.rb +4 -2
- data/lib/microsoft_computer_vision/api/describe.rb +3 -1
- data/lib/microsoft_computer_vision/api/domain_model.rb +2 -0
- data/lib/microsoft_computer_vision/api/domain_models.rb +2 -0
- data/lib/microsoft_computer_vision/api/ocr.rb +4 -2
- data/lib/microsoft_computer_vision/api/tag.rb +2 -0
- data/lib/microsoft_computer_vision/api/thumbnail.rb +5 -3
- data/lib/microsoft_computer_vision/client.rb +30 -82
- data/lib/microsoft_computer_vision/command_builder.rb +133 -0
- data/lib/microsoft_computer_vision/version.rb +1 -1
- data/lib/microsoft_computer_vision.rb +2 -0
- data/microsoft_computer_vision.gemspec +7 -2
- metadata +52 -7
- data/bin/console +0 -14
- data/bin/setup +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f36b1cff970f4eafa24a19dea852152a2636fac2
|
4
|
+
data.tar.gz: 022932f1b58a209d7803355a919afb3de408b450
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5163041e33d342db5d9801ea61678e5b2fafd73375912e46a60c138463fe61af30c79296cc7439f0d3d3269380a0b35c1abda1dfee4c685c6bda20990ceb9432
|
7
|
+
data.tar.gz: d1acbc502f9529945fa413fe683252f4c6de334f35fcf7570f23328d764caab9725c8f89425dd7757de1a11e1f6e60bc29d231548044ea8617345cb67b26191c
|
data/.rspec
ADDED
data/README.md
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
# Microsoft Computer Vision API
|
2
2
|
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/microsoft_computer_vision.svg)](https://badge.fury.io/rb/microsoft_computer_vision)
|
4
|
+
[![Build Status](https://travis-ci.org/henteko/microsoft_computer_vision.svg?branch=master)](https://travis-ci.org/henteko/microsoft_computer_vision)
|
5
|
+
|
3
6
|
This is a very basic wrapper for the [Microsoft Computer Vision API](https://www.microsoft.com/cognitive-services/en-us/computer-vision-api).
|
4
7
|
|
5
8
|
## Installation
|
@@ -33,7 +36,7 @@ options = {
|
|
33
36
|
details: 'Celebrities'
|
34
37
|
}
|
35
38
|
|
36
|
-
res = client.
|
39
|
+
res = client.analyze('http://example.com/images/test.jpg', options)
|
37
40
|
puts res.body
|
38
41
|
```
|
39
42
|
|
data/Rakefile
CHANGED
data/bin/mscv
ADDED
data/example/all.rb
CHANGED
@@ -4,12 +4,7 @@ require 'json'
|
|
4
4
|
subscription_key = ENV['SUBSCRIPTION_KEY']
|
5
5
|
@client = MicrosoftComputerVision::Client.new(subscription_key)
|
6
6
|
IMAGE_URL = 'https://www.pakutaso.com/shared/img/thumb/PAK105215431_TP_V.jpg'
|
7
|
-
|
8
|
-
def file_open
|
9
|
-
File.open(File.expand_path('../test.jpg', __FILE__)) do |image_file|
|
10
|
-
yield(image_file)
|
11
|
-
end
|
12
|
-
end
|
7
|
+
IMAGE_FILE_PATH = File.expand_path('../test.jpg', __FILE__)
|
13
8
|
|
14
9
|
# See: https://dev.projectoxford.ai/docs/services/56f91f2d778daf23d8ec6739/operations/56f91f2e778daf14a499e1fa
|
15
10
|
def analyze
|
@@ -21,14 +16,12 @@ def analyze
|
|
21
16
|
}
|
22
17
|
|
23
18
|
# image url
|
24
|
-
res = @client.
|
19
|
+
res = @client.analyze(IMAGE_URL, options)
|
25
20
|
puts res.body
|
26
21
|
|
27
22
|
# image file
|
28
|
-
|
29
|
-
|
30
|
-
puts res.body
|
31
|
-
end
|
23
|
+
res = @client.analyze(IMAGE_FILE_PATH, options)
|
24
|
+
puts res.body
|
32
25
|
end
|
33
26
|
|
34
27
|
# See: https://dev.projectoxford.ai/docs/services/56f91f2d778daf23d8ec6739/operations/56f91f2e778daf14a499e1fe
|
@@ -40,14 +33,12 @@ def describe
|
|
40
33
|
}
|
41
34
|
|
42
35
|
# image url
|
43
|
-
res = @client.
|
36
|
+
res = @client.describe(IMAGE_URL, options)
|
44
37
|
puts res.body
|
45
38
|
|
46
39
|
# image file
|
47
|
-
|
48
|
-
|
49
|
-
puts res.body
|
50
|
-
end
|
40
|
+
res = @client.describe(IMAGE_FILE_PATH, options)
|
41
|
+
puts res.body
|
51
42
|
end
|
52
43
|
|
53
44
|
# See: https://dev.projectoxford.ai/docs/services/56f91f2d778daf23d8ec6739/operations/56f91f2e778daf14a499e1fb
|
@@ -61,19 +52,17 @@ def thumbnail
|
|
61
52
|
}
|
62
53
|
|
63
54
|
# image url
|
64
|
-
res = @client.
|
55
|
+
res = @client.thumbnail(IMAGE_URL, options)
|
65
56
|
out = File.expand_path('../thumbnail_from_image_url.jpg', __FILE__)
|
66
57
|
File.write out, res.body
|
67
58
|
puts "Created #{out}"
|
68
59
|
|
69
60
|
# image file
|
70
|
-
|
71
|
-
out = File.expand_path('../thumbnail_from_image_file.jpg', __FILE__)
|
61
|
+
out = File.expand_path('../thumbnail_from_image_file.jpg', __FILE__)
|
72
62
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
end
|
63
|
+
res = @client.thumbnail(IMAGE_FILE_PATH, options)
|
64
|
+
File.write out, res.body
|
65
|
+
puts "Created #{out}"
|
77
66
|
end
|
78
67
|
|
79
68
|
# See: https://dev.projectoxford.ai/docs/services/56f91f2d778daf23d8ec6739/operations/56f91f2e778daf14a499e1fd
|
@@ -94,14 +83,12 @@ def ocr
|
|
94
83
|
}
|
95
84
|
|
96
85
|
# image url
|
97
|
-
res = @client.
|
86
|
+
res = @client.ocr(IMAGE_URL, options)
|
98
87
|
puts res.body
|
99
88
|
|
100
89
|
# image file
|
101
|
-
|
102
|
-
|
103
|
-
puts res.body
|
104
|
-
end
|
90
|
+
res = @client.ocr(IMAGE_FILE_PATH, options)
|
91
|
+
puts res.body
|
105
92
|
end
|
106
93
|
|
107
94
|
# See: https://dev.projectoxford.ai/docs/services/56f91f2d778daf23d8ec6739/operations/56f91f2e778daf14a499e200
|
@@ -118,14 +105,12 @@ def domain_model
|
|
118
105
|
}
|
119
106
|
|
120
107
|
# image url
|
121
|
-
res = @client.
|
108
|
+
res = @client.domain_model(IMAGE_URL, options)
|
122
109
|
puts res.body
|
123
110
|
|
124
111
|
# image file
|
125
|
-
|
126
|
-
|
127
|
-
puts res.body
|
128
|
-
end
|
112
|
+
res = @client.domain_model(IMAGE_FILE_PATH, options)
|
113
|
+
puts res.body
|
129
114
|
end
|
130
115
|
|
131
116
|
# See: https://dev.projectoxford.ai/docs/services/56f91f2d778daf23d8ec6739/operations/56f91f2e778daf14a499e1ff
|
@@ -133,14 +118,12 @@ def tag
|
|
133
118
|
puts 'Tag'
|
134
119
|
|
135
120
|
# image url
|
136
|
-
res = @client.
|
121
|
+
res = @client.tag(IMAGE_URL)
|
137
122
|
puts res.body
|
138
123
|
|
139
124
|
# image file
|
140
|
-
|
141
|
-
|
142
|
-
puts res.body
|
143
|
-
end
|
125
|
+
res = @client.tag(IMAGE_FILE_PATH)
|
126
|
+
puts res.body
|
144
127
|
end
|
145
128
|
|
146
129
|
analyze
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# Docs: https://dev.projectoxford.ai/docs/services/56f91f2d778daf23d8ec6739/operations/56f91f2e778daf14a499e1fa
|
2
|
+
|
1
3
|
module MicrosoftComputerVision::Api
|
2
4
|
class Analyze
|
3
5
|
|
@@ -17,8 +19,8 @@ module MicrosoftComputerVision::Api
|
|
17
19
|
|
18
20
|
def params
|
19
21
|
data = {}
|
20
|
-
data[:visualFeatures] = @visual_features
|
21
|
-
data[:details] = @details
|
22
|
+
data[:visualFeatures] = @visual_features unless @visual_features.nil?
|
23
|
+
data[:details] = @details unless @details.nil?
|
22
24
|
|
23
25
|
data
|
24
26
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# Docs: https://dev.projectoxford.ai/docs/services/56f91f2d778daf23d8ec6739/operations/56f91f2e778daf14a499e1fe
|
2
|
+
|
1
3
|
module MicrosoftComputerVision::Api
|
2
4
|
class Describe
|
3
5
|
|
@@ -16,7 +18,7 @@ module MicrosoftComputerVision::Api
|
|
16
18
|
|
17
19
|
def params
|
18
20
|
data = {}
|
19
|
-
data[:maxCandidates] = @max_candidates
|
21
|
+
data[:maxCandidates] = @max_candidates unless @max_candidates.nil?
|
20
22
|
|
21
23
|
data
|
22
24
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# Docs: https://dev.projectoxford.ai/docs/services/56f91f2d778daf23d8ec6739/operations/56f91f2e778daf14a499e1fc
|
2
|
+
|
1
3
|
module MicrosoftComputerVision::Api
|
2
4
|
class OCR
|
3
5
|
|
@@ -17,8 +19,8 @@ module MicrosoftComputerVision::Api
|
|
17
19
|
|
18
20
|
def params
|
19
21
|
data = {}
|
20
|
-
data[:language] = @language
|
21
|
-
data[:detectOrientation] = @detect_orientation
|
22
|
+
data[:language] = @language unless @language.nil?
|
23
|
+
data[:detectOrientation] = @detect_orientation unless @detect_orientation.nil?
|
22
24
|
|
23
25
|
data
|
24
26
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# Docs: https://dev.projectoxford.ai/docs/services/56f91f2d778daf23d8ec6739/operations/56f91f2e778daf14a499e1fb
|
2
|
+
|
1
3
|
module MicrosoftComputerVision::Api
|
2
4
|
class Thumbnail
|
3
5
|
|
@@ -18,9 +20,9 @@ module MicrosoftComputerVision::Api
|
|
18
20
|
|
19
21
|
def params
|
20
22
|
data = {}
|
21
|
-
data[:width] = @width
|
22
|
-
data[:height] = @height
|
23
|
-
data[:smartCropping] = @smart_cropping
|
23
|
+
data[:width] = @width unless @width.nil?
|
24
|
+
data[:height] = @height unless @height.nil?
|
25
|
+
data[:smartCropping] = @smart_cropping unless @smart_cropping.nil?
|
24
26
|
|
25
27
|
data
|
26
28
|
end
|
@@ -7,116 +7,58 @@ module MicrosoftComputerVision
|
|
7
7
|
@subscription_key = subscription_key
|
8
8
|
end
|
9
9
|
|
10
|
-
|
11
|
-
# Analyze
|
12
|
-
# Docs: https://dev.projectoxford.ai/docs/services/56f91f2d778daf23d8ec6739/operations/56f91f2e778daf14a499e1fa
|
13
|
-
###############################################################################################################
|
14
|
-
|
15
|
-
def analyze_image_url(image_url, options)
|
10
|
+
def analyze(image_path, options)
|
16
11
|
analyze = Api::Analyze.new(options[:visual_features], options[:details])
|
17
|
-
|
12
|
+
post_image_path(analyze.uri, image_path)
|
18
13
|
end
|
19
14
|
|
20
|
-
def
|
21
|
-
analyze = Api::Analyze.new(options[:visual_features], options[:details])
|
22
|
-
post_image_file(analyze.uri, image_file)
|
23
|
-
end
|
24
|
-
|
25
|
-
###############################################################################################################
|
26
|
-
# Describe
|
27
|
-
# Docs: https://dev.projectoxford.ai/docs/services/56f91f2d778daf23d8ec6739/operations/56f91f2e778daf14a499e1fe
|
28
|
-
###############################################################################################################
|
29
|
-
|
30
|
-
def describe_image_url(image_url, options)
|
15
|
+
def describe(image_path, options)
|
31
16
|
describe = Api::Describe.new(options[:max_candidates])
|
32
|
-
|
33
|
-
end
|
34
|
-
|
35
|
-
def describe_image_file(image_file, options)
|
36
|
-
describe = Api::Describe.new(options[:max_candidates])
|
37
|
-
post_image_file(describe.uri, image_file)
|
38
|
-
end
|
39
|
-
|
40
|
-
###############################################################################################################
|
41
|
-
# Thumbnail
|
42
|
-
# Docs: https://dev.projectoxford.ai/docs/services/56f91f2d778daf23d8ec6739/operations/56f91f2e778daf14a499e1fb
|
43
|
-
###############################################################################################################
|
44
|
-
|
45
|
-
def thumbnail_image_url(image_url, options)
|
46
|
-
thumbnail = Api::Thumbnail.new(options[:width], options[:height], options[:smart_cropping])
|
47
|
-
post_image_url(thumbnail.uri, image_url)
|
17
|
+
post_image_path(describe.uri, image_path)
|
48
18
|
end
|
49
19
|
|
50
|
-
def
|
20
|
+
def thumbnail(image_path, options)
|
51
21
|
thumbnail = Api::Thumbnail.new(options[:width], options[:height], options[:smart_cropping])
|
52
|
-
|
22
|
+
post_image_path(thumbnail.uri, image_path)
|
53
23
|
end
|
54
24
|
|
55
|
-
###############################################################################################################
|
56
|
-
# Domain Models
|
57
|
-
# Docs: https://dev.projectoxford.ai/docs/services/56f91f2d778daf23d8ec6739/operations/56f91f2e778daf14a499e1fd
|
58
|
-
###############################################################################################################
|
59
|
-
|
60
25
|
def domain_models
|
61
26
|
domain_models = Api::DomainModels.new()
|
62
27
|
get(domain_models.uri, {}.to_json)
|
63
28
|
end
|
64
29
|
|
65
|
-
|
66
|
-
# Domain Model
|
67
|
-
# Docs: https://dev.projectoxford.ai/docs/services/56f91f2d778daf23d8ec6739/operations/56f91f2e778daf14a499e200
|
68
|
-
###############################################################################################################
|
69
|
-
|
70
|
-
def domain_model_image_url(image_url, options)
|
30
|
+
def domain_model(image_path, options)
|
71
31
|
domain_model = Api::DomainModel.new(options[:model])
|
72
|
-
|
32
|
+
post_image_path(domain_model.uri, image_path)
|
73
33
|
end
|
74
34
|
|
75
|
-
def
|
76
|
-
domain_model = Api::DomainModel.new(options[:model])
|
77
|
-
post_image_file(domain_model.uri, image_file)
|
78
|
-
end
|
79
|
-
|
80
|
-
###############################################################################################################
|
81
|
-
# OCR
|
82
|
-
# Docs: https://dev.projectoxford.ai/docs/services/56f91f2d778daf23d8ec6739/operations/56f91f2e778daf14a499e1fc
|
83
|
-
###############################################################################################################
|
84
|
-
|
85
|
-
def ocr_image_url(image_url, options)
|
35
|
+
def ocr(image_path, options)
|
86
36
|
ocr = Api::OCR.new(options[:language], options[:detect_orientation])
|
87
|
-
|
37
|
+
post_image_path(ocr.uri, image_path)
|
88
38
|
end
|
89
39
|
|
90
|
-
def
|
91
|
-
ocr = Api::OCR.new(options[:language], options[:detect_orientation])
|
92
|
-
post_image_file(ocr.uri, image_file)
|
93
|
-
end
|
94
|
-
|
95
|
-
###############################################################################################################
|
96
|
-
# Tag
|
97
|
-
# Docs: https://dev.projectoxford.ai/docs/services/56f91f2d778daf23d8ec6739/operations/56f91f2e778daf14a499e1ff
|
98
|
-
###############################################################################################################
|
99
|
-
|
100
|
-
def tag_image_url(image_url)
|
40
|
+
def tag(image_path)
|
101
41
|
tag = Api::Tag.new()
|
102
|
-
|
103
|
-
end
|
104
|
-
|
105
|
-
def tag_image_file(image_file)
|
106
|
-
tag = Api::Tag.new()
|
107
|
-
post_image_file(tag.uri, image_file)
|
42
|
+
post_image_path(tag.uri, image_path)
|
108
43
|
end
|
109
44
|
|
110
45
|
private
|
111
46
|
|
112
|
-
def
|
113
|
-
|
47
|
+
def post_image_path(uri, image_path)
|
48
|
+
image_uri = URI.parse(image_path)
|
114
49
|
|
115
|
-
|
50
|
+
case image_uri
|
51
|
+
when URI::HTTPS, URI::HTTP
|
52
|
+
post_image_url(uri, image_path)
|
53
|
+
else
|
54
|
+
File.open(image_path) do |image_file|
|
55
|
+
post_image_data(uri, image_file.read)
|
56
|
+
end
|
57
|
+
end
|
116
58
|
end
|
117
59
|
|
118
|
-
def
|
119
|
-
post(uri, 'application/octet-stream',
|
60
|
+
def post_image_data(uri, image_data)
|
61
|
+
post(uri, 'application/octet-stream', image_data)
|
120
62
|
end
|
121
63
|
|
122
64
|
def post_image_url(uri, image_url)
|
@@ -130,6 +72,12 @@ module MicrosoftComputerVision
|
|
130
72
|
start(uri, body, request)
|
131
73
|
end
|
132
74
|
|
75
|
+
def get(uri, body)
|
76
|
+
request = Net::HTTP::Get.new(uri.request_uri)
|
77
|
+
|
78
|
+
start(uri, body, request)
|
79
|
+
end
|
80
|
+
|
133
81
|
def start(uri, body, request)
|
134
82
|
request['Ocp-Apim-Subscription-Key'] = @subscription_key
|
135
83
|
request.body = body
|
@@ -0,0 +1,133 @@
|
|
1
|
+
module MicrosoftComputerVision
|
2
|
+
class CommandBuilder
|
3
|
+
include Commander::Methods
|
4
|
+
|
5
|
+
def get_subscription_key(options)
|
6
|
+
key = options.subscription_key || ENV['SUBSCRIPTION_KEY']
|
7
|
+
if key.nil?
|
8
|
+
puts 'Please input your Subscription Key (--subscription_key or SUBSCRIPTION_KEY env)'
|
9
|
+
exit
|
10
|
+
end
|
11
|
+
|
12
|
+
key
|
13
|
+
end
|
14
|
+
|
15
|
+
def run
|
16
|
+
program :name, 'mscv'
|
17
|
+
program :version, MicrosoftComputerVision::VERSION
|
18
|
+
program :description, 'Microsoft Computer Vision API for cli'
|
19
|
+
|
20
|
+
command 'analyze' do |c|
|
21
|
+
c.syntax = 'mscv analyze /path/to/image'
|
22
|
+
c.description = 'Microsoft Computer Vision API Analyze'
|
23
|
+
c.option '--subscription_key STRING', String, 'Microsoft Computer Vision API Subscription Key'
|
24
|
+
c.option '--visual_features STRING', String, 'visualFeatures param'
|
25
|
+
c.option '--details STRING', String, 'details param'
|
26
|
+
c.action do |args, options|
|
27
|
+
result = MicrosoftComputerVision::Client.new(get_subscription_key(options)).analyze(args.first, {
|
28
|
+
visual_features: options.visual_features,
|
29
|
+
details: options.details
|
30
|
+
})
|
31
|
+
|
32
|
+
puts result.body
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
command 'describe' do |c|
|
37
|
+
c.syntax = 'mscv describe /path/to/image'
|
38
|
+
c.description = 'Microsoft Computer Vision API Describe'
|
39
|
+
c.option '--subscription_key STRING', String, 'Microsoft Computer Vision API Subscription Key'
|
40
|
+
c.option '--max_candidates STRING', String, 'maxCandidates param'
|
41
|
+
c.action do |args, options|
|
42
|
+
result = MicrosoftComputerVision::Client.new(get_subscription_key(options)).describe(args.first, {
|
43
|
+
max_candidates: options.max_candidates
|
44
|
+
})
|
45
|
+
|
46
|
+
puts result.body
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
command 'thumbnail' do |c|
|
51
|
+
c.syntax = 'mscv thumbnail /path/to/image'
|
52
|
+
c.description = 'Microsoft Computer Vision API Get Thumbnail'
|
53
|
+
c.option '--subscription_key STRING', String, 'Microsoft Computer Vision API Subscription Key'
|
54
|
+
c.option '--output STRING', String, 'Output thumbnail path'
|
55
|
+
c.option '--width INTEGER', Integer, 'width param'
|
56
|
+
c.option '--height INTEGER', Integer, 'height param'
|
57
|
+
c.option '--smart_cropping BOOLEAN', 'smartCropping param'
|
58
|
+
c.action do |args, options|
|
59
|
+
options.default smart_cropping: true, output: './out.jpg'
|
60
|
+
|
61
|
+
if options.width.nil? || options.height.nil?
|
62
|
+
puts 'Please input width and height(--width, --height)'
|
63
|
+
exit
|
64
|
+
end
|
65
|
+
|
66
|
+
result = MicrosoftComputerVision::Client.new(get_subscription_key(options)).thumbnail(args.first, {
|
67
|
+
width: options.width,
|
68
|
+
height: options.height,
|
69
|
+
smart_cropping: options.smart_cropping
|
70
|
+
})
|
71
|
+
|
72
|
+
File.write options.output, result.body
|
73
|
+
puts "Created #{options.output}"
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
command 'ocr' do |c|
|
78
|
+
c.syntax = 'mscv ocr /path/to/image'
|
79
|
+
c.description = 'Microsoft Computer Vision API OCR'
|
80
|
+
c.option '--subscription_key STRING', String, 'Microsoft Computer Vision API Subscription Key'
|
81
|
+
c.option '--language STRING', String, 'language param'
|
82
|
+
c.option '--detect_orientation', 'detectOrientation param'
|
83
|
+
c.action do |args, options|
|
84
|
+
options.default detect_orientation: true
|
85
|
+
result = MicrosoftComputerVision::Client.new(get_subscription_key(options)).ocr(args.first, {
|
86
|
+
language: options.language,
|
87
|
+
detect_orientation: options.detect_orientation
|
88
|
+
})
|
89
|
+
|
90
|
+
puts result.body
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
command 'model' do |c|
|
95
|
+
c.syntax = 'mscv model /path/to/image'
|
96
|
+
c.description = 'Microsoft Computer Vision API Domain Model'
|
97
|
+
c.option '--subscription_key STRING', String, 'Microsoft Computer Vision API Subscription Key'
|
98
|
+
c.option '--model STRING', String, 'model param'
|
99
|
+
c.action do |args, options|
|
100
|
+
result = MicrosoftComputerVision::Client.new(get_subscription_key(options)).domain_model(args.first, {
|
101
|
+
model: options.model
|
102
|
+
})
|
103
|
+
|
104
|
+
puts result.body
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
command 'tag' do |c|
|
109
|
+
c.syntax = 'mscv tag /path/to/image'
|
110
|
+
c.description = 'Microsoft Computer Vision API Tag'
|
111
|
+
c.option '--subscription_key STRING', String, 'Microsoft Computer Vision API Subscription Key'
|
112
|
+
c.action do |args, options|
|
113
|
+
result = MicrosoftComputerVision::Client.new(get_subscription_key(options)).tag(args.first)
|
114
|
+
|
115
|
+
puts result.body
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
command 'models' do |c|
|
120
|
+
c.syntax = 'mscv models'
|
121
|
+
c.description = 'Microsoft Computer Vision API Domain Models'
|
122
|
+
c.option '--subscription_key STRING', String, 'Microsoft Computer Vision API Subscription Key'
|
123
|
+
c.action do |args, options|
|
124
|
+
result = MicrosoftComputerVision::Client.new(get_subscription_key(options)).domain_models
|
125
|
+
|
126
|
+
puts result.body
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
run!
|
131
|
+
end
|
132
|
+
end
|
133
|
+
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'uri'
|
2
2
|
require 'net/http'
|
3
3
|
require 'json'
|
4
|
+
require 'commander'
|
4
5
|
|
5
6
|
module MicrosoftComputerVision
|
6
7
|
end
|
@@ -14,3 +15,4 @@ require 'microsoft_computer_vision/api/domain_model'
|
|
14
15
|
require 'microsoft_computer_vision/api/domain_models'
|
15
16
|
require 'microsoft_computer_vision/api/ocr'
|
16
17
|
require 'microsoft_computer_vision/api/tag'
|
18
|
+
require 'microsoft_computer_vision/command_builder'
|
@@ -12,12 +12,17 @@ Gem::Specification.new do |spec|
|
|
12
12
|
spec.summary = 'This is a very basic wrapper for the Microsoft Computer Vision API.'
|
13
13
|
spec.description = 'This is a very basic wrapper for the Microsoft Computer Vision API.'
|
14
14
|
spec.homepage = 'https://github.com/henteko/microsoft_computer_vision'
|
15
|
+
spec.license = 'MIT'
|
15
16
|
|
16
17
|
spec.files = `git ls-files`.split($/).reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
-
spec.bindir = '
|
18
|
-
spec.executables = spec.files.grep(%r{^
|
18
|
+
spec.bindir = 'bin'
|
19
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
19
20
|
spec.require_paths = ['lib']
|
20
21
|
|
22
|
+
spec.add_dependency 'commander', '~> 4.4.0'
|
23
|
+
|
21
24
|
spec.add_development_dependency 'bundler', '~> 1.10'
|
22
25
|
spec.add_development_dependency 'rake', '~> 10.0'
|
26
|
+
spec.add_development_dependency 'rspec', '~> 3.4.0'
|
27
|
+
spec.add_development_dependency 'webmock', '~> 2.1.0'
|
23
28
|
end
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: microsoft_computer_vision
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- henteko
|
8
8
|
autorequire:
|
9
|
-
bindir:
|
9
|
+
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-08-
|
11
|
+
date: 2016-08-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: commander
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 4.4.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 4.4.0
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: bundler
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -38,20 +52,49 @@ dependencies:
|
|
38
52
|
- - "~>"
|
39
53
|
- !ruby/object:Gem::Version
|
40
54
|
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 3.4.0
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 3.4.0
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: webmock
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 2.1.0
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 2.1.0
|
41
83
|
description: This is a very basic wrapper for the Microsoft Computer Vision API.
|
42
84
|
email:
|
43
85
|
- henteko07@gmail.com
|
44
|
-
executables:
|
86
|
+
executables:
|
87
|
+
- mscv
|
45
88
|
extensions: []
|
46
89
|
extra_rdoc_files: []
|
47
90
|
files:
|
48
91
|
- ".gitignore"
|
92
|
+
- ".rspec"
|
49
93
|
- ".travis.yml"
|
50
94
|
- Gemfile
|
51
95
|
- README.md
|
52
96
|
- Rakefile
|
53
|
-
- bin/
|
54
|
-
- bin/setup
|
97
|
+
- bin/mscv
|
55
98
|
- example/all.rb
|
56
99
|
- example/test.jpg
|
57
100
|
- lib/microsoft_computer_vision.rb
|
@@ -63,10 +106,12 @@ files:
|
|
63
106
|
- lib/microsoft_computer_vision/api/tag.rb
|
64
107
|
- lib/microsoft_computer_vision/api/thumbnail.rb
|
65
108
|
- lib/microsoft_computer_vision/client.rb
|
109
|
+
- lib/microsoft_computer_vision/command_builder.rb
|
66
110
|
- lib/microsoft_computer_vision/version.rb
|
67
111
|
- microsoft_computer_vision.gemspec
|
68
112
|
homepage: https://github.com/henteko/microsoft_computer_vision
|
69
|
-
licenses:
|
113
|
+
licenses:
|
114
|
+
- MIT
|
70
115
|
metadata: {}
|
71
116
|
post_install_message:
|
72
117
|
rdoc_options: []
|
data/bin/console
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require 'bundler/setup'
|
4
|
-
require 'microsoft_computer_vision'
|
5
|
-
|
6
|
-
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
-
# with your gem easier. You can also use a different console, if you like.
|
8
|
-
|
9
|
-
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
-
# require 'pry'
|
11
|
-
# Pry.start
|
12
|
-
|
13
|
-
require 'irb'
|
14
|
-
IRB.start
|