Class: KairosRB::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/kairos_rb/client.rb

Instance Method Summary collapse

Constructor Details

#initialize(app_id:, app_key:) ⇒ Client

Returns a new instance of Client.



7
8
9
10
11
12
# File 'lib/kairos_rb/client.rb', line 7

def initialize(app_id:, app_key:)
  @connection = KairosRB::Connection.new(
    app_id: app_id,
    app_key: app_key
  )
end

Instance Method Details

#add_media(media:, landmarks: 1, timeout: 10) ⇒ Object



117
118
119
120
121
122
123
# File 'lib/kairos_rb/client.rb', line 117

def add_media(media:, landmarks: 1, timeout: 10)
  @connection.call(
    method: 'post',
    url: "/v2/media?source=#{media}&landmarks=#{landmarks}&timeout=#{timeout}",
    headers: { 'Content-Type' => 'application/x-www-form-urlencoded' }
  )
end

#all_galeriesObject



65
66
67
68
69
70
71
# File 'lib/kairos_rb/client.rb', line 65

def all_galeries
  @connection.call(
    method: 'post',
    url: '/gallery/list_all',
    headers: { 'Content-Type' => 'application/json' }
  )
end

#detect(image:, selector: nil, min_head_scale: nil) ⇒ Object



54
55
56
57
58
59
60
61
62
63
# File 'lib/kairos_rb/client.rb', line 54

def detect(image:, selector: nil, min_head_scale: nil)
  body = { 'image' => image, 'selector' => selector, 'MinHeadScale' => min_head_scale }

  @connection.call(
    method: 'post',
    url: '/detect',
    body: body.to_json,
    headers: { 'Content-Type' => 'application/json' }
  )
end

#enroll(image:, gallery_name:, subject_id:, selector: nil) ⇒ Object



14
15
16
17
18
19
20
21
22
23
# File 'lib/kairos_rb/client.rb', line 14

def enroll(image:, gallery_name:, subject_id:, selector: nil)
  body = { gallery_name: gallery_name, image: image, subject_id: subject_id, selector: selector }

  @connection.call(
    method: 'post',
    url: '/enroll',
    body: body.to_json,
    headers: { 'Content-Type' => 'application/json' }
  )
end


73
74
75
76
77
78
79
80
81
82
# File 'lib/kairos_rb/client.rb', line 73

def gallery_details(gallery_name:)
  body = { gallery_name: gallery_name }

  @connection.call(
    method: 'post',
    url: '/gallery/view',
    body: body.to_json,
    headers: { 'Content-Type' => 'application/json' }
  )
end


84
85
86
87
88
89
90
91
92
93
# File 'lib/kairos_rb/client.rb', line 84

def gallery_subject(gallery_name:, subject_id:)
  body = { gallery_name: gallery_name, subject_id: subject_id }

  @connection.call(
    method: 'post',
    url: '/gallery/view_subject',
    body: body.to_json,
    headers: { 'Content-Type' => 'application/json' }
  )
end

#get_media(media_id:) ⇒ Object



125
126
127
128
129
130
131
# File 'lib/kairos_rb/client.rb', line 125

def get_media(media_id:)
  @connection.call(
    method: 'get',
    url: "/v2/media/#{media_id}",
    headers: { 'Content-Type' => 'application/x-www-form-urlencoded' }
  )
end

#media_analytics(media_id:) ⇒ Object



133
134
135
136
137
138
139
# File 'lib/kairos_rb/client.rb', line 133

def media_analytics(media_id:)
  @connection.call(
    method: 'get',
    url: "/v2/analytics/#{media_id}",
    headers: { 'Content-Type' => 'application/x-www-form-urlencoded' }
  )
end

#recognize(image:, gallery_name:, selector: nil, min_head_scale: nil, threshold: nil, max_num_results: nil) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/kairos_rb/client.rb', line 36

def recognize(image:, gallery_name:, selector: nil, min_head_scale: nil, threshold: nil, max_num_results: nil)
  body = {
    'image' => image,
    'gallery_name' => gallery_name,
    'selector' => selector,
    'MinHeadScale' => min_head_scale,
    'threshold' => threshold,
    'max_num_results' => max_num_results
  }

  @connection.call(
    method: 'post',
    url: '/recognize',
    body: body.to_json,
    headers: { 'Content-Type' => 'application/json' }
  )
end


106
107
108
109
110
111
112
113
114
115
# File 'lib/kairos_rb/client.rb', line 106

def remove_gallery(gallery_name:)
  body = { gallery_name: gallery_name }

  @connection.call(
    method: 'post',
    url: '/gallery/remove',
    body: body.to_json,
    headers: { 'Content-Type' => 'application/json' }
  )
end

#remove_media(media_id:) ⇒ Object



141
142
143
144
145
146
147
# File 'lib/kairos_rb/client.rb', line 141

def remove_media(media_id:)
  @connection.call(
    method: 'delete',
    url: "/v2/media/#{media_id}",
    headers: { 'Content-Type' => 'application/json' }
  )
end


95
96
97
98
99
100
101
102
103
104
# File 'lib/kairos_rb/client.rb', line 95

def remove_subject_from_gallery(gallery_name:, subject_id:)
  body = { gallery_name: gallery_name, subject_id: subject_id }

  @connection.call(
    method: 'post',
    url: '/gallery/remove_subject',
    body: body.to_json,
    headers: { 'Content-Type' => 'application/json' }
  )
end

#verify(image:, gallery_name:, subject_id:, selector: nil) ⇒ Object



25
26
27
28
29
30
31
32
33
34
# File 'lib/kairos_rb/client.rb', line 25

def verify(image:, gallery_name:, subject_id:, selector: nil)
  body = { gallery_name: gallery_name, image: image, subject_id: subject_id, selector: selector }

  @connection.call(
    method: 'post',
    url: '/verify',
    body: body.to_json,
    headers: { 'Content-Type' => 'application/json' }
  )
end