azure_cognitiveservices_face 0.16.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE.txt +21 -0
- data/lib/1.0/generated/azure_cognitiveservices_face.rb +78 -0
- data/lib/1.0/generated/azure_cognitiveservices_face/face.rb +955 -0
- data/lib/1.0/generated/azure_cognitiveservices_face/face_client.rb +145 -0
- data/lib/1.0/generated/azure_cognitiveservices_face/face_list_operations.rb +857 -0
- data/lib/1.0/generated/azure_cognitiveservices_face/models/accessory.rb +59 -0
- data/lib/1.0/generated/azure_cognitiveservices_face/models/accessory_type.rb +17 -0
- data/lib/1.0/generated/azure_cognitiveservices_face/models/apierror.rb +47 -0
- data/lib/1.0/generated/azure_cognitiveservices_face/models/azure_regions.rb +26 -0
- data/lib/1.0/generated/azure_cognitiveservices_face/models/blur.rb +60 -0
- data/lib/1.0/generated/azure_cognitiveservices_face/models/blur_level.rb +17 -0
- data/lib/1.0/generated/azure_cognitiveservices_face/models/coordinate.rb +57 -0
- data/lib/1.0/generated/azure_cognitiveservices_face/models/detected_face.rb +82 -0
- data/lib/1.0/generated/azure_cognitiveservices_face/models/emotion.rb +124 -0
- data/lib/1.0/generated/azure_cognitiveservices_face/models/error.rb +57 -0
- data/lib/1.0/generated/azure_cognitiveservices_face/models/exposure.rb +62 -0
- data/lib/1.0/generated/azure_cognitiveservices_face/models/exposure_level.rb +17 -0
- data/lib/1.0/generated/azure_cognitiveservices_face/models/face_attribute_type.rb +28 -0
- data/lib/1.0/generated/azure_cognitiveservices_face/models/face_attributes.rb +214 -0
- data/lib/1.0/generated/azure_cognitiveservices_face/models/face_landmarks.rb +360 -0
- data/lib/1.0/generated/azure_cognitiveservices_face/models/face_list.rb +92 -0
- data/lib/1.0/generated/azure_cognitiveservices_face/models/face_rectangle.rb +81 -0
- data/lib/1.0/generated/azure_cognitiveservices_face/models/facial_hair.rb +68 -0
- data/lib/1.0/generated/azure_cognitiveservices_face/models/find_similar_match_mode.rb +16 -0
- data/lib/1.0/generated/azure_cognitiveservices_face/models/find_similar_request.rb +121 -0
- data/lib/1.0/generated/azure_cognitiveservices_face/models/gender.rb +17 -0
- data/lib/1.0/generated/azure_cognitiveservices_face/models/glasses_type.rb +18 -0
- data/lib/1.0/generated/azure_cognitiveservices_face/models/group_request.rb +58 -0
- data/lib/1.0/generated/azure_cognitiveservices_face/models/group_result.rb +83 -0
- data/lib/1.0/generated/azure_cognitiveservices_face/models/hair.rb +80 -0
- data/lib/1.0/generated/azure_cognitiveservices_face/models/hair_color.rb +60 -0
- data/lib/1.0/generated/azure_cognitiveservices_face/models/hair_color_type.rb +22 -0
- data/lib/1.0/generated/azure_cognitiveservices_face/models/head_pose.rb +68 -0
- data/lib/1.0/generated/azure_cognitiveservices_face/models/identify_candidate.rb +59 -0
- data/lib/1.0/generated/azure_cognitiveservices_face/models/identify_request.rb +105 -0
- data/lib/1.0/generated/azure_cognitiveservices_face/models/identify_result.rb +69 -0
- data/lib/1.0/generated/azure_cognitiveservices_face/models/image_url.rb +47 -0
- data/lib/1.0/generated/azure_cognitiveservices_face/models/makeup.rb +59 -0
- data/lib/1.0/generated/azure_cognitiveservices_face/models/name_and_user_data_contract.rb +64 -0
- data/lib/1.0/generated/azure_cognitiveservices_face/models/noise.rb +62 -0
- data/lib/1.0/generated/azure_cognitiveservices_face/models/noise_level.rb +17 -0
- data/lib/1.0/generated/azure_cognitiveservices_face/models/occlusion.rb +70 -0
- data/lib/1.0/generated/azure_cognitiveservices_face/models/persisted_face.rb +63 -0
- data/lib/1.0/generated/azure_cognitiveservices_face/models/person.rb +89 -0
- data/lib/1.0/generated/azure_cognitiveservices_face/models/person_group.rb +72 -0
- data/lib/1.0/generated/azure_cognitiveservices_face/models/similar_face.rb +73 -0
- data/lib/1.0/generated/azure_cognitiveservices_face/models/training_status.rb +89 -0
- data/lib/1.0/generated/azure_cognitiveservices_face/models/training_status_type.rb +18 -0
- data/lib/1.0/generated/azure_cognitiveservices_face/models/update_person_face_request.rb +50 -0
- data/lib/1.0/generated/azure_cognitiveservices_face/models/verify_face_to_face_request.rb +57 -0
- data/lib/1.0/generated/azure_cognitiveservices_face/models/verify_face_to_person_request.rb +75 -0
- data/lib/1.0/generated/azure_cognitiveservices_face/models/verify_result.rb +62 -0
- data/lib/1.0/generated/azure_cognitiveservices_face/module_definition.rb +9 -0
- data/lib/1.0/generated/azure_cognitiveservices_face/person_group_operations.rb +678 -0
- data/lib/1.0/generated/azure_cognitiveservices_face/person_group_person.rb +1121 -0
- data/lib/azure_cognitiveservices_face.rb +6 -0
- data/lib/module_definition.rb +7 -0
- data/lib/profiles/latest/face_latest_profile_client.rb +38 -0
- data/lib/profiles/latest/face_module_definition.rb +8 -0
- data/lib/profiles/latest/modules/face_profile_module.rb +253 -0
- data/lib/version.rb +7 -0
- metadata +180 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 6648bdf2512575046c982df50d07e0127e54b459
|
4
|
+
data.tar.gz: ec848ceb96afb3fde854043a9651e0b36051f91c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1013d4549baea2255821fb82845e491ec86750de8f1ec35ba312f8db91e9461bc11861fe821d7f0044e9ea637fa4d41ef13135ec102d4f12fb04541457ec3e38
|
7
|
+
data.tar.gz: b6fd153ddf17767e212dc5f14bf9aca2d01efed4dd87994264f66d51a60de51594276bebad42cdb8f064daba3f31c2c582bc7ef7a58626788e256a2a59ba44eb
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Microsoft Corporation
|
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.
|
@@ -0,0 +1,78 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# Code generated by Microsoft (R) AutoRest Code Generator.
|
3
|
+
# Changes may cause incorrect behavior and will be lost if the code is
|
4
|
+
# regenerated.
|
5
|
+
|
6
|
+
require 'uri'
|
7
|
+
require 'cgi'
|
8
|
+
require 'date'
|
9
|
+
require 'json'
|
10
|
+
require 'base64'
|
11
|
+
require 'erb'
|
12
|
+
require 'securerandom'
|
13
|
+
require 'time'
|
14
|
+
require 'timeliness'
|
15
|
+
require 'faraday'
|
16
|
+
require 'faraday-cookie_jar'
|
17
|
+
require 'concurrent'
|
18
|
+
require 'ms_rest'
|
19
|
+
require '1.0/generated/azure_cognitiveservices_face/module_definition'
|
20
|
+
require 'ms_rest_azure'
|
21
|
+
|
22
|
+
module Azure::CognitiveServices::Face::V1_0
|
23
|
+
autoload :Face, '1.0/generated/azure_cognitiveservices_face/face.rb'
|
24
|
+
autoload :PersonGroupPerson, '1.0/generated/azure_cognitiveservices_face/person_group_person.rb'
|
25
|
+
autoload :PersonGroupOperations, '1.0/generated/azure_cognitiveservices_face/person_group_operations.rb'
|
26
|
+
autoload :FaceListOperations, '1.0/generated/azure_cognitiveservices_face/face_list_operations.rb'
|
27
|
+
autoload :FaceClient, '1.0/generated/azure_cognitiveservices_face/face_client.rb'
|
28
|
+
|
29
|
+
module Models
|
30
|
+
autoload :FindSimilarRequest, '1.0/generated/azure_cognitiveservices_face/models/find_similar_request.rb'
|
31
|
+
autoload :Error, '1.0/generated/azure_cognitiveservices_face/models/error.rb'
|
32
|
+
autoload :SimilarFace, '1.0/generated/azure_cognitiveservices_face/models/similar_face.rb'
|
33
|
+
autoload :FaceRectangle, '1.0/generated/azure_cognitiveservices_face/models/face_rectangle.rb'
|
34
|
+
autoload :GroupRequest, '1.0/generated/azure_cognitiveservices_face/models/group_request.rb'
|
35
|
+
autoload :FaceLandmarks, '1.0/generated/azure_cognitiveservices_face/models/face_landmarks.rb'
|
36
|
+
autoload :GroupResult, '1.0/generated/azure_cognitiveservices_face/models/group_result.rb'
|
37
|
+
autoload :HeadPose, '1.0/generated/azure_cognitiveservices_face/models/head_pose.rb'
|
38
|
+
autoload :IdentifyRequest, '1.0/generated/azure_cognitiveservices_face/models/identify_request.rb'
|
39
|
+
autoload :HairColor, '1.0/generated/azure_cognitiveservices_face/models/hair_color.rb'
|
40
|
+
autoload :IdentifyCandidate, '1.0/generated/azure_cognitiveservices_face/models/identify_candidate.rb'
|
41
|
+
autoload :Makeup, '1.0/generated/azure_cognitiveservices_face/models/makeup.rb'
|
42
|
+
autoload :IdentifyResult, '1.0/generated/azure_cognitiveservices_face/models/identify_result.rb'
|
43
|
+
autoload :Accessory, '1.0/generated/azure_cognitiveservices_face/models/accessory.rb'
|
44
|
+
autoload :VerifyFaceToPersonRequest, '1.0/generated/azure_cognitiveservices_face/models/verify_face_to_person_request.rb'
|
45
|
+
autoload :Exposure, '1.0/generated/azure_cognitiveservices_face/models/exposure.rb'
|
46
|
+
autoload :VerifyFaceToFaceRequest, '1.0/generated/azure_cognitiveservices_face/models/verify_face_to_face_request.rb'
|
47
|
+
autoload :FaceAttributes, '1.0/generated/azure_cognitiveservices_face/models/face_attributes.rb'
|
48
|
+
autoload :VerifyResult, '1.0/generated/azure_cognitiveservices_face/models/verify_result.rb'
|
49
|
+
autoload :APIError, '1.0/generated/azure_cognitiveservices_face/models/apierror.rb'
|
50
|
+
autoload :PersistedFace, '1.0/generated/azure_cognitiveservices_face/models/persisted_face.rb'
|
51
|
+
autoload :FacialHair, '1.0/generated/azure_cognitiveservices_face/models/facial_hair.rb'
|
52
|
+
autoload :Coordinate, '1.0/generated/azure_cognitiveservices_face/models/coordinate.rb'
|
53
|
+
autoload :Emotion, '1.0/generated/azure_cognitiveservices_face/models/emotion.rb'
|
54
|
+
autoload :Occlusion, '1.0/generated/azure_cognitiveservices_face/models/occlusion.rb'
|
55
|
+
autoload :Noise, '1.0/generated/azure_cognitiveservices_face/models/noise.rb'
|
56
|
+
autoload :ImageUrl, '1.0/generated/azure_cognitiveservices_face/models/image_url.rb'
|
57
|
+
autoload :Hair, '1.0/generated/azure_cognitiveservices_face/models/hair.rb'
|
58
|
+
autoload :NameAndUserDataContract, '1.0/generated/azure_cognitiveservices_face/models/name_and_user_data_contract.rb'
|
59
|
+
autoload :DetectedFace, '1.0/generated/azure_cognitiveservices_face/models/detected_face.rb'
|
60
|
+
autoload :UpdatePersonFaceRequest, '1.0/generated/azure_cognitiveservices_face/models/update_person_face_request.rb'
|
61
|
+
autoload :Blur, '1.0/generated/azure_cognitiveservices_face/models/blur.rb'
|
62
|
+
autoload :TrainingStatus, '1.0/generated/azure_cognitiveservices_face/models/training_status.rb'
|
63
|
+
autoload :FaceList, '1.0/generated/azure_cognitiveservices_face/models/face_list.rb'
|
64
|
+
autoload :PersonGroup, '1.0/generated/azure_cognitiveservices_face/models/person_group.rb'
|
65
|
+
autoload :Person, '1.0/generated/azure_cognitiveservices_face/models/person.rb'
|
66
|
+
autoload :Gender, '1.0/generated/azure_cognitiveservices_face/models/gender.rb'
|
67
|
+
autoload :GlassesType, '1.0/generated/azure_cognitiveservices_face/models/glasses_type.rb'
|
68
|
+
autoload :HairColorType, '1.0/generated/azure_cognitiveservices_face/models/hair_color_type.rb'
|
69
|
+
autoload :AccessoryType, '1.0/generated/azure_cognitiveservices_face/models/accessory_type.rb'
|
70
|
+
autoload :BlurLevel, '1.0/generated/azure_cognitiveservices_face/models/blur_level.rb'
|
71
|
+
autoload :ExposureLevel, '1.0/generated/azure_cognitiveservices_face/models/exposure_level.rb'
|
72
|
+
autoload :NoiseLevel, '1.0/generated/azure_cognitiveservices_face/models/noise_level.rb'
|
73
|
+
autoload :FindSimilarMatchMode, '1.0/generated/azure_cognitiveservices_face/models/find_similar_match_mode.rb'
|
74
|
+
autoload :TrainingStatusType, '1.0/generated/azure_cognitiveservices_face/models/training_status_type.rb'
|
75
|
+
autoload :FaceAttributeType, '1.0/generated/azure_cognitiveservices_face/models/face_attribute_type.rb'
|
76
|
+
autoload :AzureRegions, '1.0/generated/azure_cognitiveservices_face/models/azure_regions.rb'
|
77
|
+
end
|
78
|
+
end
|
@@ -0,0 +1,955 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# Code generated by Microsoft (R) AutoRest Code Generator.
|
3
|
+
# Changes may cause incorrect behavior and will be lost if the code is
|
4
|
+
# regenerated.
|
5
|
+
|
6
|
+
module Azure::CognitiveServices::Face::V1_0
|
7
|
+
#
|
8
|
+
# An API for face detection, verification, and identification.
|
9
|
+
#
|
10
|
+
class Face
|
11
|
+
include MsRestAzure
|
12
|
+
|
13
|
+
#
|
14
|
+
# Creates and initializes a new instance of the Face class.
|
15
|
+
# @param client service class for accessing basic functionality.
|
16
|
+
#
|
17
|
+
def initialize(client)
|
18
|
+
@client = client
|
19
|
+
end
|
20
|
+
|
21
|
+
# @return [FaceClient] reference to the FaceClient
|
22
|
+
attr_reader :client
|
23
|
+
|
24
|
+
#
|
25
|
+
# Given query face's faceId, find the similar-looking faces from a faceId array
|
26
|
+
# or a faceListId.
|
27
|
+
#
|
28
|
+
# @param face_id FaceId of the query face. User needs to call Face - Detect
|
29
|
+
# first to get a valid faceId. Note that this faceId is not persisted and will
|
30
|
+
# expire 24 hours after the detection call
|
31
|
+
# @param face_list_id [String] An existing user-specified unique candidate face
|
32
|
+
# list, created in Face List - Create a Face List. Face list contains a set of
|
33
|
+
# persistedFaceIds which are persisted and will never expire. Parameter
|
34
|
+
# faceListId and faceIds should not be provided at the same time
|
35
|
+
# @param face_ids An array of candidate faceIds. All of them are created by
|
36
|
+
# Face - Detect and the faceIds will expire 24 hours after the detection call.
|
37
|
+
# @param max_num_of_candidates_returned [Integer] The number of top similar
|
38
|
+
# faces returned. The valid range is [1, 1000].
|
39
|
+
# @param mode [FindSimilarMatchMode] Similar face searching mode. It can be
|
40
|
+
# "matchPerson" or "matchFace". Possible values include: 'matchPerson',
|
41
|
+
# 'matchFace'
|
42
|
+
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
43
|
+
# will be added to the HTTP request.
|
44
|
+
#
|
45
|
+
# @return [Array] operation results.
|
46
|
+
#
|
47
|
+
def find_similar(face_id, face_list_id:nil, face_ids:nil, max_num_of_candidates_returned:20, mode:nil, custom_headers:nil)
|
48
|
+
response = find_similar_async(face_id, face_list_id:face_list_id, face_ids:face_ids, max_num_of_candidates_returned:max_num_of_candidates_returned, mode:mode, custom_headers:custom_headers).value!
|
49
|
+
response.body unless response.nil?
|
50
|
+
end
|
51
|
+
|
52
|
+
#
|
53
|
+
# Given query face's faceId, find the similar-looking faces from a faceId array
|
54
|
+
# or a faceListId.
|
55
|
+
#
|
56
|
+
# @param face_id FaceId of the query face. User needs to call Face - Detect
|
57
|
+
# first to get a valid faceId. Note that this faceId is not persisted and will
|
58
|
+
# expire 24 hours after the detection call
|
59
|
+
# @param face_list_id [String] An existing user-specified unique candidate face
|
60
|
+
# list, created in Face List - Create a Face List. Face list contains a set of
|
61
|
+
# persistedFaceIds which are persisted and will never expire. Parameter
|
62
|
+
# faceListId and faceIds should not be provided at the same time
|
63
|
+
# @param face_ids An array of candidate faceIds. All of them are created by
|
64
|
+
# Face - Detect and the faceIds will expire 24 hours after the detection call.
|
65
|
+
# @param max_num_of_candidates_returned [Integer] The number of top similar
|
66
|
+
# faces returned. The valid range is [1, 1000].
|
67
|
+
# @param mode [FindSimilarMatchMode] Similar face searching mode. It can be
|
68
|
+
# "matchPerson" or "matchFace". Possible values include: 'matchPerson',
|
69
|
+
# 'matchFace'
|
70
|
+
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
71
|
+
# will be added to the HTTP request.
|
72
|
+
#
|
73
|
+
# @return [MsRestAzure::AzureOperationResponse] HTTP response information.
|
74
|
+
#
|
75
|
+
def find_similar_with_http_info(face_id, face_list_id:nil, face_ids:nil, max_num_of_candidates_returned:20, mode:nil, custom_headers:nil)
|
76
|
+
find_similar_async(face_id, face_list_id:face_list_id, face_ids:face_ids, max_num_of_candidates_returned:max_num_of_candidates_returned, mode:mode, custom_headers:custom_headers).value!
|
77
|
+
end
|
78
|
+
|
79
|
+
#
|
80
|
+
# Given query face's faceId, find the similar-looking faces from a faceId array
|
81
|
+
# or a faceListId.
|
82
|
+
#
|
83
|
+
# @param face_id FaceId of the query face. User needs to call Face - Detect
|
84
|
+
# first to get a valid faceId. Note that this faceId is not persisted and will
|
85
|
+
# expire 24 hours after the detection call
|
86
|
+
# @param face_list_id [String] An existing user-specified unique candidate face
|
87
|
+
# list, created in Face List - Create a Face List. Face list contains a set of
|
88
|
+
# persistedFaceIds which are persisted and will never expire. Parameter
|
89
|
+
# faceListId and faceIds should not be provided at the same time
|
90
|
+
# @param face_ids An array of candidate faceIds. All of them are created by
|
91
|
+
# Face - Detect and the faceIds will expire 24 hours after the detection call.
|
92
|
+
# @param max_num_of_candidates_returned [Integer] The number of top similar
|
93
|
+
# faces returned. The valid range is [1, 1000].
|
94
|
+
# @param mode [FindSimilarMatchMode] Similar face searching mode. It can be
|
95
|
+
# "matchPerson" or "matchFace". Possible values include: 'matchPerson',
|
96
|
+
# 'matchFace'
|
97
|
+
# @param [Hash{String => String}] A hash of custom headers that will be added
|
98
|
+
# to the HTTP request.
|
99
|
+
#
|
100
|
+
# @return [Concurrent::Promise] Promise object which holds the HTTP response.
|
101
|
+
#
|
102
|
+
def find_similar_async(face_id, face_list_id:nil, face_ids:nil, max_num_of_candidates_returned:20, mode:nil, custom_headers:nil)
|
103
|
+
fail ArgumentError, '@client.azure_region is nil' if @client.azure_region.nil?
|
104
|
+
fail ArgumentError, 'face_id is nil' if face_id.nil?
|
105
|
+
fail ArgumentError, "'face_list_id' should satisfy the constraint - 'MaxLength': '64'" if !face_list_id.nil? && face_list_id.length > 64
|
106
|
+
fail ArgumentError, "'face_list_id' should satisfy the constraint - 'Pattern': '^[a-z0-9-_]+$'" if !face_list_id.nil? && face_list_id.match(Regexp.new('^^[a-z0-9-_]+$$')).nil?
|
107
|
+
fail ArgumentError, "'face_ids' should satisfy the constraint - 'MaxItems': '1000'" if !face_ids.nil? && face_ids.length > 1000
|
108
|
+
fail ArgumentError, "'max_num_of_candidates_returned' should satisfy the constraint - 'InclusiveMaximum': '1000'" if !max_num_of_candidates_returned.nil? && max_num_of_candidates_returned > 1000
|
109
|
+
fail ArgumentError, "'max_num_of_candidates_returned' should satisfy the constraint - 'InclusiveMinimum': '1'" if !max_num_of_candidates_returned.nil? && max_num_of_candidates_returned < 1
|
110
|
+
|
111
|
+
body = FindSimilarRequest.new
|
112
|
+
unless face_id.nil? && face_list_id.nil? && face_ids.nil? && max_num_of_candidates_returned.nil? && mode.nil?
|
113
|
+
body.face_id = face_id
|
114
|
+
body.face_list_id = face_list_id
|
115
|
+
body.face_ids = face_ids
|
116
|
+
body.max_num_of_candidates_returned = max_num_of_candidates_returned
|
117
|
+
body.mode = mode
|
118
|
+
end
|
119
|
+
|
120
|
+
request_headers = {}
|
121
|
+
request_headers['Content-Type'] = 'application/json; charset=utf-8'
|
122
|
+
|
123
|
+
# Set Headers
|
124
|
+
request_headers['x-ms-client-request-id'] = SecureRandom.uuid
|
125
|
+
request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
|
126
|
+
|
127
|
+
# Serialize Request
|
128
|
+
request_mapper = Azure::CognitiveServices::Face::V1_0::Models::FindSimilarRequest.mapper()
|
129
|
+
request_content = @client.serialize(request_mapper, body)
|
130
|
+
request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil
|
131
|
+
|
132
|
+
path_template = 'findsimilars'
|
133
|
+
|
134
|
+
request_url = @base_url || @client.base_url
|
135
|
+
request_url = request_url.gsub('{AzureRegion}', @client.azure_region)
|
136
|
+
|
137
|
+
options = {
|
138
|
+
middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
|
139
|
+
body: request_content,
|
140
|
+
headers: request_headers.merge(custom_headers || {}),
|
141
|
+
base_url: request_url
|
142
|
+
}
|
143
|
+
promise = @client.make_request_async(:post, path_template, options)
|
144
|
+
|
145
|
+
promise = promise.then do |result|
|
146
|
+
http_response = result.response
|
147
|
+
status_code = http_response.status
|
148
|
+
response_content = http_response.body
|
149
|
+
unless status_code == 200
|
150
|
+
error_model = JSON.load(response_content)
|
151
|
+
fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
|
152
|
+
end
|
153
|
+
|
154
|
+
result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
|
155
|
+
# Deserialize Response
|
156
|
+
if status_code == 200
|
157
|
+
begin
|
158
|
+
parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
|
159
|
+
result_mapper = {
|
160
|
+
client_side_validation: true,
|
161
|
+
required: false,
|
162
|
+
serialized_name: 'parsed_response',
|
163
|
+
type: {
|
164
|
+
name: 'Sequence',
|
165
|
+
element: {
|
166
|
+
client_side_validation: true,
|
167
|
+
required: false,
|
168
|
+
serialized_name: 'SimilarFaceElementType',
|
169
|
+
type: {
|
170
|
+
name: 'Composite',
|
171
|
+
class_name: 'SimilarFace'
|
172
|
+
}
|
173
|
+
}
|
174
|
+
}
|
175
|
+
}
|
176
|
+
result.body = @client.deserialize(result_mapper, parsed_response)
|
177
|
+
rescue Exception => e
|
178
|
+
fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
182
|
+
result
|
183
|
+
end
|
184
|
+
|
185
|
+
promise.execute
|
186
|
+
end
|
187
|
+
|
188
|
+
#
|
189
|
+
# Divide candidate faces into groups based on face similarity.
|
190
|
+
#
|
191
|
+
# @param face_ids Array of candidate faceId created by Face - Detect. The
|
192
|
+
# maximum is 1000 faces
|
193
|
+
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
194
|
+
# will be added to the HTTP request.
|
195
|
+
#
|
196
|
+
# @return [GroupResult] operation results.
|
197
|
+
#
|
198
|
+
def group(face_ids, custom_headers:nil)
|
199
|
+
response = group_async(face_ids, custom_headers:custom_headers).value!
|
200
|
+
response.body unless response.nil?
|
201
|
+
end
|
202
|
+
|
203
|
+
#
|
204
|
+
# Divide candidate faces into groups based on face similarity.
|
205
|
+
#
|
206
|
+
# @param face_ids Array of candidate faceId created by Face - Detect. The
|
207
|
+
# maximum is 1000 faces
|
208
|
+
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
209
|
+
# will be added to the HTTP request.
|
210
|
+
#
|
211
|
+
# @return [MsRestAzure::AzureOperationResponse] HTTP response information.
|
212
|
+
#
|
213
|
+
def group_with_http_info(face_ids, custom_headers:nil)
|
214
|
+
group_async(face_ids, custom_headers:custom_headers).value!
|
215
|
+
end
|
216
|
+
|
217
|
+
#
|
218
|
+
# Divide candidate faces into groups based on face similarity.
|
219
|
+
#
|
220
|
+
# @param face_ids Array of candidate faceId created by Face - Detect. The
|
221
|
+
# maximum is 1000 faces
|
222
|
+
# @param [Hash{String => String}] A hash of custom headers that will be added
|
223
|
+
# to the HTTP request.
|
224
|
+
#
|
225
|
+
# @return [Concurrent::Promise] Promise object which holds the HTTP response.
|
226
|
+
#
|
227
|
+
def group_async(face_ids, custom_headers:nil)
|
228
|
+
fail ArgumentError, '@client.azure_region is nil' if @client.azure_region.nil?
|
229
|
+
fail ArgumentError, 'face_ids is nil' if face_ids.nil?
|
230
|
+
fail ArgumentError, "'face_ids' should satisfy the constraint - 'MaxItems': '1000'" if !face_ids.nil? && face_ids.length > 1000
|
231
|
+
|
232
|
+
body = GroupRequest.new
|
233
|
+
unless face_ids.nil?
|
234
|
+
body.face_ids = face_ids
|
235
|
+
end
|
236
|
+
|
237
|
+
request_headers = {}
|
238
|
+
request_headers['Content-Type'] = 'application/json; charset=utf-8'
|
239
|
+
|
240
|
+
# Set Headers
|
241
|
+
request_headers['x-ms-client-request-id'] = SecureRandom.uuid
|
242
|
+
request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
|
243
|
+
|
244
|
+
# Serialize Request
|
245
|
+
request_mapper = Azure::CognitiveServices::Face::V1_0::Models::GroupRequest.mapper()
|
246
|
+
request_content = @client.serialize(request_mapper, body)
|
247
|
+
request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil
|
248
|
+
|
249
|
+
path_template = 'group'
|
250
|
+
|
251
|
+
request_url = @base_url || @client.base_url
|
252
|
+
request_url = request_url.gsub('{AzureRegion}', @client.azure_region)
|
253
|
+
|
254
|
+
options = {
|
255
|
+
middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
|
256
|
+
body: request_content,
|
257
|
+
headers: request_headers.merge(custom_headers || {}),
|
258
|
+
base_url: request_url
|
259
|
+
}
|
260
|
+
promise = @client.make_request_async(:post, path_template, options)
|
261
|
+
|
262
|
+
promise = promise.then do |result|
|
263
|
+
http_response = result.response
|
264
|
+
status_code = http_response.status
|
265
|
+
response_content = http_response.body
|
266
|
+
unless status_code == 200
|
267
|
+
error_model = JSON.load(response_content)
|
268
|
+
fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
|
269
|
+
end
|
270
|
+
|
271
|
+
result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
|
272
|
+
# Deserialize Response
|
273
|
+
if status_code == 200
|
274
|
+
begin
|
275
|
+
parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
|
276
|
+
result_mapper = Azure::CognitiveServices::Face::V1_0::Models::GroupResult.mapper()
|
277
|
+
result.body = @client.deserialize(result_mapper, parsed_response)
|
278
|
+
rescue Exception => e
|
279
|
+
fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
|
280
|
+
end
|
281
|
+
end
|
282
|
+
|
283
|
+
result
|
284
|
+
end
|
285
|
+
|
286
|
+
promise.execute
|
287
|
+
end
|
288
|
+
|
289
|
+
#
|
290
|
+
# Identify unknown faces from a person group.
|
291
|
+
#
|
292
|
+
# @param person_group_id [String] PersonGroupId of the target person group,
|
293
|
+
# created by PersonGroups.Create
|
294
|
+
# @param face_ids Array of query faces faceIds, created by the Face - Detect.
|
295
|
+
# Each of the faces are identified independently. The valid number of faceIds
|
296
|
+
# is between [1, 10].
|
297
|
+
# @param max_num_of_candidates_returned [Integer] The range of
|
298
|
+
# maxNumOfCandidatesReturned is between 1 and 5 (default is 1).
|
299
|
+
# @param confidence_threshold [Float] Confidence threshold of identification,
|
300
|
+
# used to judge whether one face belong to one person. The range of
|
301
|
+
# confidenceThreshold is [0, 1] (default specified by algorithm).
|
302
|
+
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
303
|
+
# will be added to the HTTP request.
|
304
|
+
#
|
305
|
+
# @return [Array] operation results.
|
306
|
+
#
|
307
|
+
def identify(person_group_id, face_ids, max_num_of_candidates_returned:1, confidence_threshold:nil, custom_headers:nil)
|
308
|
+
response = identify_async(person_group_id, face_ids, max_num_of_candidates_returned:max_num_of_candidates_returned, confidence_threshold:confidence_threshold, custom_headers:custom_headers).value!
|
309
|
+
response.body unless response.nil?
|
310
|
+
end
|
311
|
+
|
312
|
+
#
|
313
|
+
# Identify unknown faces from a person group.
|
314
|
+
#
|
315
|
+
# @param person_group_id [String] PersonGroupId of the target person group,
|
316
|
+
# created by PersonGroups.Create
|
317
|
+
# @param face_ids Array of query faces faceIds, created by the Face - Detect.
|
318
|
+
# Each of the faces are identified independently. The valid number of faceIds
|
319
|
+
# is between [1, 10].
|
320
|
+
# @param max_num_of_candidates_returned [Integer] The range of
|
321
|
+
# maxNumOfCandidatesReturned is between 1 and 5 (default is 1).
|
322
|
+
# @param confidence_threshold [Float] Confidence threshold of identification,
|
323
|
+
# used to judge whether one face belong to one person. The range of
|
324
|
+
# confidenceThreshold is [0, 1] (default specified by algorithm).
|
325
|
+
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
326
|
+
# will be added to the HTTP request.
|
327
|
+
#
|
328
|
+
# @return [MsRestAzure::AzureOperationResponse] HTTP response information.
|
329
|
+
#
|
330
|
+
def identify_with_http_info(person_group_id, face_ids, max_num_of_candidates_returned:1, confidence_threshold:nil, custom_headers:nil)
|
331
|
+
identify_async(person_group_id, face_ids, max_num_of_candidates_returned:max_num_of_candidates_returned, confidence_threshold:confidence_threshold, custom_headers:custom_headers).value!
|
332
|
+
end
|
333
|
+
|
334
|
+
#
|
335
|
+
# Identify unknown faces from a person group.
|
336
|
+
#
|
337
|
+
# @param person_group_id [String] PersonGroupId of the target person group,
|
338
|
+
# created by PersonGroups.Create
|
339
|
+
# @param face_ids Array of query faces faceIds, created by the Face - Detect.
|
340
|
+
# Each of the faces are identified independently. The valid number of faceIds
|
341
|
+
# is between [1, 10].
|
342
|
+
# @param max_num_of_candidates_returned [Integer] The range of
|
343
|
+
# maxNumOfCandidatesReturned is between 1 and 5 (default is 1).
|
344
|
+
# @param confidence_threshold [Float] Confidence threshold of identification,
|
345
|
+
# used to judge whether one face belong to one person. The range of
|
346
|
+
# confidenceThreshold is [0, 1] (default specified by algorithm).
|
347
|
+
# @param [Hash{String => String}] A hash of custom headers that will be added
|
348
|
+
# to the HTTP request.
|
349
|
+
#
|
350
|
+
# @return [Concurrent::Promise] Promise object which holds the HTTP response.
|
351
|
+
#
|
352
|
+
def identify_async(person_group_id, face_ids, max_num_of_candidates_returned:1, confidence_threshold:nil, custom_headers:nil)
|
353
|
+
fail ArgumentError, '@client.azure_region is nil' if @client.azure_region.nil?
|
354
|
+
fail ArgumentError, 'person_group_id is nil' if person_group_id.nil?
|
355
|
+
fail ArgumentError, "'person_group_id' should satisfy the constraint - 'MaxLength': '64'" if !person_group_id.nil? && person_group_id.length > 64
|
356
|
+
fail ArgumentError, "'person_group_id' should satisfy the constraint - 'Pattern': '^[a-z0-9-_]+$'" if !person_group_id.nil? && person_group_id.match(Regexp.new('^^[a-z0-9-_]+$$')).nil?
|
357
|
+
fail ArgumentError, 'face_ids is nil' if face_ids.nil?
|
358
|
+
fail ArgumentError, "'face_ids' should satisfy the constraint - 'MaxItems': '10'" if !face_ids.nil? && face_ids.length > 10
|
359
|
+
fail ArgumentError, "'max_num_of_candidates_returned' should satisfy the constraint - 'InclusiveMaximum': '5'" if !max_num_of_candidates_returned.nil? && max_num_of_candidates_returned > 5
|
360
|
+
fail ArgumentError, "'max_num_of_candidates_returned' should satisfy the constraint - 'InclusiveMinimum': '1'" if !max_num_of_candidates_returned.nil? && max_num_of_candidates_returned < 1
|
361
|
+
|
362
|
+
body = IdentifyRequest.new
|
363
|
+
unless person_group_id.nil? && face_ids.nil? && max_num_of_candidates_returned.nil? && confidence_threshold.nil?
|
364
|
+
body.person_group_id = person_group_id
|
365
|
+
body.face_ids = face_ids
|
366
|
+
body.max_num_of_candidates_returned = max_num_of_candidates_returned
|
367
|
+
body.confidence_threshold = confidence_threshold
|
368
|
+
end
|
369
|
+
|
370
|
+
request_headers = {}
|
371
|
+
request_headers['Content-Type'] = 'application/json; charset=utf-8'
|
372
|
+
|
373
|
+
# Set Headers
|
374
|
+
request_headers['x-ms-client-request-id'] = SecureRandom.uuid
|
375
|
+
request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
|
376
|
+
|
377
|
+
# Serialize Request
|
378
|
+
request_mapper = Azure::CognitiveServices::Face::V1_0::Models::IdentifyRequest.mapper()
|
379
|
+
request_content = @client.serialize(request_mapper, body)
|
380
|
+
request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil
|
381
|
+
|
382
|
+
path_template = 'identify'
|
383
|
+
|
384
|
+
request_url = @base_url || @client.base_url
|
385
|
+
request_url = request_url.gsub('{AzureRegion}', @client.azure_region)
|
386
|
+
|
387
|
+
options = {
|
388
|
+
middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
|
389
|
+
body: request_content,
|
390
|
+
headers: request_headers.merge(custom_headers || {}),
|
391
|
+
base_url: request_url
|
392
|
+
}
|
393
|
+
promise = @client.make_request_async(:post, path_template, options)
|
394
|
+
|
395
|
+
promise = promise.then do |result|
|
396
|
+
http_response = result.response
|
397
|
+
status_code = http_response.status
|
398
|
+
response_content = http_response.body
|
399
|
+
unless status_code == 200
|
400
|
+
error_model = JSON.load(response_content)
|
401
|
+
fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
|
402
|
+
end
|
403
|
+
|
404
|
+
result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
|
405
|
+
# Deserialize Response
|
406
|
+
if status_code == 200
|
407
|
+
begin
|
408
|
+
parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
|
409
|
+
result_mapper = {
|
410
|
+
client_side_validation: true,
|
411
|
+
required: false,
|
412
|
+
serialized_name: 'parsed_response',
|
413
|
+
type: {
|
414
|
+
name: 'Sequence',
|
415
|
+
element: {
|
416
|
+
client_side_validation: true,
|
417
|
+
required: false,
|
418
|
+
serialized_name: 'IdentifyResultElementType',
|
419
|
+
type: {
|
420
|
+
name: 'Composite',
|
421
|
+
class_name: 'IdentifyResult'
|
422
|
+
}
|
423
|
+
}
|
424
|
+
}
|
425
|
+
}
|
426
|
+
result.body = @client.deserialize(result_mapper, parsed_response)
|
427
|
+
rescue Exception => e
|
428
|
+
fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
|
429
|
+
end
|
430
|
+
end
|
431
|
+
|
432
|
+
result
|
433
|
+
end
|
434
|
+
|
435
|
+
promise.execute
|
436
|
+
end
|
437
|
+
|
438
|
+
#
|
439
|
+
# Verify whether two faces belong to a same person or whether one face belongs
|
440
|
+
# to a person.
|
441
|
+
#
|
442
|
+
# @param face_id1 FaceId of the first face, comes from Face - Detect
|
443
|
+
# @param face_id2 FaceId of the second face, comes from Face - Detect
|
444
|
+
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
445
|
+
# will be added to the HTTP request.
|
446
|
+
#
|
447
|
+
# @return [VerifyResult] operation results.
|
448
|
+
#
|
449
|
+
def verify_face_to_face(face_id1, face_id2, custom_headers:nil)
|
450
|
+
response = verify_face_to_face_async(face_id1, face_id2, custom_headers:custom_headers).value!
|
451
|
+
response.body unless response.nil?
|
452
|
+
end
|
453
|
+
|
454
|
+
#
|
455
|
+
# Verify whether two faces belong to a same person or whether one face belongs
|
456
|
+
# to a person.
|
457
|
+
#
|
458
|
+
# @param face_id1 FaceId of the first face, comes from Face - Detect
|
459
|
+
# @param face_id2 FaceId of the second face, comes from Face - Detect
|
460
|
+
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
461
|
+
# will be added to the HTTP request.
|
462
|
+
#
|
463
|
+
# @return [MsRestAzure::AzureOperationResponse] HTTP response information.
|
464
|
+
#
|
465
|
+
def verify_face_to_face_with_http_info(face_id1, face_id2, custom_headers:nil)
|
466
|
+
verify_face_to_face_async(face_id1, face_id2, custom_headers:custom_headers).value!
|
467
|
+
end
|
468
|
+
|
469
|
+
#
|
470
|
+
# Verify whether two faces belong to a same person or whether one face belongs
|
471
|
+
# to a person.
|
472
|
+
#
|
473
|
+
# @param face_id1 FaceId of the first face, comes from Face - Detect
|
474
|
+
# @param face_id2 FaceId of the second face, comes from Face - Detect
|
475
|
+
# @param [Hash{String => String}] A hash of custom headers that will be added
|
476
|
+
# to the HTTP request.
|
477
|
+
#
|
478
|
+
# @return [Concurrent::Promise] Promise object which holds the HTTP response.
|
479
|
+
#
|
480
|
+
def verify_face_to_face_async(face_id1, face_id2, custom_headers:nil)
|
481
|
+
fail ArgumentError, '@client.azure_region is nil' if @client.azure_region.nil?
|
482
|
+
fail ArgumentError, 'face_id1 is nil' if face_id1.nil?
|
483
|
+
fail ArgumentError, 'face_id2 is nil' if face_id2.nil?
|
484
|
+
|
485
|
+
body = VerifyFaceToFaceRequest.new
|
486
|
+
unless face_id1.nil? && face_id2.nil?
|
487
|
+
body.face_id1 = face_id1
|
488
|
+
body.face_id2 = face_id2
|
489
|
+
end
|
490
|
+
|
491
|
+
request_headers = {}
|
492
|
+
request_headers['Content-Type'] = 'application/json; charset=utf-8'
|
493
|
+
|
494
|
+
# Set Headers
|
495
|
+
request_headers['x-ms-client-request-id'] = SecureRandom.uuid
|
496
|
+
request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
|
497
|
+
|
498
|
+
# Serialize Request
|
499
|
+
request_mapper = Azure::CognitiveServices::Face::V1_0::Models::VerifyFaceToFaceRequest.mapper()
|
500
|
+
request_content = @client.serialize(request_mapper, body)
|
501
|
+
request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil
|
502
|
+
|
503
|
+
path_template = 'verify'
|
504
|
+
|
505
|
+
request_url = @base_url || @client.base_url
|
506
|
+
request_url = request_url.gsub('{AzureRegion}', @client.azure_region)
|
507
|
+
|
508
|
+
options = {
|
509
|
+
middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
|
510
|
+
body: request_content,
|
511
|
+
headers: request_headers.merge(custom_headers || {}),
|
512
|
+
base_url: request_url
|
513
|
+
}
|
514
|
+
promise = @client.make_request_async(:post, path_template, options)
|
515
|
+
|
516
|
+
promise = promise.then do |result|
|
517
|
+
http_response = result.response
|
518
|
+
status_code = http_response.status
|
519
|
+
response_content = http_response.body
|
520
|
+
unless status_code == 200
|
521
|
+
error_model = JSON.load(response_content)
|
522
|
+
fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
|
523
|
+
end
|
524
|
+
|
525
|
+
result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
|
526
|
+
# Deserialize Response
|
527
|
+
if status_code == 200
|
528
|
+
begin
|
529
|
+
parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
|
530
|
+
result_mapper = Azure::CognitiveServices::Face::V1_0::Models::VerifyResult.mapper()
|
531
|
+
result.body = @client.deserialize(result_mapper, parsed_response)
|
532
|
+
rescue Exception => e
|
533
|
+
fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
|
534
|
+
end
|
535
|
+
end
|
536
|
+
|
537
|
+
result
|
538
|
+
end
|
539
|
+
|
540
|
+
promise.execute
|
541
|
+
end
|
542
|
+
|
543
|
+
#
|
544
|
+
# Detect human faces in an image and returns face locations, and optionally
|
545
|
+
# with faceIds, landmarks, and attributes.
|
546
|
+
#
|
547
|
+
# @param url [String]
|
548
|
+
# @param return_face_id [Boolean] A value indicating whether the operation
|
549
|
+
# should return faceIds of detected faces.
|
550
|
+
# @param return_face_landmarks [Boolean] A value indicating whether the
|
551
|
+
# operation should return landmarks of the detected faces.
|
552
|
+
# @param return_face_attributes [Array<FaceAttributeType>] Analyze and return
|
553
|
+
# the one or more specified face attributes in the comma-separated string like
|
554
|
+
# "returnFaceAttributes=age,gender". Supported face attributes include age,
|
555
|
+
# gender, headPose, smile, facialHair, glasses and emotion. Note that each face
|
556
|
+
# attribute analysis has additional computational and time cost.
|
557
|
+
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
558
|
+
# will be added to the HTTP request.
|
559
|
+
#
|
560
|
+
# @return [Array] operation results.
|
561
|
+
#
|
562
|
+
def detect_with_url(url, return_face_id:true, return_face_landmarks:false, return_face_attributes:nil, custom_headers:nil)
|
563
|
+
response = detect_with_url_async(url, return_face_id:return_face_id, return_face_landmarks:return_face_landmarks, return_face_attributes:return_face_attributes, custom_headers:custom_headers).value!
|
564
|
+
response.body unless response.nil?
|
565
|
+
end
|
566
|
+
|
567
|
+
#
|
568
|
+
# Detect human faces in an image and returns face locations, and optionally
|
569
|
+
# with faceIds, landmarks, and attributes.
|
570
|
+
#
|
571
|
+
# @param url [String]
|
572
|
+
# @param return_face_id [Boolean] A value indicating whether the operation
|
573
|
+
# should return faceIds of detected faces.
|
574
|
+
# @param return_face_landmarks [Boolean] A value indicating whether the
|
575
|
+
# operation should return landmarks of the detected faces.
|
576
|
+
# @param return_face_attributes [Array<FaceAttributeType>] Analyze and return
|
577
|
+
# the one or more specified face attributes in the comma-separated string like
|
578
|
+
# "returnFaceAttributes=age,gender". Supported face attributes include age,
|
579
|
+
# gender, headPose, smile, facialHair, glasses and emotion. Note that each face
|
580
|
+
# attribute analysis has additional computational and time cost.
|
581
|
+
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
582
|
+
# will be added to the HTTP request.
|
583
|
+
#
|
584
|
+
# @return [MsRestAzure::AzureOperationResponse] HTTP response information.
|
585
|
+
#
|
586
|
+
def detect_with_url_with_http_info(url, return_face_id:true, return_face_landmarks:false, return_face_attributes:nil, custom_headers:nil)
|
587
|
+
detect_with_url_async(url, return_face_id:return_face_id, return_face_landmarks:return_face_landmarks, return_face_attributes:return_face_attributes, custom_headers:custom_headers).value!
|
588
|
+
end
|
589
|
+
|
590
|
+
#
|
591
|
+
# Detect human faces in an image and returns face locations, and optionally
|
592
|
+
# with faceIds, landmarks, and attributes.
|
593
|
+
#
|
594
|
+
# @param url [String]
|
595
|
+
# @param return_face_id [Boolean] A value indicating whether the operation
|
596
|
+
# should return faceIds of detected faces.
|
597
|
+
# @param return_face_landmarks [Boolean] A value indicating whether the
|
598
|
+
# operation should return landmarks of the detected faces.
|
599
|
+
# @param return_face_attributes [Array<FaceAttributeType>] Analyze and return
|
600
|
+
# the one or more specified face attributes in the comma-separated string like
|
601
|
+
# "returnFaceAttributes=age,gender". Supported face attributes include age,
|
602
|
+
# gender, headPose, smile, facialHair, glasses and emotion. Note that each face
|
603
|
+
# attribute analysis has additional computational and time cost.
|
604
|
+
# @param [Hash{String => String}] A hash of custom headers that will be added
|
605
|
+
# to the HTTP request.
|
606
|
+
#
|
607
|
+
# @return [Concurrent::Promise] Promise object which holds the HTTP response.
|
608
|
+
#
|
609
|
+
def detect_with_url_async(url, return_face_id:true, return_face_landmarks:false, return_face_attributes:nil, custom_headers:nil)
|
610
|
+
fail ArgumentError, '@client.azure_region is nil' if @client.azure_region.nil?
|
611
|
+
fail ArgumentError, 'url is nil' if url.nil?
|
612
|
+
|
613
|
+
image_url = ImageUrl.new
|
614
|
+
unless url.nil?
|
615
|
+
image_url.url = url
|
616
|
+
end
|
617
|
+
|
618
|
+
request_headers = {}
|
619
|
+
request_headers['Content-Type'] = 'application/json; charset=utf-8'
|
620
|
+
|
621
|
+
# Set Headers
|
622
|
+
request_headers['x-ms-client-request-id'] = SecureRandom.uuid
|
623
|
+
request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
|
624
|
+
|
625
|
+
# Serialize Request
|
626
|
+
request_mapper = Azure::CognitiveServices::Face::V1_0::Models::ImageUrl.mapper()
|
627
|
+
request_content = @client.serialize(request_mapper, image_url)
|
628
|
+
request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil
|
629
|
+
|
630
|
+
path_template = 'detect'
|
631
|
+
|
632
|
+
request_url = @base_url || @client.base_url
|
633
|
+
request_url = request_url.gsub('{AzureRegion}', @client.azure_region)
|
634
|
+
|
635
|
+
options = {
|
636
|
+
middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
|
637
|
+
query_params: {'returnFaceId' => return_face_id,'returnFaceLandmarks' => return_face_landmarks,'returnFaceAttributes' => return_face_attributes.nil? ? nil : return_face_attributes.join(',')},
|
638
|
+
body: request_content,
|
639
|
+
headers: request_headers.merge(custom_headers || {}),
|
640
|
+
base_url: request_url
|
641
|
+
}
|
642
|
+
promise = @client.make_request_async(:post, path_template, options)
|
643
|
+
|
644
|
+
promise = promise.then do |result|
|
645
|
+
http_response = result.response
|
646
|
+
status_code = http_response.status
|
647
|
+
response_content = http_response.body
|
648
|
+
unless status_code == 200
|
649
|
+
error_model = JSON.load(response_content)
|
650
|
+
fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
|
651
|
+
end
|
652
|
+
|
653
|
+
result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
|
654
|
+
# Deserialize Response
|
655
|
+
if status_code == 200
|
656
|
+
begin
|
657
|
+
parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
|
658
|
+
result_mapper = {
|
659
|
+
client_side_validation: true,
|
660
|
+
required: false,
|
661
|
+
serialized_name: 'parsed_response',
|
662
|
+
type: {
|
663
|
+
name: 'Sequence',
|
664
|
+
element: {
|
665
|
+
client_side_validation: true,
|
666
|
+
required: false,
|
667
|
+
serialized_name: 'DetectedFaceElementType',
|
668
|
+
type: {
|
669
|
+
name: 'Composite',
|
670
|
+
class_name: 'DetectedFace'
|
671
|
+
}
|
672
|
+
}
|
673
|
+
}
|
674
|
+
}
|
675
|
+
result.body = @client.deserialize(result_mapper, parsed_response)
|
676
|
+
rescue Exception => e
|
677
|
+
fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
|
678
|
+
end
|
679
|
+
end
|
680
|
+
|
681
|
+
result
|
682
|
+
end
|
683
|
+
|
684
|
+
promise.execute
|
685
|
+
end
|
686
|
+
|
687
|
+
#
|
688
|
+
# Verify whether two faces belong to a same person. Compares a face Id with a
|
689
|
+
# Person Id
|
690
|
+
#
|
691
|
+
# @param face_id FaceId the face, comes from Face - Detect
|
692
|
+
# @param person_group_id [String] Using existing personGroupId and personId for
|
693
|
+
# fast loading a specified person. personGroupId is created in Person
|
694
|
+
# Groups.Create.
|
695
|
+
# @param person_id Specify a certain person in a person group. personId is
|
696
|
+
# created in Persons.Create.
|
697
|
+
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
698
|
+
# will be added to the HTTP request.
|
699
|
+
#
|
700
|
+
# @return [VerifyResult] operation results.
|
701
|
+
#
|
702
|
+
def verify_face_to_person(face_id, person_group_id, person_id, custom_headers:nil)
|
703
|
+
response = verify_face_to_person_async(face_id, person_group_id, person_id, custom_headers:custom_headers).value!
|
704
|
+
response.body unless response.nil?
|
705
|
+
end
|
706
|
+
|
707
|
+
#
|
708
|
+
# Verify whether two faces belong to a same person. Compares a face Id with a
|
709
|
+
# Person Id
|
710
|
+
#
|
711
|
+
# @param face_id FaceId the face, comes from Face - Detect
|
712
|
+
# @param person_group_id [String] Using existing personGroupId and personId for
|
713
|
+
# fast loading a specified person. personGroupId is created in Person
|
714
|
+
# Groups.Create.
|
715
|
+
# @param person_id Specify a certain person in a person group. personId is
|
716
|
+
# created in Persons.Create.
|
717
|
+
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
718
|
+
# will be added to the HTTP request.
|
719
|
+
#
|
720
|
+
# @return [MsRestAzure::AzureOperationResponse] HTTP response information.
|
721
|
+
#
|
722
|
+
def verify_face_to_person_with_http_info(face_id, person_group_id, person_id, custom_headers:nil)
|
723
|
+
verify_face_to_person_async(face_id, person_group_id, person_id, custom_headers:custom_headers).value!
|
724
|
+
end
|
725
|
+
|
726
|
+
#
|
727
|
+
# Verify whether two faces belong to a same person. Compares a face Id with a
|
728
|
+
# Person Id
|
729
|
+
#
|
730
|
+
# @param face_id FaceId the face, comes from Face - Detect
|
731
|
+
# @param person_group_id [String] Using existing personGroupId and personId for
|
732
|
+
# fast loading a specified person. personGroupId is created in Person
|
733
|
+
# Groups.Create.
|
734
|
+
# @param person_id Specify a certain person in a person group. personId is
|
735
|
+
# created in Persons.Create.
|
736
|
+
# @param [Hash{String => String}] A hash of custom headers that will be added
|
737
|
+
# to the HTTP request.
|
738
|
+
#
|
739
|
+
# @return [Concurrent::Promise] Promise object which holds the HTTP response.
|
740
|
+
#
|
741
|
+
def verify_face_to_person_async(face_id, person_group_id, person_id, custom_headers:nil)
|
742
|
+
fail ArgumentError, '@client.azure_region is nil' if @client.azure_region.nil?
|
743
|
+
fail ArgumentError, 'face_id is nil' if face_id.nil?
|
744
|
+
fail ArgumentError, 'person_group_id is nil' if person_group_id.nil?
|
745
|
+
fail ArgumentError, "'person_group_id' should satisfy the constraint - 'MaxLength': '64'" if !person_group_id.nil? && person_group_id.length > 64
|
746
|
+
fail ArgumentError, "'person_group_id' should satisfy the constraint - 'Pattern': '^[a-z0-9-_]+$'" if !person_group_id.nil? && person_group_id.match(Regexp.new('^^[a-z0-9-_]+$$')).nil?
|
747
|
+
fail ArgumentError, 'person_id is nil' if person_id.nil?
|
748
|
+
|
749
|
+
body = VerifyFaceToPersonRequest.new
|
750
|
+
unless face_id.nil? && person_group_id.nil? && person_id.nil?
|
751
|
+
body.face_id = face_id
|
752
|
+
body.person_group_id = person_group_id
|
753
|
+
body.person_id = person_id
|
754
|
+
end
|
755
|
+
|
756
|
+
request_headers = {}
|
757
|
+
request_headers['Content-Type'] = 'application/json; charset=utf-8'
|
758
|
+
|
759
|
+
# Set Headers
|
760
|
+
request_headers['x-ms-client-request-id'] = SecureRandom.uuid
|
761
|
+
request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
|
762
|
+
|
763
|
+
# Serialize Request
|
764
|
+
request_mapper = Azure::CognitiveServices::Face::V1_0::Models::VerifyFaceToPersonRequest.mapper()
|
765
|
+
request_content = @client.serialize(request_mapper, body)
|
766
|
+
request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil
|
767
|
+
|
768
|
+
path_template = 'verify'
|
769
|
+
|
770
|
+
request_url = @base_url || @client.base_url
|
771
|
+
request_url = request_url.gsub('{AzureRegion}', @client.azure_region)
|
772
|
+
|
773
|
+
options = {
|
774
|
+
middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
|
775
|
+
body: request_content,
|
776
|
+
headers: request_headers.merge(custom_headers || {}),
|
777
|
+
base_url: request_url
|
778
|
+
}
|
779
|
+
promise = @client.make_request_async(:post, path_template, options)
|
780
|
+
|
781
|
+
promise = promise.then do |result|
|
782
|
+
http_response = result.response
|
783
|
+
status_code = http_response.status
|
784
|
+
response_content = http_response.body
|
785
|
+
unless status_code == 200
|
786
|
+
error_model = JSON.load(response_content)
|
787
|
+
fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
|
788
|
+
end
|
789
|
+
|
790
|
+
result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
|
791
|
+
# Deserialize Response
|
792
|
+
if status_code == 200
|
793
|
+
begin
|
794
|
+
parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
|
795
|
+
result_mapper = Azure::CognitiveServices::Face::V1_0::Models::VerifyResult.mapper()
|
796
|
+
result.body = @client.deserialize(result_mapper, parsed_response)
|
797
|
+
rescue Exception => e
|
798
|
+
fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
|
799
|
+
end
|
800
|
+
end
|
801
|
+
|
802
|
+
result
|
803
|
+
end
|
804
|
+
|
805
|
+
promise.execute
|
806
|
+
end
|
807
|
+
|
808
|
+
#
|
809
|
+
# Detect human faces in an image and returns face locations, and optionally
|
810
|
+
# with faceIds, landmarks, and attributes.
|
811
|
+
#
|
812
|
+
# @param image An image stream.
|
813
|
+
# @param return_face_id [Boolean] A value indicating whether the operation
|
814
|
+
# should return faceIds of detected faces.
|
815
|
+
# @param return_face_landmarks [Boolean] A value indicating whether the
|
816
|
+
# operation should return landmarks of the detected faces.
|
817
|
+
# @param return_face_attributes [Array<FaceAttributeType>] Analyze and return
|
818
|
+
# the one or more specified face attributes in the comma-separated string like
|
819
|
+
# "returnFaceAttributes=age,gender". Supported face attributes include age,
|
820
|
+
# gender, headPose, smile, facialHair, glasses and emotion. Note that each face
|
821
|
+
# attribute analysis has additional computational and time cost.
|
822
|
+
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
823
|
+
# will be added to the HTTP request.
|
824
|
+
#
|
825
|
+
# @return [Array] operation results.
|
826
|
+
#
|
827
|
+
def detect_with_stream(image, return_face_id:true, return_face_landmarks:false, return_face_attributes:nil, custom_headers:nil)
|
828
|
+
response = detect_with_stream_async(image, return_face_id:return_face_id, return_face_landmarks:return_face_landmarks, return_face_attributes:return_face_attributes, custom_headers:custom_headers).value!
|
829
|
+
response.body unless response.nil?
|
830
|
+
end
|
831
|
+
|
832
|
+
#
|
833
|
+
# Detect human faces in an image and returns face locations, and optionally
|
834
|
+
# with faceIds, landmarks, and attributes.
|
835
|
+
#
|
836
|
+
# @param image An image stream.
|
837
|
+
# @param return_face_id [Boolean] A value indicating whether the operation
|
838
|
+
# should return faceIds of detected faces.
|
839
|
+
# @param return_face_landmarks [Boolean] A value indicating whether the
|
840
|
+
# operation should return landmarks of the detected faces.
|
841
|
+
# @param return_face_attributes [Array<FaceAttributeType>] Analyze and return
|
842
|
+
# the one or more specified face attributes in the comma-separated string like
|
843
|
+
# "returnFaceAttributes=age,gender". Supported face attributes include age,
|
844
|
+
# gender, headPose, smile, facialHair, glasses and emotion. Note that each face
|
845
|
+
# attribute analysis has additional computational and time cost.
|
846
|
+
# @param custom_headers [Hash{String => String}] A hash of custom headers that
|
847
|
+
# will be added to the HTTP request.
|
848
|
+
#
|
849
|
+
# @return [MsRestAzure::AzureOperationResponse] HTTP response information.
|
850
|
+
#
|
851
|
+
def detect_with_stream_with_http_info(image, return_face_id:true, return_face_landmarks:false, return_face_attributes:nil, custom_headers:nil)
|
852
|
+
detect_with_stream_async(image, return_face_id:return_face_id, return_face_landmarks:return_face_landmarks, return_face_attributes:return_face_attributes, custom_headers:custom_headers).value!
|
853
|
+
end
|
854
|
+
|
855
|
+
#
|
856
|
+
# Detect human faces in an image and returns face locations, and optionally
|
857
|
+
# with faceIds, landmarks, and attributes.
|
858
|
+
#
|
859
|
+
# @param image An image stream.
|
860
|
+
# @param return_face_id [Boolean] A value indicating whether the operation
|
861
|
+
# should return faceIds of detected faces.
|
862
|
+
# @param return_face_landmarks [Boolean] A value indicating whether the
|
863
|
+
# operation should return landmarks of the detected faces.
|
864
|
+
# @param return_face_attributes [Array<FaceAttributeType>] Analyze and return
|
865
|
+
# the one or more specified face attributes in the comma-separated string like
|
866
|
+
# "returnFaceAttributes=age,gender". Supported face attributes include age,
|
867
|
+
# gender, headPose, smile, facialHair, glasses and emotion. Note that each face
|
868
|
+
# attribute analysis has additional computational and time cost.
|
869
|
+
# @param [Hash{String => String}] A hash of custom headers that will be added
|
870
|
+
# to the HTTP request.
|
871
|
+
#
|
872
|
+
# @return [Concurrent::Promise] Promise object which holds the HTTP response.
|
873
|
+
#
|
874
|
+
def detect_with_stream_async(image, return_face_id:true, return_face_landmarks:false, return_face_attributes:nil, custom_headers:nil)
|
875
|
+
fail ArgumentError, '@client.azure_region is nil' if @client.azure_region.nil?
|
876
|
+
fail ArgumentError, 'image is nil' if image.nil?
|
877
|
+
|
878
|
+
|
879
|
+
request_headers = {}
|
880
|
+
request_headers['Content-Type'] = 'application/octet-stream'
|
881
|
+
|
882
|
+
# Set Headers
|
883
|
+
request_headers['x-ms-client-request-id'] = SecureRandom.uuid
|
884
|
+
request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
|
885
|
+
|
886
|
+
# Serialize Request
|
887
|
+
request_mapper = {
|
888
|
+
client_side_validation: true,
|
889
|
+
required: true,
|
890
|
+
serialized_name: 'Image',
|
891
|
+
type: {
|
892
|
+
name: 'Stream'
|
893
|
+
}
|
894
|
+
}
|
895
|
+
request_content = @client.serialize(request_mapper, image)
|
896
|
+
|
897
|
+
path_template = 'detect'
|
898
|
+
|
899
|
+
request_url = @base_url || @client.base_url
|
900
|
+
request_url = request_url.gsub('{AzureRegion}', @client.azure_region)
|
901
|
+
|
902
|
+
options = {
|
903
|
+
middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
|
904
|
+
query_params: {'returnFaceId' => return_face_id,'returnFaceLandmarks' => return_face_landmarks,'returnFaceAttributes' => return_face_attributes.nil? ? nil : return_face_attributes.join(',')},
|
905
|
+
body: request_content,
|
906
|
+
headers: request_headers.merge(custom_headers || {}),
|
907
|
+
base_url: request_url
|
908
|
+
}
|
909
|
+
promise = @client.make_request_async(:post, path_template, options)
|
910
|
+
|
911
|
+
promise = promise.then do |result|
|
912
|
+
http_response = result.response
|
913
|
+
status_code = http_response.status
|
914
|
+
response_content = http_response.body
|
915
|
+
unless status_code == 200
|
916
|
+
error_model = JSON.load(response_content)
|
917
|
+
fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
|
918
|
+
end
|
919
|
+
|
920
|
+
result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
|
921
|
+
# Deserialize Response
|
922
|
+
if status_code == 200
|
923
|
+
begin
|
924
|
+
parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
|
925
|
+
result_mapper = {
|
926
|
+
client_side_validation: true,
|
927
|
+
required: false,
|
928
|
+
serialized_name: 'parsed_response',
|
929
|
+
type: {
|
930
|
+
name: 'Sequence',
|
931
|
+
element: {
|
932
|
+
client_side_validation: true,
|
933
|
+
required: false,
|
934
|
+
serialized_name: 'DetectedFaceElementType',
|
935
|
+
type: {
|
936
|
+
name: 'Composite',
|
937
|
+
class_name: 'DetectedFace'
|
938
|
+
}
|
939
|
+
}
|
940
|
+
}
|
941
|
+
}
|
942
|
+
result.body = @client.deserialize(result_mapper, parsed_response)
|
943
|
+
rescue Exception => e
|
944
|
+
fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
|
945
|
+
end
|
946
|
+
end
|
947
|
+
|
948
|
+
result
|
949
|
+
end
|
950
|
+
|
951
|
+
promise.execute
|
952
|
+
end
|
953
|
+
|
954
|
+
end
|
955
|
+
end
|