Class: Kairos::Client
- Inherits:
-
Object
- Object
- Kairos::Client
- Defined in:
- lib/kairos/client.rb
Instance Method Summary collapse
-
#detect(options = {}) ⇒ Object
Detect faces in Image.
-
#enroll(options = {}) ⇒ Object
Enroll an Image.
-
#gallery_list_all ⇒ Object
List all Galleries.
-
#gallery_remove_subject(options = {}) ⇒ Object
Remove Subject from Gallery.
-
#gallery_view(options = {}) ⇒ Object
View subjects in Gallery.
-
#initialize(options = {}) ⇒ Client
constructor
A new instance of Client.
-
#recognize(options = {}) ⇒ Object
Recognize an Image.
Constructor Details
#initialize(options = {}) ⇒ Client
Returns a new instance of Client.
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/kairos/client.rb', line 10 def initialize(={}) # Merge the config values from the module and those passed # to the client. = Kairos..merge() # Copy the merged values to this client and ignore those # not part of our configuration Configuration::VALID_CONFIG_KEYS.each do |key| send("#{key}=", [key]) end end |
Instance Method Details
#detect(options = {}) ⇒ Object
Detect faces in Image
Example Usage:
- require 'kairos'
- client = Kairos::Client.new(:app_id => '1234', :app_key => 'abcde1234')
- client.detect(:url => 'https://some.url.com/to_some_other_image.jpg', :selector => 'FULL')
58 59 60 |
# File 'lib/kairos/client.rb', line 58 def detect(={}) post_to_api(Kairos::Configuration::DETECT, ) end |
#enroll(options = {}) ⇒ Object
Enroll an Image
Example Usage:
- require 'kairos'
- client = Kairos::Client.new(:app_id => '1234', :app_key => 'abcde1234')
- client.enroll(:url => 'https://some.url.com/to_some.jpg', :subject_id => 'gemtest', :gallery_name => 'testgallery')
28 29 30 |
# File 'lib/kairos/client.rb', line 28 def enroll(={}) post_to_api(Kairos::Configuration::ENROLL, ) end |
#gallery_list_all ⇒ Object
List all Galleries
Example Usage:
- require 'kairos'
- client = Kairos::Client.new(:app_id => '1234', :app_key => 'abcde1234')
- client.gallery_list_all
68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/kairos/client.rb', line 68 def gallery_list_all # ToDo: Research why Typhoeus works better than Faraday for this endpoint request = Typhoeus::Request.new( "#{Kairos::Configuration::GALLERY_LIST_ALL}", method: :post, headers: { "Content-Type" => "application/x-www-form-urlencoded", "app_id" => "#{@app_id}", "app_key" => "#{@app_key}" } ) response = request.run JSON.parse(response.body) rescue "INVALID_JSON: #{response.body}" end |
#gallery_remove_subject(options = {}) ⇒ Object
Remove Subject from Gallery
Example Usage:
- require 'kairos'
- client = Kairos::Client.new(:app_id => '1234', :app_key => 'abcde1234')
- client.gallery_remove_subject(:gallery_name => 'testgallery', :subject_id => 'gemtest')
48 49 50 |
# File 'lib/kairos/client.rb', line 48 def gallery_remove_subject(={}) post_to_api(Kairos::Configuration::GALLERY_REMOVE_SUBJECT, ) end |
#gallery_view(options = {}) ⇒ Object
View subjects in Gallery
Example Usage:
- require 'kairos'
- client = Kairos::Client.new(:app_id => '1234', :app_key => 'abcde1234')
- client.gallery_view(:gallery_name => 'testgallery')
87 88 89 |
# File 'lib/kairos/client.rb', line 87 def gallery_view(={}) post_to_api(Kairos::Configuration::GALLERY_VIEW, ) end |
#recognize(options = {}) ⇒ Object
Recognize an Image
Example Usage:
- require 'kairos'
- client = Kairos::Client.new(:app_id => '1234', :app_key => 'abcde1234')
- client.recognize(:url => 'https://some.url.com/to_some_other_image.jpg', :gallery_name => 'testgallery', :threshold => '.2', :max_num_results => '5')
38 39 40 |
# File 'lib/kairos/client.rb', line 38 def recognize(={}) post_to_api(Kairos::Configuration::RECOGNIZE, ) end |