kairos 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +14 -0
- data/LICENSE +22 -0
- data/README.rdoc +19 -0
- data/Rakefile +2 -0
- data/kairos.gemspec +27 -0
- data/lib/ext/hash.rb +16 -0
- data/lib/ext/object.rb +12 -0
- data/lib/kairos/client/accounts.rb +22 -0
- data/lib/kairos/client/base.rb +45 -0
- data/lib/kairos/client/recognition.rb +12 -0
- data/lib/kairos/client/tags.rb +21 -0
- data/lib/kairos/client/utils.rb +71 -0
- data/lib/kairos/client.rb +8 -0
- data/lib/kairos/version.rb +3 -0
- data/lib/kairos.rb +13 -0
- metadata +88 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a6e1c1bc804295ff56e78bb380de870f4d2cc3ef
|
4
|
+
data.tar.gz: 7a2a142abdf523200013c66e5ad0c8e8f391402a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 53093911e74f8743a076aab54732c72737ab733d9b05c1dffd381a97b9f7520b7bffcd1ea9ab57323b2759b1fac63e2bc58173424b22b52d503e7caf854c8036
|
7
|
+
data.tar.gz: 29c881ba915ae7c51c1c9eb2d9735d76dda09c3666d07d5f348e68fb774458c288f9324c4deb12ab864fcec0b29429a9911f15f124d2c3a7fba5e1e9e8c3a0b6
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
(The MIT License)
|
2
|
+
|
3
|
+
Copyright (c) 2010 {rociiu (Roc Yu)}[http://rociiu.com]
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Note: This gem is still under development, create issues if you meet any problem when using it https://github.com/chrisallick/kairos/issues
|
2
|
+
|
3
|
+
Kairos is a ruby library of Kairos Face Detection and Recognition API.
|
4
|
+
|
5
|
+
It is completely ripped off from https://github.com/rociiu/face by http://rociiu.com/
|
6
|
+
|
7
|
+
== Getting Started
|
8
|
+
gem install kairos
|
9
|
+
|
10
|
+
irb
|
11
|
+
>> require 'kairos'
|
12
|
+
>> client = Kairos.get_client(:app_id => 'your_api_app_id', :app_key => 'your_api_app_key')
|
13
|
+
|
14
|
+
Detect Faces with Urls:
|
15
|
+
|
16
|
+
# returns a Hash not a raw JSON string
|
17
|
+
>> puts client.detect(:urls => ['http://img3.wikia.nocookie.net/__cb20120804165550/assassinscreed/images/e/ed/New_engine_face_model_test_by_Michel_Thibault.png'])
|
18
|
+
|
19
|
+
Author: Chris Allick (chrisallick@gmail.com)
|
data/Rakefile
ADDED
data/kairos.gemspec
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "kairos/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "kairos"
|
7
|
+
s.version = Kairos::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Chris Allick"]
|
10
|
+
s.email = ["chrisallick@gmail.com"]
|
11
|
+
s.homepage = "http://rubygems.org/gems/kairos"
|
12
|
+
s.summary = %q{Ruby wraper of Kairos Face Detection and Recognition API}
|
13
|
+
s.description = %q{}
|
14
|
+
|
15
|
+
s.rubyforge_project = "kairos"
|
16
|
+
|
17
|
+
s.files = `git ls-files`.split("\n")
|
18
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
19
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
|
+
s.require_paths = ["lib"]
|
21
|
+
|
22
|
+
s.add_dependency "rest-client", ">=1.6.1"
|
23
|
+
s.add_dependency "json", ">=1.4.6"
|
24
|
+
|
25
|
+
s.licenses = 'MIT'
|
26
|
+
|
27
|
+
end
|
data/lib/ext/hash.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
require File.expand_path('../object', __FILE__)
|
2
|
+
|
3
|
+
class Hash
|
4
|
+
|
5
|
+
def assert_valid_keys(*valid_keys)
|
6
|
+
unknown_keys = keys - [valid_keys].flatten
|
7
|
+
raise(ArgumentError, "Unknown key(s): #{unknown_keys.join(", ")}") unless unknown_keys.empty?
|
8
|
+
end
|
9
|
+
|
10
|
+
def to_param(namespace = nil)
|
11
|
+
collect do |key, value|
|
12
|
+
value.to_query(namespace ? "#{namespace}[#{key}]" : key)
|
13
|
+
end.sort * '&'
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
data/lib/ext/object.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
module Kairos
|
2
|
+
module Client
|
3
|
+
module Accounts
|
4
|
+
def account_limits(opts={})
|
5
|
+
make_request(:account_limits, opts.merge(user_auth_param))
|
6
|
+
end
|
7
|
+
|
8
|
+
def account_users(opts={})
|
9
|
+
make_request(:account_users, opts.merge(user_auth_param))
|
10
|
+
end
|
11
|
+
|
12
|
+
def account_namespaces(opts={})
|
13
|
+
make_request(:account_namespaces, opts.merge(user_auth_param))
|
14
|
+
end
|
15
|
+
|
16
|
+
def account_authenticate(opts={})
|
17
|
+
make_request(:account_authenticate, opts.merge(user_auth_param))
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require File.expand_path('../utils', __FILE__)
|
2
|
+
require File.expand_path('../recognition', __FILE__)
|
3
|
+
#require File.expand_path('../tags', __FILE__)
|
4
|
+
#require File.expand_path('../accounts', __FILE__)
|
5
|
+
|
6
|
+
module Kairos
|
7
|
+
module Client
|
8
|
+
class Base
|
9
|
+
|
10
|
+
attr_accessor :app_id, :app_key
|
11
|
+
|
12
|
+
# #{
|
13
|
+
# # twitter_username => [twitter screen name]
|
14
|
+
# # twitter_password => [twitter password]
|
15
|
+
# #}
|
16
|
+
# attr_accessor :twitter_credentials
|
17
|
+
|
18
|
+
# #{
|
19
|
+
# # twitter_oauth_user => [twitter OAuth user]
|
20
|
+
# # twitter_oauth_secret => [twitter OAuth secret]
|
21
|
+
# # twitter_oauth_token => [twitter OAuth token]
|
22
|
+
# #}
|
23
|
+
# attr_accessor :twitter_oauth_credentials
|
24
|
+
|
25
|
+
# #{
|
26
|
+
# # fb_user => [facebook user id]
|
27
|
+
# # fb_session => [facebook session id]
|
28
|
+
# # fb_oauth_token => [facebook oauth 2.0 access token]
|
29
|
+
# #}
|
30
|
+
# attr_accessor :facebook_credentials
|
31
|
+
|
32
|
+
include Kairos::Client::Utils
|
33
|
+
include Kairos::Client::Recognition
|
34
|
+
# include Kairos::Client::Tags
|
35
|
+
# include Kairos::Client::Accounts
|
36
|
+
|
37
|
+
|
38
|
+
def initialize(opts={})
|
39
|
+
opts.assert_valid_keys(:app_id, :app_key)
|
40
|
+
@app_id, @app_key = opts[:app_id], opts[:app_key]
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Kairos
|
2
|
+
module Client
|
3
|
+
module Tags
|
4
|
+
def tags_get(opts={})
|
5
|
+
make_request(:tags_get, opts.merge(user_auth_param))
|
6
|
+
end
|
7
|
+
|
8
|
+
def tags_add(opts={})
|
9
|
+
make_request(:tags_add, opts.merge(user_auth_param))
|
10
|
+
end
|
11
|
+
|
12
|
+
def tags_save(opts={})
|
13
|
+
make_request(:tags_save, opts.merge(user_auth_param))
|
14
|
+
end
|
15
|
+
|
16
|
+
def tags_remove(opts={})
|
17
|
+
make_request(:tags_remove, opts.merge(user_auth_param))
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
module Kairos
|
2
|
+
module Client
|
3
|
+
module Utils
|
4
|
+
|
5
|
+
class FaceError < StandardError; end
|
6
|
+
|
7
|
+
API_METHODS = {
|
8
|
+
:detect => 'http://api.kairos.io/detect',
|
9
|
+
}
|
10
|
+
|
11
|
+
def api_crendential
|
12
|
+
{ :app_id => app_id, :app_key => app_key }
|
13
|
+
end
|
14
|
+
|
15
|
+
def make_request(api_method, opts={})
|
16
|
+
# if opts[:url].is_a? Array
|
17
|
+
# opts[:url] = opts[:url].join(',')
|
18
|
+
# end
|
19
|
+
|
20
|
+
# if opts[:uids].is_a? Array
|
21
|
+
# opts[:uids] = opts[:uids].join(',')
|
22
|
+
# end
|
23
|
+
|
24
|
+
# if opts[:tids].is_a? Array
|
25
|
+
# opts[:tids] = opts[:tids].join(',')
|
26
|
+
# end
|
27
|
+
|
28
|
+
# if opts[:pids].is_a? Array
|
29
|
+
# opts[:pids] = opts[:pids].join(',')
|
30
|
+
# end
|
31
|
+
|
32
|
+
# response = JSON.parse( RestClient.post(API_METHODS[ api_method ], opts.merge(api_crendential)).body )
|
33
|
+
response = JSON.parse( RestClient::Request.execute(
|
34
|
+
:method => :post,
|
35
|
+
:url => API_METHODS[ api_method ],
|
36
|
+
:headers => {
|
37
|
+
"app_id" => app_id,
|
38
|
+
"app_key" => app_key
|
39
|
+
},
|
40
|
+
:payload => opts.to_json
|
41
|
+
))
|
42
|
+
|
43
|
+
# if %w/success partial/.include?(response['status'])
|
44
|
+
return response
|
45
|
+
# elsif response['status'] == 'failure'
|
46
|
+
# raise FaceError.new("Error: #{response['error_code']}, #{response['error_message']}")
|
47
|
+
# end
|
48
|
+
end
|
49
|
+
|
50
|
+
def user_auth_param
|
51
|
+
user_auth_value = []
|
52
|
+
# if twitter_credentials
|
53
|
+
# twitter_credentials.each do |k, v|
|
54
|
+
# user_auth_value << "#{k}:#{v}"
|
55
|
+
# end
|
56
|
+
# elsif twitter_oauth_credentials
|
57
|
+
# twitter_oauth_credentials.each do |k,v|
|
58
|
+
# user_auth_value << "#{k}:#{v}"
|
59
|
+
# end
|
60
|
+
# end
|
61
|
+
# if facebook_credentials
|
62
|
+
# facebook_credentials.each do |k, v|
|
63
|
+
# user_auth_value << "#{k}:#{v}"
|
64
|
+
# end
|
65
|
+
# end
|
66
|
+
user_auth_value.size > 0 ? { :user_auth => user_auth_value.join(',') } : {}
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
data/lib/kairos.rb
ADDED
metadata
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: kairos
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.6
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Chris Allick
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-07-10 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rest-client
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.6.1
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.6.1
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: json
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.4.6
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.4.6
|
41
|
+
description: ''
|
42
|
+
email:
|
43
|
+
- chrisallick@gmail.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- Gemfile
|
49
|
+
- Gemfile.lock
|
50
|
+
- LICENSE
|
51
|
+
- README.rdoc
|
52
|
+
- Rakefile
|
53
|
+
- kairos.gemspec
|
54
|
+
- lib/ext/hash.rb
|
55
|
+
- lib/ext/object.rb
|
56
|
+
- lib/kairos.rb
|
57
|
+
- lib/kairos/client.rb
|
58
|
+
- lib/kairos/client/accounts.rb
|
59
|
+
- lib/kairos/client/base.rb
|
60
|
+
- lib/kairos/client/recognition.rb
|
61
|
+
- lib/kairos/client/tags.rb
|
62
|
+
- lib/kairos/client/utils.rb
|
63
|
+
- lib/kairos/version.rb
|
64
|
+
homepage: http://rubygems.org/gems/kairos
|
65
|
+
licenses:
|
66
|
+
- MIT
|
67
|
+
metadata: {}
|
68
|
+
post_install_message:
|
69
|
+
rdoc_options: []
|
70
|
+
require_paths:
|
71
|
+
- lib
|
72
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - '>='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - '>='
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
82
|
+
requirements: []
|
83
|
+
rubyforge_project: kairos
|
84
|
+
rubygems_version: 2.2.2
|
85
|
+
signing_key:
|
86
|
+
specification_version: 4
|
87
|
+
summary: Ruby wraper of Kairos Face Detection and Recognition API
|
88
|
+
test_files: []
|