findface 0.0.1
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/.gitignore +10 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +82 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/findface.gemspec +37 -0
- data/lib/findface.rb +60 -0
- data/lib/findface/all.rb +10 -0
- data/lib/findface/api.rb +30 -0
- data/lib/findface/error.rb +33 -0
- data/lib/findface/face.rb +62 -0
- data/lib/findface/gallery.rb +29 -0
- data/lib/findface/utility.rb +57 -0
- data/lib/findface/version.rb +3 -0
- metadata +154 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 403a89b0670a82b62e29dc963f42b747b9c3212e
|
4
|
+
data.tar.gz: b1edbebe77d9c9727d01c26c126822f2ddd4e62b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5d0c41851e2c953075dbe1558c4ab1d6decb5856c9a1e9033a8a3a5d41e8a91c39f7977a704c632029d2e79d82083b40b75e5a510a67952b72470be7fd443d7b
|
7
|
+
data.tar.gz: 188c9508a75ee86f38bd20093e927aba5e46f8d2b0e996432f170d1554f11968c2137fa5b2168070538b5c8603b079adb26828f68a1f3a2371c0d2ed1718727b
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at sandeep@rubyeffect.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 Sam
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
|
2
|
+
# Findface
|
3
|
+
|
4
|
+
By [Rubyeffect](https://www.rubyeffect.com/).
|
5
|
+
|
6
|
+
This is a ruby gem to provide easy implementation of utilities of [FindFace Cloud API](https://findface.pro/en/). The [FindFace Cloud API](https://findface.pro/en/) offers integration with a face detection, verification, and identification platform. This API enables face comparison, and human detection with coordinates and sizes. REST calls are supported with JSON responses and Token-Based HTTP authentication. FindFace is a Cyprus based software development firm.
|
7
|
+
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
Add this line to your application's Gemfile:
|
11
|
+
|
12
|
+
```ruby
|
13
|
+
gem 'findface'
|
14
|
+
```
|
15
|
+
|
16
|
+
And then execute:
|
17
|
+
|
18
|
+
$ bundle
|
19
|
+
|
20
|
+
Or install it yourself as:
|
21
|
+
|
22
|
+
$ gem install findface
|
23
|
+
|
24
|
+
## Usage
|
25
|
+
|
26
|
+
The details on usage of "findface" gem are present at: `http://blog.rubyeffect.com/category/findface/`. If you wish to see Findface's API documentation, please visit the url: `https://findface.pro/en/docs.html`
|
27
|
+
|
28
|
+
1. Add gem to your application’s Gemfile
|
29
|
+
|
30
|
+
gem 'findface'
|
31
|
+
|
32
|
+
2. Set the API key in initializer file by creating it (config/initializers/findface.rb)
|
33
|
+
|
34
|
+
Findface.api_key = 'YOUR-API-KEY'
|
35
|
+
|
36
|
+
3. Start using the gem 🙂
|
37
|
+
|
38
|
+
## Documentation
|
39
|
+
|
40
|
+
1. [Findface Gem Introduction](http://blog.rubyeffect.com/documentation-for-findface-gem/)
|
41
|
+
2. [Findface Face Module Endpoints](http://blog.rubyeffect.com/findface-gem-face-module-endpoints/)
|
42
|
+
3. [Findface Gallery Module Endpoints](http://blog.rubyeffect.com/findface-gem-gallery-module-endpoints/)
|
43
|
+
4. [Findface Utility Module Endpoints](http://blog.rubyeffect.com/findface-gem-utility-module-endpoints/)
|
44
|
+
5. [Findface Gem – Endpoints supporting Paginated results](http://blog.rubyeffect.com/findface-gem-endpoints-supporting-paginated-results/)
|
45
|
+
|
46
|
+
## TODO
|
47
|
+
|
48
|
+
1. Addition of any new endpoints with respect to Findface Cloud API latest changelog.
|
49
|
+
2. Support for ruby versions < 2.2.2 .
|
50
|
+
3. Writing more test cases.
|
51
|
+
|
52
|
+
## Development
|
53
|
+
|
54
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
55
|
+
|
56
|
+
### Running tests
|
57
|
+
|
58
|
+
To the run tests get key from `https://saas.findface.pro/account/dashboard` then run:
|
59
|
+
|
60
|
+
```console
|
61
|
+
$ env FINDFACE_API_KEY='<YOUR-API-KEY>' rspec
|
62
|
+
```
|
63
|
+
|
64
|
+
|
65
|
+
## Contributing
|
66
|
+
|
67
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/findface. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
68
|
+
|
69
|
+
|
70
|
+
## License
|
71
|
+
|
72
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
73
|
+
|
74
|
+
## About RubyEffect
|
75
|
+
|
76
|
+

|
77
|
+
|
78
|
+
RubyEffect builds intuitive, live and elegant software that solves real world problems. We love open source and it's community.
|
79
|
+
|
80
|
+
Liked this gem? You may also like the articles we post on our [blog](http://blog.rubyeffect.com). Please do check
|
81
|
+
|
82
|
+
We would love to work on your ideas and see them grow. Say hello @ http://rubyeffect.com/contact
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "findface"
|
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
|
data/bin/setup
ADDED
data/findface.gemspec
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'findface/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "findface"
|
8
|
+
spec.version = Findface::VERSION
|
9
|
+
spec.authors = ["Sandeep Mallela a.k.a Sam"]
|
10
|
+
spec.email = ["opensource@rubyeffect.com", "sandeep@rubyeffect.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Ruby Gem for Findface API to use it in Ruby on Rails & Sinatra Applications}
|
13
|
+
spec.description = %q{Utility to use FindFace API Face Detection algorithms on media like photos}
|
14
|
+
spec.homepage = "https://github.com/rubyeffect/findface"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
18
|
+
f.match(%r{^(test|spec|features)/})
|
19
|
+
end
|
20
|
+
|
21
|
+
spec.bindir = "exe"
|
22
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
23
|
+
spec.require_paths = ["lib"]
|
24
|
+
|
25
|
+
#Development Dependencies
|
26
|
+
spec.add_development_dependency "bundler", "~> 1.13"
|
27
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
28
|
+
spec.add_development_dependency "rspec", "~> 3.5"
|
29
|
+
|
30
|
+
# Runtime Dependencies
|
31
|
+
spec.add_runtime_dependency 'httparty', '~> 0.14.0'
|
32
|
+
spec.add_runtime_dependency 'json', '~> 2.0', '>= 2.0.2'
|
33
|
+
|
34
|
+
#Documentation
|
35
|
+
spec.add_runtime_dependency 'yard', '~> 0.9.8'
|
36
|
+
|
37
|
+
end
|
data/lib/findface.rb
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
require 'findface/all'
|
2
|
+
|
3
|
+
module Findface
|
4
|
+
class << self
|
5
|
+
# Returns API key or raises exception
|
6
|
+
def api_key
|
7
|
+
defined? @api_key and @api_key or raise "Findface.api_key not configured"
|
8
|
+
end
|
9
|
+
attr_writer :api_key
|
10
|
+
|
11
|
+
# Sets the API endpoint base uri.
|
12
|
+
# For each API request, the request specific element must be added excluding the common part of uri.
|
13
|
+
# An example for entities is: base_uri + 'entities'
|
14
|
+
def base_uri
|
15
|
+
@base_uri = "https://api.findface.pro/v0/"
|
16
|
+
end
|
17
|
+
|
18
|
+
# Returns simple token based authentication hash.
|
19
|
+
# While making a request, merge this hash into options hash of request.
|
20
|
+
# We also need to merge request specific hash with key as body.
|
21
|
+
# The overall format looks as follows:
|
22
|
+
# {:headers => {:Authorization => 'Token YOUR_TOKEN'}}, :body => request_specific_options_hash}
|
23
|
+
def token_auth
|
24
|
+
{
|
25
|
+
:headers => {
|
26
|
+
:Authorization => "Token " + api_key
|
27
|
+
}
|
28
|
+
}
|
29
|
+
end
|
30
|
+
|
31
|
+
#Returns a string replacing a space with '%20'
|
32
|
+
#Findface API do not accept strings with spaces or usage of '+' in the string.
|
33
|
+
def encode_meta_string meta_string
|
34
|
+
return meta_string.gsub(" ", "%20") if meta_string
|
35
|
+
end
|
36
|
+
|
37
|
+
#Gallery name cannot contain spaces.
|
38
|
+
#This methods formats the string by eliminating spaces.
|
39
|
+
def format_gallery_name name_string
|
40
|
+
return name_string.gsub(" ", '') if name_string
|
41
|
+
end
|
42
|
+
|
43
|
+
# Extensible method to manage & serve results considering pagination parameters supported by API.
|
44
|
+
def get_list page_name, pages = nil
|
45
|
+
next_page_url = pages[:next_page].split('?').last if !pages.nil? && !pages[:next_page].nil? && !pages[:next_page] != ''
|
46
|
+
prev_page_url = pages[:prev_page].split('?').last if !pages.nil? && !pages[:prev_page].nil? && !pages[:prev_page] != ''
|
47
|
+
if !next_page_url.nil? && prev_page_url.nil?
|
48
|
+
API::request(:get, page_name + '?' +next_page_url)
|
49
|
+
elsif next_page_url.nil? && !prev_page_url.nil?
|
50
|
+
request_url =
|
51
|
+
API::request(:get, page_name + '?' + prev_page_url)
|
52
|
+
elsif !next_page_url.nil? && !prev_page_url.nil?
|
53
|
+
API::request(:get, page_name + '?' + next_page_url + '&' + prev_page_url)
|
54
|
+
else
|
55
|
+
#Regular request is executed if pages value is not present or contains invalid hash key names other than next_page & pev_page
|
56
|
+
API::request(:get, page_name)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
data/lib/findface/all.rb
ADDED
data/lib/findface/api.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
module Findface
|
2
|
+
class API
|
3
|
+
class << self
|
4
|
+
|
5
|
+
# This is universal method that handles the process of communicating with API end points and returns a response or proper error message.
|
6
|
+
# This is invoked from Endpoint methods by passing required parameters like 'method', 'uri' and 'options' as inputs
|
7
|
+
def request method, uri, options={}
|
8
|
+
options = Findface.token_auth.merge!({:body => options})
|
9
|
+
uri = Findface.base_uri + uri
|
10
|
+
response = HTTParty.send(method, uri, options)
|
11
|
+
if response.body == nil
|
12
|
+
# A delete request simply returns HTTP 204 No Content as a response. Here specific response is created for delete requests to observe successful calls to endpoint
|
13
|
+
# as unsuccessful delete requests always returns reason for request failure.
|
14
|
+
return "Delete request executed successfully."
|
15
|
+
else
|
16
|
+
parsed_response = JSON.parse(response.body)
|
17
|
+
if response.code.to_i == 200
|
18
|
+
# Returns parsed_response - a hash of response body
|
19
|
+
# if response is successful
|
20
|
+
parsed_response
|
21
|
+
else
|
22
|
+
# Raises error if the response is not sucessful
|
23
|
+
raise Findface::Error.new(parsed_response, response.code.to_i)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Findface
|
2
|
+
class Error < StandardError
|
3
|
+
attr_reader :parsed_response
|
4
|
+
|
5
|
+
# Contructor method to take response code and parsed_response.
|
6
|
+
# The method gives a set of object methods in rescue - e.message and e.parsed_response
|
7
|
+
def initialize(parsed_response, code)
|
8
|
+
super(Findface::Error.error_message(code, parsed_response))
|
9
|
+
@parsed_response = parsed_response
|
10
|
+
end
|
11
|
+
|
12
|
+
# Method to return error message based on the response code
|
13
|
+
def self.error_message(code, parsed_response)
|
14
|
+
case code
|
15
|
+
when 400 then
|
16
|
+
"Bad parameters supplied"
|
17
|
+
when 401 then
|
18
|
+
'Wrong authentication token or no token at all is provided.'
|
19
|
+
when 403 then
|
20
|
+
"Not authorized. You don't have permission to take action on a particular resource"
|
21
|
+
when 404 then
|
22
|
+
'Resource was not found'
|
23
|
+
when 422 then
|
24
|
+
"This usually means you are missing or have supplied invalid parameters for a request: #{parsed_response}"
|
25
|
+
when 500 then
|
26
|
+
"Internal server error. Something went wrong. This is a bug. Please report it to support immediately"
|
27
|
+
else
|
28
|
+
'An error occured. Please check parsed_response for details'
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
module Findface
|
2
|
+
class Face
|
3
|
+
class << self
|
4
|
+
|
5
|
+
# Endpoint: https://api.findface.pro/v0/faces/ (GET) |
|
6
|
+
# Usage: FindFace::Face.list
|
7
|
+
# Output: Returns list of faces
|
8
|
+
def list pages = nil
|
9
|
+
Findface.get_list 'faces', pages
|
10
|
+
end
|
11
|
+
|
12
|
+
# Endpoint: https://api.findface.pro/v0/meta/ (GET) |
|
13
|
+
# Usage: FindFace::Face.list_by_meta
|
14
|
+
# Output: Returns list of faces with meta information
|
15
|
+
def list_by_meta
|
16
|
+
API::request(:get, 'meta')
|
17
|
+
end
|
18
|
+
|
19
|
+
# Endpoint: https://api.findface.pro/v0/face/ (POST) |
|
20
|
+
# Usage: FindFace::Face.create
|
21
|
+
# Output: Creates a new face object
|
22
|
+
def create options
|
23
|
+
API::request(:post, 'face', options)
|
24
|
+
end
|
25
|
+
|
26
|
+
# Endpoint: https://api.findface.pro/v0/face/id/:id (GET) |
|
27
|
+
# Usage: FindFace::Face.details(face_id)
|
28
|
+
# Output: Returns the details of a face with matching id
|
29
|
+
def details face_id
|
30
|
+
API::request(:get, "face/id/#{face_id}")
|
31
|
+
end
|
32
|
+
|
33
|
+
# Endpoint: https://api.findface.pro/v0/face/meta/:meta_string (GET) |
|
34
|
+
# Usage: FindFace::Face.details_by_meta(meta_string)
|
35
|
+
# Output: Returns the details of an face with matching meta_string
|
36
|
+
def details_by_meta meta_string, pages = nil
|
37
|
+
Findface.get_list "face/meta/#{Findface.encode_meta_string(meta_string)}", pages
|
38
|
+
end
|
39
|
+
|
40
|
+
# Endpoint: https://api.findface.pro/v0/face/id/:id (PUT) |
|
41
|
+
# Usage: FindFace::Face.update(face_id)
|
42
|
+
# Output: Updates a face with matching id
|
43
|
+
def update face_id, options
|
44
|
+
API::request(:put, "face/id/#{face_id}", options)
|
45
|
+
end
|
46
|
+
|
47
|
+
# Endpoint: https://api.findface.pro/v0/face/id/:id (DELETE) |
|
48
|
+
# Usage: FindFace::Face.delete(face_id)
|
49
|
+
# Output: Deletes a face with matching id
|
50
|
+
def delete face_id
|
51
|
+
API::request(:delete, "face/id/#{face_id}")
|
52
|
+
end
|
53
|
+
|
54
|
+
# Endpoint: https://api.findface.pro/v0/face/meta/:meta_string (DELETE) |
|
55
|
+
# Usage: FindFace::Face.delete_by_meta(meta_string)
|
56
|
+
# Output: Deletes a face with matching meta_string
|
57
|
+
def delete_by_meta meta_string
|
58
|
+
API::request(:delete, "face/meta/#{Findface.encode_meta_string(meta_string)}")
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Findface
|
2
|
+
class Gallery
|
3
|
+
class << self
|
4
|
+
|
5
|
+
# Endpoint: https://api.findface.pro/v0/galleries/ (GET) |
|
6
|
+
# Usage: FindFace::Gallery.list
|
7
|
+
# Output: Returns list of galleries
|
8
|
+
def list
|
9
|
+
API::request(:get, 'galleries')
|
10
|
+
end
|
11
|
+
|
12
|
+
# Endpoint: https://api.findface.pro/v0/galleries/ (POST) |
|
13
|
+
# Usage: FindFace::Gallery.create
|
14
|
+
# Output: Creates a new gallery
|
15
|
+
def create(options)
|
16
|
+
options[:name] = Findface.format_gallery_name options[:name]
|
17
|
+
API::request(:post, 'galleries', options)
|
18
|
+
end
|
19
|
+
|
20
|
+
# Endpoint: https://api.findface.pro/v0/galleries/:name (DELETE) |
|
21
|
+
# Usage: FindFace::Gallery.delete(name)
|
22
|
+
# Output: Deletes a gallery with matching gallery name
|
23
|
+
def delete(name)
|
24
|
+
API::request(:delete, "galleries/#{Findface.format_gallery_name name}")
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
module Findface
|
2
|
+
class Utility
|
3
|
+
class << self
|
4
|
+
|
5
|
+
# Endpoint: https://api.findface.pro/v0/detect/ (POST) |
|
6
|
+
# Usage: FindFace::Utility.detect
|
7
|
+
# Output: A list of rectangles (bounding boxes) for the detected faces.
|
8
|
+
def detect options
|
9
|
+
API::request(:post, 'detect', options)
|
10
|
+
end
|
11
|
+
|
12
|
+
# Endpoint: https://api.findface.pro/v0/verify/ (POST) |
|
13
|
+
# Usage: FindFace::Utility.verify
|
14
|
+
# Output: Binary verification result of two images provided.
|
15
|
+
def verify options
|
16
|
+
API::request(:post, 'verify', options)
|
17
|
+
end
|
18
|
+
|
19
|
+
# Endpoint: https://api.findface.pro/v0/identify/ (POST) |
|
20
|
+
# Usage: FindFace::Utility.identify
|
21
|
+
# Output: A map with - Detected or provided face bounding boxes, as keys,
|
22
|
+
# Arrays of matching Face objects along with match confidence, as values.
|
23
|
+
def identify options
|
24
|
+
API::request(:post, 'identify', options)
|
25
|
+
end
|
26
|
+
|
27
|
+
# Endpoint: https://api.findface.pro/v0/faces/gallery/:galley_name/identify/ (POST) |
|
28
|
+
# Usage: FindFace::Utility.identify_in_gallery
|
29
|
+
# Output: Same as identification alogorithm, but it is applied on datasets which belongs to particular gallery
|
30
|
+
def identify_in_gallery name, options
|
31
|
+
API::request(:post, "faces/gallery/#{name}/identify", options)
|
32
|
+
end
|
33
|
+
|
34
|
+
# Endpoint: https://api.findface.pro/v0/faces/gallery/:gallery_name/ (GET) |
|
35
|
+
# Usage: FindFace::Utility.list_faces_from_gallery
|
36
|
+
# Output: Returns list of faces data which belongs to particular gallery
|
37
|
+
def list_faces_from_gallery name, pages = nil
|
38
|
+
Findface.get_list "faces/gallery/#{name}/", pages
|
39
|
+
end
|
40
|
+
|
41
|
+
# Endpoint: https://api.findface.pro/v0/face/gallery/:gallery_name/meta/:meta_string (GET) |
|
42
|
+
# Usage: FindFace::Utility.list_faces_from_gallery_by_meta
|
43
|
+
# Output: Retuns list of faces which belongs to particular gallery by meta information provided
|
44
|
+
def list_faces_from_gallery_by_meta name, meta_string, pages = nil
|
45
|
+
Findface.get_list "faces/gallery/#{name}/meta/#{Findface.encode_meta_string(meta_string)}", pages
|
46
|
+
end
|
47
|
+
|
48
|
+
# Endpoint: https://api.findface.pro/v0/meta/gallery/:gallery_name/ (GET) |
|
49
|
+
# Usage: FindFace::Utility.list_meta_for_gallery
|
50
|
+
# Output: Returns meta information of faces belongs to particular gallery
|
51
|
+
def list_meta_for_gallery name
|
52
|
+
API::request(:get, "meta/gallery/#{name}/")
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
metadata
ADDED
@@ -0,0 +1,154 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: findface
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Sandeep Mallela a.k.a Sam
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-01-20 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.13'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.13'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.5'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.5'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: httparty
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.14.0
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.14.0
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: json
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '2.0'
|
76
|
+
- - ">="
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: 2.0.2
|
79
|
+
type: :runtime
|
80
|
+
prerelease: false
|
81
|
+
version_requirements: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - "~>"
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '2.0'
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: 2.0.2
|
89
|
+
- !ruby/object:Gem::Dependency
|
90
|
+
name: yard
|
91
|
+
requirement: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - "~>"
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: 0.9.8
|
96
|
+
type: :runtime
|
97
|
+
prerelease: false
|
98
|
+
version_requirements: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - "~>"
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: 0.9.8
|
103
|
+
description: Utility to use FindFace API Face Detection algorithms on media like photos
|
104
|
+
email:
|
105
|
+
- opensource@rubyeffect.com
|
106
|
+
- sandeep@rubyeffect.com
|
107
|
+
executables: []
|
108
|
+
extensions: []
|
109
|
+
extra_rdoc_files: []
|
110
|
+
files:
|
111
|
+
- ".gitignore"
|
112
|
+
- ".rspec"
|
113
|
+
- ".travis.yml"
|
114
|
+
- CODE_OF_CONDUCT.md
|
115
|
+
- Gemfile
|
116
|
+
- LICENSE.txt
|
117
|
+
- README.md
|
118
|
+
- Rakefile
|
119
|
+
- bin/console
|
120
|
+
- bin/setup
|
121
|
+
- findface.gemspec
|
122
|
+
- lib/findface.rb
|
123
|
+
- lib/findface/all.rb
|
124
|
+
- lib/findface/api.rb
|
125
|
+
- lib/findface/error.rb
|
126
|
+
- lib/findface/face.rb
|
127
|
+
- lib/findface/gallery.rb
|
128
|
+
- lib/findface/utility.rb
|
129
|
+
- lib/findface/version.rb
|
130
|
+
homepage: https://github.com/rubyeffect/findface
|
131
|
+
licenses:
|
132
|
+
- MIT
|
133
|
+
metadata: {}
|
134
|
+
post_install_message:
|
135
|
+
rdoc_options: []
|
136
|
+
require_paths:
|
137
|
+
- lib
|
138
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
139
|
+
requirements:
|
140
|
+
- - ">="
|
141
|
+
- !ruby/object:Gem::Version
|
142
|
+
version: '0'
|
143
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
144
|
+
requirements:
|
145
|
+
- - ">="
|
146
|
+
- !ruby/object:Gem::Version
|
147
|
+
version: '0'
|
148
|
+
requirements: []
|
149
|
+
rubyforge_project:
|
150
|
+
rubygems_version: 2.6.8
|
151
|
+
signing_key:
|
152
|
+
specification_version: 4
|
153
|
+
summary: Ruby Gem for Findface API to use it in Ruby on Rails & Sinatra Applications
|
154
|
+
test_files: []
|