face_rekord2018 0.1.0
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
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/face_rekord2018.rb +81 -0
- metadata +91 -0
- metadata.gz.sig +0 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 62d2a08daf5ff8818f88341903635498bc6b10140344436233efced7155c7e2c
|
4
|
+
data.tar.gz: b5b88d787491ae2e7d6a7125c2ff887becbbc4596e6fc77082ff6213200ef074
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0442f02126a414c43211afc967fedf15fa578a67b94a07d4159f82e4da3c99d2e70dc4a23e972768a85e165777b3b6498fd597c130884baad3e9914afa4d7caa
|
7
|
+
data.tar.gz: 98d4f3df182f52e1ac327b612840724ae651ecd91a2a29af4bc40e0e84ee1a34396a0e2e6bfdccd01b7d3a4baedc4bfe7aba5af6d0020b4f948f892a0f6e138e
|
checksums.yaml.gz.sig
ADDED
Binary file
|
data.tar.gz.sig
ADDED
Binary file
|
@@ -0,0 +1,81 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# file: face_rekord2018.rb
|
4
|
+
|
5
|
+
|
6
|
+
require 'aws-sdk'
|
7
|
+
|
8
|
+
# description: A wrapper of the Aws::Rekognition gem.
|
9
|
+
|
10
|
+
|
11
|
+
class FaceRekord2018
|
12
|
+
|
13
|
+
attr_reader :collections
|
14
|
+
|
15
|
+
|
16
|
+
def initialize(access_key: '', secret_key: '', region: 'us-east-1',
|
17
|
+
collection: 'default', debug: false, match_threshold: 95)
|
18
|
+
|
19
|
+
@collection, @debug, @threshold = collection, debug, match_threshold
|
20
|
+
|
21
|
+
@face = Aws::Rekognition::Client.new(region: region,
|
22
|
+
credentials: Aws::Credentials.new(access_key, secret_key))
|
23
|
+
|
24
|
+
# create the collection if it doesn't already exist
|
25
|
+
#
|
26
|
+
@collections = @face.list_collections({}).collection_ids
|
27
|
+
|
28
|
+
if !(@collections.include? collection) then
|
29
|
+
puts 'creating a new collection' if @debug
|
30
|
+
response = @face.create_collection({ collection_id: collection })
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
def delete_collection(id)
|
36
|
+
|
37
|
+
if (@collections.include? id)
|
38
|
+
response = @face.delete_collection({ collection_id: id })
|
39
|
+
else
|
40
|
+
'unknown collection'
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
def recognise(filename)
|
46
|
+
|
47
|
+
response = @face.search_faces_by_image({
|
48
|
+
collection_id: @collection,
|
49
|
+
max_faces: 1,
|
50
|
+
face_match_threshold: @threshold,
|
51
|
+
image: {
|
52
|
+
bytes: File.read(filename)
|
53
|
+
}
|
54
|
+
})
|
55
|
+
|
56
|
+
if response.face_matches.count > 1
|
57
|
+
{:message => "Too many faces found"}
|
58
|
+
elsif response.face_matches.count == 0
|
59
|
+
{:message => "No face detected!"}
|
60
|
+
else
|
61
|
+
{:id => response.face_matches[0].face.external_image_id, :confidence => response.face_matches[0].face.confidence, :message => "Face found!"}
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
|
66
|
+
alias reconize recognise
|
67
|
+
alias rekognize recognise
|
68
|
+
|
69
|
+
def store(filename, image_id)
|
70
|
+
|
71
|
+
response = @face.index_faces({
|
72
|
+
collection_id: @collection,
|
73
|
+
external_image_id: image_id,
|
74
|
+
image: {
|
75
|
+
bytes: File.read(filename)
|
76
|
+
}
|
77
|
+
})
|
78
|
+
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
metadata
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: face_rekord2018
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
auth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mQXXKv4tZwcwJgYDVR0RBB8wHYEbZ2VtbWFzdGVyQGphbWVzcm9iZXJ0
|
27
|
+
c29uLmV1MCYGA1UdEgQfMB2BG2dlbW1hc3RlckBqYW1lc3JvYmVydHNvbi5ldTAN
|
28
|
+
BgkqhkiG9w0BAQsFAAOCAYEAMzPb65q0RH6C5qoj+egH4QjjjXA6t7k9ClpkT5px
|
29
|
+
uWu1pGIMilwA/B7cCwqllj6LY1XHYS3LExPEGmZExxMAGotI835/goQewgqLRCZV
|
30
|
+
9QP124SATWPj9CHt77PoBjE3tzqcp1AJ5J7vFeqmMeVfqxZxZ/xw5tAzswCaKhsi
|
31
|
+
K72DNhkFYyrC9Lu626wR/nbX0zJG6qsXF4Zg1h4aeNkYJas5dhXSRm8JZt6TTKth
|
32
|
+
PTsuO7EZk7Y3pjy4YC6k3hWiZGTNJCaFu0sLJF6wKnFzGfVVI9Fj+Fw3tYQFTy1A
|
33
|
+
mYHKfgV8am99Xo/7t6pV5FcYpuUtCvJ65ouCURMzq2zuEY8omwB+HAXDAC0dcsOc
|
34
|
+
/OhRbpA3kCtJkMzh2U4KTtjpmauuTonr3k1pYuVYiQ1XsmyStmIncz7Bzipevmd/
|
35
|
+
oweRwH0nVNBK8W3dw4dAiiJx/LQ8a0zcnPuZ8SLYhXrtADELzMgI9l8J4oxRW2lq
|
36
|
+
Q3Uz1SzBz/4Sr3g8X1k1Eo7P
|
37
|
+
-----END CERTIFICATE-----
|
38
|
+
date: 2018-08-15 00:00:00.000000000 Z
|
39
|
+
dependencies:
|
40
|
+
- !ruby/object:Gem::Dependency
|
41
|
+
name: aws-sdk
|
42
|
+
requirement: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - "~>"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '1.4'
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: 1.4.12
|
50
|
+
type: :runtime
|
51
|
+
prerelease: false
|
52
|
+
version_requirements: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - "~>"
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: '1.4'
|
57
|
+
- - ">="
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: 1.4.12
|
60
|
+
description:
|
61
|
+
email: james@jamesrobertson.eu
|
62
|
+
executables: []
|
63
|
+
extensions: []
|
64
|
+
extra_rdoc_files: []
|
65
|
+
files:
|
66
|
+
- lib/face_rekord2018.rb
|
67
|
+
homepage: https://github.com/jrobertson/face_rekord2018
|
68
|
+
licenses:
|
69
|
+
- MIT
|
70
|
+
metadata: {}
|
71
|
+
post_install_message:
|
72
|
+
rdoc_options: []
|
73
|
+
require_paths:
|
74
|
+
- lib
|
75
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
76
|
+
requirements:
|
77
|
+
- - ">="
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '0'
|
80
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '0'
|
85
|
+
requirements: []
|
86
|
+
rubyforge_project:
|
87
|
+
rubygems_version: 2.7.6
|
88
|
+
signing_key:
|
89
|
+
specification_version: 4
|
90
|
+
summary: A wrapper of the Aws::Rekognition gem.
|
91
|
+
test_files: []
|
metadata.gz.sig
ADDED
Binary file
|