Module: DeepStack::Face
- Included in:
- DeepStack
- Defined in:
- lib/deep_stack/face.rb
Overview
APIs related to face recognition
Instance Method Summary collapse
-
#delete_face(userid) ⇒ Boolean
Delete the given face / userid.
-
#delete_faces(*userids) ⇒ Hash
Delete the given list of faces / userids.
-
#detect_faces(image, **options) ⇒ Array
Detect faces in an image.
-
#face_list ⇒ Array
Get a list of registered faces.
-
#face_match(*images, **args) ⇒ Float?
Call DeepStack’s Face Match service.
-
#recognize_faces(image, **options) ⇒ Array?
Perform face recognition.
-
#register_face(userid, *images) ⇒ Boolean
Register a face.
Instance Method Details
#delete_face(userid) ⇒ Boolean
Delete the given face / userid
63 64 65 66 |
# File 'lib/deep_stack/face.rb', line 63 def delete_face(userid) target = 'vision/face/delete' api_post(target, userid: userid)&.dig('success') == true end |
#delete_faces(*userids) ⇒ Hash
Delete the given list of faces / userids
52 53 54 |
# File 'lib/deep_stack/face.rb', line 52 def delete_faces(*userids) userids.flatten.compact.to_h { |userid| [userid, delete_face(userid)] } end |
#detect_faces(image, **options) ⇒ Array
Detect faces in an image
29 30 31 32 |
# File 'lib/deep_stack/face.rb', line 29 def detect_faces(image, **) target = 'vision/face/' # the URL ends with a slash api_post(target, image, **)&.dig('predictions') end |
#face_list ⇒ Array
Get a list of registered faces
39 40 41 42 43 |
# File 'lib/deep_stack/face.rb', line 39 def face_list target = 'vision/face/list' api_post(target)&.dig('faces') # {"success"=>true, "faces"=>["face_1", "face_2"], "duration"=>0} end |
#face_match(*images, **args) ⇒ Float?
Call DeepStack’s Face Match service. Compare two different pictures and tells the similarity between them.
95 96 97 98 |
# File 'lib/deep_stack/face.rb', line 95 def face_match(*images, **args) target = 'vision/face/match' api_post(target, images, **args)&.dig('similarity') end |
#recognize_faces(image, **options) ⇒ Array?
Perform face recognition
16 17 18 19 |
# File 'lib/deep_stack/face.rb', line 16 def recognize_faces(image, **) target = 'vision/face/recognize' api_post(target, image, **)&.dig('predictions') end |
#register_face(userid, *images) ⇒ Boolean
Register a face
76 77 78 79 |
# File 'lib/deep_stack/face.rb', line 76 def register_face(userid, *images) target = 'vision/face/register' api_post(target, images, userid: userid)&.dig('success') == true end |