class Azure::CognitiveServices::Face::V1_0::LargePersonGroupPerson

An API for face detection, verification, and identification.

Attributes

client[R]

@return [FaceClient] reference to the FaceClient

Private Class Methods

new(client) click to toggle source

Creates and initializes a new instance of the LargePersonGroupPerson class. @param client service class for accessing basic functionality.

# File lib/1.0/generated/azure_cognitiveservices_face/large_person_group_person.rb, line 17
def initialize(client)
  @client = client
end

Private Instance Methods

add_face_from_stream(large_person_group_id, person_id, image, user_data:nil, target_face:nil, detection_model:nil, custom_headers:nil) click to toggle source

Add a face to a person into a large person group for face identification or verification. To deal with an image contains multiple faces, input face can be specified as an image with a targetFace rectangle. It returns a persistedFaceId representing the added face. No image will be stored. Only the extracted face feature will be stored on server until [LargePersonGroup PersonFace - Delete](/docs/services/563879b61984550e40cbbe8d/operations/599ae2966ac60f11b48b5aa3), [LargePersonGroup Person - Delete](/docs/services/563879b61984550e40cbbe8d/operations/599ade5c6ac60f11b48b5aa2) or [LargePersonGroup - Delete](/docs/services/563879b61984550e40cbbe8d/operations/599adc216ac60f11b48b5a9f) is called. <br /> Note persistedFaceId is different from faceId generated by [Face - Detect](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395236).

  • Higher face image quality means better recognition precision. Please

consider high-quality faces: frontal, clear, and face size is 200x200 pixels (100 pixels between eyes) or bigger.

  • Each person entry can hold up to 248 faces.

  • JPEG, PNG, GIF (the first frame), and BMP format are supported. The allowed

image file size is from 1KB to 6MB.

  • “targetFace” rectangle should contain one face. Zero or multiple faces will

be regarded as an error. If the provided “targetFace” rectangle is not returned from [Face - Detect](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395236), there’s no guarantee to detect and add the face successfully.

  • Out of detectable face size (36x36 - 4096x4096 pixels), large head-pose, or

large occlusions will cause failures.

  • Adding/deleting faces to/from a same person will be processed sequentially.

Adding/deleting faces to/from different persons are processed in parallel.

  • The minimum detectable face size is 36x36 pixels in an image no larger than

1920x1080 pixels. Images with dimensions higher than 1920x1080 pixels will need a proportionally larger minimum face size.

  • Different 'detectionModel' values can be provided. To use and compare

different detection models, please refer to [How to specify a detection model](docs.microsoft.com/en-us/azure/cognitive-services/face/face-api-how-to-topics/specify-detection-model) | Model | Recommended use-case(s) | | ———- | ——– | | 'detection_01': | The default detection model for [LargePersonGroup Person

  • Add

Face](/docs/services/563879b61984550e40cbbe8d/operations/599adf2a3a7b9412a4d53f42). Recommend for near frontal face detection. For scenarios with exceptionally large angle (head-pose) faces, occluded faces or wrong image orientation, the faces in such cases may not be detected. | | 'detection_02': | Detection model released in 2019 May with improved accuracy especially on small, side and blurry faces. |

@param large_person_group_id [String] Id referencing a particular large person group. @param person_id Id referencing a particular person. @param image An image stream. @param user_data [String] User-specified data about the face for any purpose. The maximum length is 1KB. @param target_face [Array<Integer>] A face rectangle to specify the target face to be added to a person in the format of “targetFace=left,top,width,height”. E.g. “targetFace=10,10,100,100”. If there is more than one face in the image, targetFace is required to specify which face to add. No targetFace means there is only one face detected in the entire image. @param detection_model [DetectionModel] Name of detection model. Detection model is used to detect faces in the submitted image. A detection model name can be provided when performing Face - Detect or (Large)FaceList - Add Face or (Large)PersonGroup - Add Face. The default value is 'detection_01', if another model is needed, please explicitly specify it. Possible values include: 'detection_01', 'detection_02' @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [PersistedFace] operation results.

# File lib/1.0/generated/azure_cognitiveservices_face/large_person_group_person.rb, line 1255
def add_face_from_stream(large_person_group_id, person_id, image, user_data:nil, target_face:nil, detection_model:nil, custom_headers:nil)
  response = add_face_from_stream_async(large_person_group_id, person_id, image, user_data:user_data, target_face:target_face, detection_model:detection_model, custom_headers:custom_headers).value!
  response.body unless response.nil?
end
add_face_from_stream_async(large_person_group_id, person_id, image, user_data:nil, target_face:nil, detection_model:nil, custom_headers:nil) click to toggle source

Add a face to a person into a large person group for face identification or verification. To deal with an image contains multiple faces, input face can be specified as an image with a targetFace rectangle. It returns a persistedFaceId representing the added face. No image will be stored. Only the extracted face feature will be stored on server until [LargePersonGroup PersonFace - Delete](/docs/services/563879b61984550e40cbbe8d/operations/599ae2966ac60f11b48b5aa3), [LargePersonGroup Person - Delete](/docs/services/563879b61984550e40cbbe8d/operations/599ade5c6ac60f11b48b5aa2) or [LargePersonGroup - Delete](/docs/services/563879b61984550e40cbbe8d/operations/599adc216ac60f11b48b5a9f) is called. <br /> Note persistedFaceId is different from faceId generated by [Face - Detect](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395236).

  • Higher face image quality means better recognition precision. Please

consider high-quality faces: frontal, clear, and face size is 200x200 pixels (100 pixels between eyes) or bigger.

  • Each person entry can hold up to 248 faces.

  • JPEG, PNG, GIF (the first frame), and BMP format are supported. The allowed

image file size is from 1KB to 6MB.

  • “targetFace” rectangle should contain one face. Zero or multiple faces will

be regarded as an error. If the provided “targetFace” rectangle is not returned from [Face - Detect](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395236), there’s no guarantee to detect and add the face successfully.

  • Out of detectable face size (36x36 - 4096x4096 pixels), large head-pose, or

large occlusions will cause failures.

  • Adding/deleting faces to/from a same person will be processed sequentially.

Adding/deleting faces to/from different persons are processed in parallel.

  • The minimum detectable face size is 36x36 pixels in an image no larger than

1920x1080 pixels. Images with dimensions higher than 1920x1080 pixels will need a proportionally larger minimum face size.

  • Different 'detectionModel' values can be provided. To use and compare

different detection models, please refer to [How to specify a detection model](docs.microsoft.com/en-us/azure/cognitive-services/face/face-api-how-to-topics/specify-detection-model) | Model | Recommended use-case(s) | | ———- | ——– | | 'detection_01': | The default detection model for [LargePersonGroup Person

  • Add

Face](/docs/services/563879b61984550e40cbbe8d/operations/599adf2a3a7b9412a4d53f42). Recommend for near frontal face detection. For scenarios with exceptionally large angle (head-pose) faces, occluded faces or wrong image orientation, the faces in such cases may not be detected. | | 'detection_02': | Detection model released in 2019 May with improved accuracy especially on small, side and blurry faces. |

@param large_person_group_id [String] Id referencing a particular large person group. @param person_id Id referencing a particular person. @param image An image stream. @param user_data [String] User-specified data about the face for any purpose. The maximum length is 1KB. @param target_face [Array<Integer>] A face rectangle to specify the target face to be added to a person in the format of “targetFace=left,top,width,height”. E.g. “targetFace=10,10,100,100”. If there is more than one face in the image, targetFace is required to specify which face to add. No targetFace means there is only one face detected in the entire image. @param detection_model [DetectionModel] Name of detection model. Detection model is used to detect faces in the submitted image. A detection model name can be provided when performing Face - Detect or (Large)FaceList - Add Face or (Large)PersonGroup - Add Face. The default value is 'detection_01', if another model is needed, please explicitly specify it. Possible values include: 'detection_01', 'detection_02' @param [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [Concurrent::Promise] Promise object which holds the HTTP response.

# File lib/1.0/generated/azure_cognitiveservices_face/large_person_group_person.rb, line 1404
def add_face_from_stream_async(large_person_group_id, person_id, image, user_data:nil, target_face:nil, detection_model:nil, custom_headers:nil)
  fail ArgumentError, '@client.endpoint is nil' if @client.endpoint.nil?
  fail ArgumentError, 'large_person_group_id is nil' if large_person_group_id.nil?
  fail ArgumentError, "'large_person_group_id' should satisfy the constraint - 'MaxLength': '64'" if !large_person_group_id.nil? && large_person_group_id.length > 64
  fail ArgumentError, "'large_person_group_id' should satisfy the constraint - 'Pattern': '^[a-z0-9-_]+$'" if !large_person_group_id.nil? && large_person_group_id.match(Regexp.new('^^[a-z0-9-_]+$$')).nil?
  fail ArgumentError, 'person_id is nil' if person_id.nil?
  fail ArgumentError, "'user_data' should satisfy the constraint - 'MaxLength': '1024'" if !user_data.nil? && user_data.length > 1024
  fail ArgumentError, 'image is nil' if image.nil?


  request_headers = {}
  request_headers['Content-Type'] = 'application/octet-stream'

  # Set Headers
  request_headers['x-ms-client-request-id'] = SecureRandom.uuid
  request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?

  # Serialize Request
  request_mapper = {
    client_side_validation: true,
    required: true,
    serialized_name: 'Image',
    type: {
      name: 'Stream'
    }
  }
  request_content = @client.serialize(request_mapper,  image)

  path_template = 'largepersongroups/{largePersonGroupId}/persons/{personId}/persistedfaces'

  request_url = @base_url || @client.base_url
request_url = request_url.gsub('{Endpoint}', @client.endpoint)

  options = {
      middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
      path_params: {'largePersonGroupId' => large_person_group_id,'personId' => person_id},
      query_params: {'userData' => user_data,'targetFace' => target_face.nil? ? nil : target_face.join(','),'detectionModel' => detection_model},
      body: request_content,
      headers: request_headers.merge(custom_headers || {}),
      base_url: request_url
  }
  promise = @client.make_request_async(:post, path_template, options)

  promise = promise.then do |result|
    http_response = result.response
    status_code = http_response.status
    response_content = http_response.body
    unless status_code == 200
      error_model = JSON.load(response_content)
      fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
    end

    result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
    result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
    result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
    # Deserialize Response
    if status_code == 200
      begin
        parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
        result_mapper = Azure::CognitiveServices::Face::V1_0::Models::PersistedFace.mapper()
        result.body = @client.deserialize(result_mapper, parsed_response)
      rescue Exception => e
        fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
      end
    end

    result
  end

  promise.execute
end
add_face_from_stream_with_http_info(large_person_group_id, person_id, image, user_data:nil, target_face:nil, detection_model:nil, custom_headers:nil) click to toggle source

Add a face to a person into a large person group for face identification or verification. To deal with an image contains multiple faces, input face can be specified as an image with a targetFace rectangle. It returns a persistedFaceId representing the added face. No image will be stored. Only the extracted face feature will be stored on server until [LargePersonGroup PersonFace - Delete](/docs/services/563879b61984550e40cbbe8d/operations/599ae2966ac60f11b48b5aa3), [LargePersonGroup Person - Delete](/docs/services/563879b61984550e40cbbe8d/operations/599ade5c6ac60f11b48b5aa2) or [LargePersonGroup - Delete](/docs/services/563879b61984550e40cbbe8d/operations/599adc216ac60f11b48b5a9f) is called. <br /> Note persistedFaceId is different from faceId generated by [Face - Detect](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395236).

  • Higher face image quality means better recognition precision. Please

consider high-quality faces: frontal, clear, and face size is 200x200 pixels (100 pixels between eyes) or bigger.

  • Each person entry can hold up to 248 faces.

  • JPEG, PNG, GIF (the first frame), and BMP format are supported. The allowed

image file size is from 1KB to 6MB.

  • “targetFace” rectangle should contain one face. Zero or multiple faces will

be regarded as an error. If the provided “targetFace” rectangle is not returned from [Face - Detect](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395236), there’s no guarantee to detect and add the face successfully.

  • Out of detectable face size (36x36 - 4096x4096 pixels), large head-pose, or

large occlusions will cause failures.

  • Adding/deleting faces to/from a same person will be processed sequentially.

Adding/deleting faces to/from different persons are processed in parallel.

  • The minimum detectable face size is 36x36 pixels in an image no larger than

1920x1080 pixels. Images with dimensions higher than 1920x1080 pixels will need a proportionally larger minimum face size.

  • Different 'detectionModel' values can be provided. To use and compare

different detection models, please refer to [How to specify a detection model](docs.microsoft.com/en-us/azure/cognitive-services/face/face-api-how-to-topics/specify-detection-model) | Model | Recommended use-case(s) | | ———- | ——– | | 'detection_01': | The default detection model for [LargePersonGroup Person

  • Add

Face](/docs/services/563879b61984550e40cbbe8d/operations/599adf2a3a7b9412a4d53f42). Recommend for near frontal face detection. For scenarios with exceptionally large angle (head-pose) faces, occluded faces or wrong image orientation, the faces in such cases may not be detected. | | 'detection_02': | Detection model released in 2019 May with improved accuracy especially on small, side and blurry faces. |

@param large_person_group_id [String] Id referencing a particular large person group. @param person_id Id referencing a particular person. @param image An image stream. @param user_data [String] User-specified data about the face for any purpose. The maximum length is 1KB. @param target_face [Array<Integer>] A face rectangle to specify the target face to be added to a person in the format of “targetFace=left,top,width,height”. E.g. “targetFace=10,10,100,100”. If there is more than one face in the image, targetFace is required to specify which face to add. No targetFace means there is only one face detected in the entire image. @param detection_model [DetectionModel] Name of detection model. Detection model is used to detect faces in the submitted image. A detection model name can be provided when performing Face - Detect or (Large)FaceList - Add Face or (Large)PersonGroup - Add Face. The default value is 'detection_01', if another model is needed, please explicitly specify it. Possible values include: 'detection_01', 'detection_02' @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [MsRestAzure::AzureOperationResponse] HTTP response information.

# File lib/1.0/generated/azure_cognitiveservices_face/large_person_group_person.rb, line 1330
def add_face_from_stream_with_http_info(large_person_group_id, person_id, image, user_data:nil, target_face:nil, detection_model:nil, custom_headers:nil)
  add_face_from_stream_async(large_person_group_id, person_id, image, user_data:user_data, target_face:target_face, detection_model:detection_model, custom_headers:custom_headers).value!
end
add_face_from_url(large_person_group_id, person_id, url, user_data:nil, target_face:nil, detection_model:nil, custom_headers:nil) click to toggle source

Add a face to a person into a large person group for face identification or verification. To deal with an image contains multiple faces, input face can be specified as an image with a targetFace rectangle. It returns a persistedFaceId representing the added face. No image will be stored. Only the extracted face feature will be stored on server until [LargePersonGroup PersonFace - Delete](/docs/services/563879b61984550e40cbbe8d/operations/599ae2966ac60f11b48b5aa3), [LargePersonGroup Person - Delete](/docs/services/563879b61984550e40cbbe8d/operations/599ade5c6ac60f11b48b5aa2) or [LargePersonGroup - Delete](/docs/services/563879b61984550e40cbbe8d/operations/599adc216ac60f11b48b5a9f) is called. <br /> Note persistedFaceId is different from faceId generated by [Face - Detect](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395236).

  • Higher face image quality means better recognition precision. Please

consider high-quality faces: frontal, clear, and face size is 200x200 pixels (100 pixels between eyes) or bigger.

  • Each person entry can hold up to 248 faces.

  • JPEG, PNG, GIF (the first frame), and BMP format are supported. The allowed

image file size is from 1KB to 6MB.

  • “targetFace” rectangle should contain one face. Zero or multiple faces will

be regarded as an error. If the provided “targetFace” rectangle is not returned from [Face - Detect](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395236), there’s no guarantee to detect and add the face successfully.

  • Out of detectable face size (36x36 - 4096x4096 pixels), large head-pose, or

large occlusions will cause failures.

  • Adding/deleting faces to/from a same person will be processed sequentially.

Adding/deleting faces to/from different persons are processed in parallel.

  • The minimum detectable face size is 36x36 pixels in an image no larger than

1920x1080 pixels. Images with dimensions higher than 1920x1080 pixels will need a proportionally larger minimum face size.

  • Different 'detectionModel' values can be provided. To use and compare

different detection models, please refer to [How to specify a detection model](docs.microsoft.com/en-us/azure/cognitive-services/face/face-api-how-to-topics/specify-detection-model) | Model | Recommended use-case(s) | | ———- | ——– | | 'detection_01': | The default detection model for [LargePersonGroup Person

  • Add

Face](/docs/services/563879b61984550e40cbbe8d/operations/599adf2a3a7b9412a4d53f42). Recommend for near frontal face detection. For scenarios with exceptionally large angle (head-pose) faces, occluded faces or wrong image orientation, the faces in such cases may not be detected. | | 'detection_02': | Detection model released in 2019 May with improved accuracy especially on small, side and blurry faces. |

@param large_person_group_id [String] Id referencing a particular large person group. @param person_id Id referencing a particular person. @param url [String] Publicly reachable URL of an image @param user_data [String] User-specified data about the face for any purpose. The maximum length is 1KB. @param target_face [Array<Integer>] A face rectangle to specify the target face to be added to a person in the format of “targetFace=left,top,width,height”. E.g. “targetFace=10,10,100,100”. If there is more than one face in the image, targetFace is required to specify which face to add. No targetFace means there is only one face detected in the entire image. @param detection_model [DetectionModel] Name of detection model. Detection model is used to detect faces in the submitted image. A detection model name can be provided when performing Face - Detect or (Large)FaceList - Add Face or (Large)PersonGroup - Add Face. The default value is 'detection_01', if another model is needed, please explicitly specify it. Possible values include: 'detection_01', 'detection_02' @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [PersistedFace] operation results.

# File lib/1.0/generated/azure_cognitiveservices_face/large_person_group_person.rb, line 966
def add_face_from_url(large_person_group_id, person_id, url, user_data:nil, target_face:nil, detection_model:nil, custom_headers:nil)
  response = add_face_from_url_async(large_person_group_id, person_id, url, user_data:user_data, target_face:target_face, detection_model:detection_model, custom_headers:custom_headers).value!
  response.body unless response.nil?
end
add_face_from_url_async(large_person_group_id, person_id, url, user_data:nil, target_face:nil, detection_model:nil, custom_headers:nil) click to toggle source

Add a face to a person into a large person group for face identification or verification. To deal with an image contains multiple faces, input face can be specified as an image with a targetFace rectangle. It returns a persistedFaceId representing the added face. No image will be stored. Only the extracted face feature will be stored on server until [LargePersonGroup PersonFace - Delete](/docs/services/563879b61984550e40cbbe8d/operations/599ae2966ac60f11b48b5aa3), [LargePersonGroup Person - Delete](/docs/services/563879b61984550e40cbbe8d/operations/599ade5c6ac60f11b48b5aa2) or [LargePersonGroup - Delete](/docs/services/563879b61984550e40cbbe8d/operations/599adc216ac60f11b48b5a9f) is called. <br /> Note persistedFaceId is different from faceId generated by [Face - Detect](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395236).

  • Higher face image quality means better recognition precision. Please

consider high-quality faces: frontal, clear, and face size is 200x200 pixels (100 pixels between eyes) or bigger.

  • Each person entry can hold up to 248 faces.

  • JPEG, PNG, GIF (the first frame), and BMP format are supported. The allowed

image file size is from 1KB to 6MB.

  • “targetFace” rectangle should contain one face. Zero or multiple faces will

be regarded as an error. If the provided “targetFace” rectangle is not returned from [Face - Detect](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395236), there’s no guarantee to detect and add the face successfully.

  • Out of detectable face size (36x36 - 4096x4096 pixels), large head-pose, or

large occlusions will cause failures.

  • Adding/deleting faces to/from a same person will be processed sequentially.

Adding/deleting faces to/from different persons are processed in parallel.

  • The minimum detectable face size is 36x36 pixels in an image no larger than

1920x1080 pixels. Images with dimensions higher than 1920x1080 pixels will need a proportionally larger minimum face size.

  • Different 'detectionModel' values can be provided. To use and compare

different detection models, please refer to [How to specify a detection model](docs.microsoft.com/en-us/azure/cognitive-services/face/face-api-how-to-topics/specify-detection-model) | Model | Recommended use-case(s) | | ———- | ——– | | 'detection_01': | The default detection model for [LargePersonGroup Person

  • Add

Face](/docs/services/563879b61984550e40cbbe8d/operations/599adf2a3a7b9412a4d53f42). Recommend for near frontal face detection. For scenarios with exceptionally large angle (head-pose) faces, occluded faces or wrong image orientation, the faces in such cases may not be detected. | | 'detection_02': | Detection model released in 2019 May with improved accuracy especially on small, side and blurry faces. |

@param large_person_group_id [String] Id referencing a particular large person group. @param person_id Id referencing a particular person. @param url [String] Publicly reachable URL of an image @param user_data [String] User-specified data about the face for any purpose. The maximum length is 1KB. @param target_face [Array<Integer>] A face rectangle to specify the target face to be added to a person in the format of “targetFace=left,top,width,height”. E.g. “targetFace=10,10,100,100”. If there is more than one face in the image, targetFace is required to specify which face to add. No targetFace means there is only one face detected in the entire image. @param detection_model [DetectionModel] Name of detection model. Detection model is used to detect faces in the submitted image. A detection model name can be provided when performing Face - Detect or (Large)FaceList - Add Face or (Large)PersonGroup - Add Face. The default value is 'detection_01', if another model is needed, please explicitly specify it. Possible values include: 'detection_01', 'detection_02' @param [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [Concurrent::Promise] Promise object which holds the HTTP response.

# File lib/1.0/generated/azure_cognitiveservices_face/large_person_group_person.rb, line 1115
def add_face_from_url_async(large_person_group_id, person_id, url, user_data:nil, target_face:nil, detection_model:nil, custom_headers:nil)
  fail ArgumentError, '@client.endpoint is nil' if @client.endpoint.nil?
  fail ArgumentError, 'large_person_group_id is nil' if large_person_group_id.nil?
  fail ArgumentError, "'large_person_group_id' should satisfy the constraint - 'MaxLength': '64'" if !large_person_group_id.nil? && large_person_group_id.length > 64
  fail ArgumentError, "'large_person_group_id' should satisfy the constraint - 'Pattern': '^[a-z0-9-_]+$'" if !large_person_group_id.nil? && large_person_group_id.match(Regexp.new('^^[a-z0-9-_]+$$')).nil?
  fail ArgumentError, 'person_id is nil' if person_id.nil?
  fail ArgumentError, "'user_data' should satisfy the constraint - 'MaxLength': '1024'" if !user_data.nil? && user_data.length > 1024
  fail ArgumentError, 'url is nil' if url.nil?

  image_url = ImageUrl.new
  unless url.nil?
    image_url.url = url
  end

  request_headers = {}
  request_headers['Content-Type'] = 'application/json; charset=utf-8'

  # Set Headers
  request_headers['x-ms-client-request-id'] = SecureRandom.uuid
  request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?

  # Serialize Request
  request_mapper = Azure::CognitiveServices::Face::V1_0::Models::ImageUrl.mapper()
  request_content = @client.serialize(request_mapper,  image_url)
  request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil

  path_template = 'largepersongroups/{largePersonGroupId}/persons/{personId}/persistedfaces'

  request_url = @base_url || @client.base_url
request_url = request_url.gsub('{Endpoint}', @client.endpoint)

  options = {
      middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
      path_params: {'largePersonGroupId' => large_person_group_id,'personId' => person_id},
      query_params: {'userData' => user_data,'targetFace' => target_face.nil? ? nil : target_face.join(','),'detectionModel' => detection_model},
      body: request_content,
      headers: request_headers.merge(custom_headers || {}),
      base_url: request_url
  }
  promise = @client.make_request_async(:post, path_template, options)

  promise = promise.then do |result|
    http_response = result.response
    status_code = http_response.status
    response_content = http_response.body
    unless status_code == 200
      error_model = JSON.load(response_content)
      fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
    end

    result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
    result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
    result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
    # Deserialize Response
    if status_code == 200
      begin
        parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
        result_mapper = Azure::CognitiveServices::Face::V1_0::Models::PersistedFace.mapper()
        result.body = @client.deserialize(result_mapper, parsed_response)
      rescue Exception => e
        fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
      end
    end

    result
  end

  promise.execute
end
add_face_from_url_with_http_info(large_person_group_id, person_id, url, user_data:nil, target_face:nil, detection_model:nil, custom_headers:nil) click to toggle source

Add a face to a person into a large person group for face identification or verification. To deal with an image contains multiple faces, input face can be specified as an image with a targetFace rectangle. It returns a persistedFaceId representing the added face. No image will be stored. Only the extracted face feature will be stored on server until [LargePersonGroup PersonFace - Delete](/docs/services/563879b61984550e40cbbe8d/operations/599ae2966ac60f11b48b5aa3), [LargePersonGroup Person - Delete](/docs/services/563879b61984550e40cbbe8d/operations/599ade5c6ac60f11b48b5aa2) or [LargePersonGroup - Delete](/docs/services/563879b61984550e40cbbe8d/operations/599adc216ac60f11b48b5a9f) is called. <br /> Note persistedFaceId is different from faceId generated by [Face - Detect](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395236).

  • Higher face image quality means better recognition precision. Please

consider high-quality faces: frontal, clear, and face size is 200x200 pixels (100 pixels between eyes) or bigger.

  • Each person entry can hold up to 248 faces.

  • JPEG, PNG, GIF (the first frame), and BMP format are supported. The allowed

image file size is from 1KB to 6MB.

  • “targetFace” rectangle should contain one face. Zero or multiple faces will

be regarded as an error. If the provided “targetFace” rectangle is not returned from [Face - Detect](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395236), there’s no guarantee to detect and add the face successfully.

  • Out of detectable face size (36x36 - 4096x4096 pixels), large head-pose, or

large occlusions will cause failures.

  • Adding/deleting faces to/from a same person will be processed sequentially.

Adding/deleting faces to/from different persons are processed in parallel.

  • The minimum detectable face size is 36x36 pixels in an image no larger than

1920x1080 pixels. Images with dimensions higher than 1920x1080 pixels will need a proportionally larger minimum face size.

  • Different 'detectionModel' values can be provided. To use and compare

different detection models, please refer to [How to specify a detection model](docs.microsoft.com/en-us/azure/cognitive-services/face/face-api-how-to-topics/specify-detection-model) | Model | Recommended use-case(s) | | ———- | ——– | | 'detection_01': | The default detection model for [LargePersonGroup Person

  • Add

Face](/docs/services/563879b61984550e40cbbe8d/operations/599adf2a3a7b9412a4d53f42). Recommend for near frontal face detection. For scenarios with exceptionally large angle (head-pose) faces, occluded faces or wrong image orientation, the faces in such cases may not be detected. | | 'detection_02': | Detection model released in 2019 May with improved accuracy especially on small, side and blurry faces. |

@param large_person_group_id [String] Id referencing a particular large person group. @param person_id Id referencing a particular person. @param url [String] Publicly reachable URL of an image @param user_data [String] User-specified data about the face for any purpose. The maximum length is 1KB. @param target_face [Array<Integer>] A face rectangle to specify the target face to be added to a person in the format of “targetFace=left,top,width,height”. E.g. “targetFace=10,10,100,100”. If there is more than one face in the image, targetFace is required to specify which face to add. No targetFace means there is only one face detected in the entire image. @param detection_model [DetectionModel] Name of detection model. Detection model is used to detect faces in the submitted image. A detection model name can be provided when performing Face - Detect or (Large)FaceList - Add Face or (Large)PersonGroup - Add Face. The default value is 'detection_01', if another model is needed, please explicitly specify it. Possible values include: 'detection_01', 'detection_02' @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [MsRestAzure::AzureOperationResponse] HTTP response information.

# File lib/1.0/generated/azure_cognitiveservices_face/large_person_group_person.rb, line 1041
def add_face_from_url_with_http_info(large_person_group_id, person_id, url, user_data:nil, target_face:nil, detection_model:nil, custom_headers:nil)
  add_face_from_url_async(large_person_group_id, person_id, url, user_data:user_data, target_face:target_face, detection_model:detection_model, custom_headers:custom_headers).value!
end
create(large_person_group_id, name:nil, user_data:nil, custom_headers:nil) click to toggle source

Create a new person in a specified large person group.

@param large_person_group_id [String] Id referencing a particular large person group. @param name [String] User defined name, maximum length is 128. @param user_data [String] User specified data. Length should not exceed 16KB. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [Person] operation results.

# File lib/1.0/generated/azure_cognitiveservices_face/large_person_group_person.rb, line 36
def create(large_person_group_id, name:nil, user_data:nil, custom_headers:nil)
  response = create_async(large_person_group_id, name:name, user_data:user_data, custom_headers:custom_headers).value!
  response.body unless response.nil?
end
create_async(large_person_group_id, name:nil, user_data:nil, custom_headers:nil) click to toggle source

Create a new person in a specified large person group.

@param large_person_group_id [String] Id referencing a particular large person group. @param name [String] User defined name, maximum length is 128. @param user_data [String] User specified data. Length should not exceed 16KB. @param [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [Concurrent::Promise] Promise object which holds the HTTP response.

# File lib/1.0/generated/azure_cognitiveservices_face/large_person_group_person.rb, line 69
def create_async(large_person_group_id, name:nil, user_data:nil, custom_headers:nil)
  fail ArgumentError, '@client.endpoint is nil' if @client.endpoint.nil?
  fail ArgumentError, 'large_person_group_id is nil' if large_person_group_id.nil?
  fail ArgumentError, "'large_person_group_id' should satisfy the constraint - 'MaxLength': '64'" if !large_person_group_id.nil? && large_person_group_id.length > 64
  fail ArgumentError, "'large_person_group_id' should satisfy the constraint - 'Pattern': '^[a-z0-9-_]+$'" if !large_person_group_id.nil? && large_person_group_id.match(Regexp.new('^^[a-z0-9-_]+$$')).nil?
  fail ArgumentError, "'name' should satisfy the constraint - 'MaxLength': '128'" if !name.nil? && name.length > 128
  fail ArgumentError, "'user_data' should satisfy the constraint - 'MaxLength': '16384'" if !user_data.nil? && user_data.length > 16384

  body = NameAndUserDataContract.new
  unless name.nil? && user_data.nil?
    body.name = name
    body.user_data = user_data
  end

  request_headers = {}
  request_headers['Content-Type'] = 'application/json; charset=utf-8'

  # Set Headers
  request_headers['x-ms-client-request-id'] = SecureRandom.uuid
  request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?

  # Serialize Request
  request_mapper = Azure::CognitiveServices::Face::V1_0::Models::NameAndUserDataContract.mapper()
  request_content = @client.serialize(request_mapper,  body)
  request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil

  path_template = 'largepersongroups/{largePersonGroupId}/persons'

  request_url = @base_url || @client.base_url
request_url = request_url.gsub('{Endpoint}', @client.endpoint)

  options = {
      middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
      path_params: {'largePersonGroupId' => large_person_group_id},
      body: request_content,
      headers: request_headers.merge(custom_headers || {}),
      base_url: request_url
  }
  promise = @client.make_request_async(:post, path_template, options)

  promise = promise.then do |result|
    http_response = result.response
    status_code = http_response.status
    response_content = http_response.body
    unless status_code == 200
      error_model = JSON.load(response_content)
      fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
    end

    result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
    result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
    result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
    # Deserialize Response
    if status_code == 200
      begin
        parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
        result_mapper = Azure::CognitiveServices::Face::V1_0::Models::Person.mapper()
        result.body = @client.deserialize(result_mapper, parsed_response)
      rescue Exception => e
        fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
      end
    end

    result
  end

  promise.execute
end
create_with_http_info(large_person_group_id, name:nil, user_data:nil, custom_headers:nil) click to toggle source

Create a new person in a specified large person group.

@param large_person_group_id [String] Id referencing a particular large person group. @param name [String] User defined name, maximum length is 128. @param user_data [String] User specified data. Length should not exceed 16KB. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [MsRestAzure::AzureOperationResponse] HTTP response information.

# File lib/1.0/generated/azure_cognitiveservices_face/large_person_group_person.rb, line 53
def create_with_http_info(large_person_group_id, name:nil, user_data:nil, custom_headers:nil)
  create_async(large_person_group_id, name:name, user_data:user_data, custom_headers:custom_headers).value!
end
delete(large_person_group_id, person_id, custom_headers:nil) click to toggle source

Delete an existing person from a large person group. The persistedFaceId, userData, person name and face feature in the person entry will all be deleted.

@param large_person_group_id [String] Id referencing a particular large person group. @param person_id Id referencing a particular person. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

# File lib/1.0/generated/azure_cognitiveservices_face/large_person_group_person.rb, line 281
def delete(large_person_group_id, person_id, custom_headers:nil)
  response = delete_async(large_person_group_id, person_id, custom_headers:custom_headers).value!
  nil
end
delete_async(large_person_group_id, person_id, custom_headers:nil) click to toggle source

Delete an existing person from a large person group. The persistedFaceId, userData, person name and face feature in the person entry will all be deleted.

@param large_person_group_id [String] Id referencing a particular large person group. @param person_id Id referencing a particular person. @param [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [Concurrent::Promise] Promise object which holds the HTTP response.

# File lib/1.0/generated/azure_cognitiveservices_face/large_person_group_person.rb, line 316
def delete_async(large_person_group_id, person_id, custom_headers:nil)
  fail ArgumentError, '@client.endpoint is nil' if @client.endpoint.nil?
  fail ArgumentError, 'large_person_group_id is nil' if large_person_group_id.nil?
  fail ArgumentError, "'large_person_group_id' should satisfy the constraint - 'MaxLength': '64'" if !large_person_group_id.nil? && large_person_group_id.length > 64
  fail ArgumentError, "'large_person_group_id' should satisfy the constraint - 'Pattern': '^[a-z0-9-_]+$'" if !large_person_group_id.nil? && large_person_group_id.match(Regexp.new('^^[a-z0-9-_]+$$')).nil?
  fail ArgumentError, 'person_id is nil' if person_id.nil?


  request_headers = {}
  request_headers['Content-Type'] = 'application/json; charset=utf-8'

  # Set Headers
  request_headers['x-ms-client-request-id'] = SecureRandom.uuid
  request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
  path_template = 'largepersongroups/{largePersonGroupId}/persons/{personId}'

  request_url = @base_url || @client.base_url
request_url = request_url.gsub('{Endpoint}', @client.endpoint)

  options = {
      middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
      path_params: {'largePersonGroupId' => large_person_group_id,'personId' => person_id},
      headers: request_headers.merge(custom_headers || {}),
      base_url: request_url
  }
  promise = @client.make_request_async(:delete, path_template, options)

  promise = promise.then do |result|
    http_response = result.response
    status_code = http_response.status
    response_content = http_response.body
    unless status_code == 200
      error_model = JSON.load(response_content)
      fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
    end

    result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
    result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
    result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?

    result
  end

  promise.execute
end
delete_face(large_person_group_id, person_id, persisted_face_id, custom_headers:nil) click to toggle source

Delete a face from a person in a large person group by specified largePersonGroupId, personId and persistedFaceId. <br /> Adding/deleting faces to/from a same person will be processed sequentially. Adding/deleting faces to/from different persons are processed in parallel.

@param large_person_group_id [String] Id referencing a particular large person group. @param person_id Id referencing a particular person. @param persisted_face_id Id referencing a particular persistedFaceId of an existing face. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

# File lib/1.0/generated/azure_cognitiveservices_face/large_person_group_person.rb, line 586
def delete_face(large_person_group_id, person_id, persisted_face_id, custom_headers:nil)
  response = delete_face_async(large_person_group_id, person_id, persisted_face_id, custom_headers:custom_headers).value!
  nil
end
delete_face_async(large_person_group_id, person_id, persisted_face_id, custom_headers:nil) click to toggle source

Delete a face from a person in a large person group by specified largePersonGroupId, personId and persistedFaceId. <br /> Adding/deleting faces to/from a same person will be processed sequentially. Adding/deleting faces to/from different persons are processed in parallel.

@param large_person_group_id [String] Id referencing a particular large person group. @param person_id Id referencing a particular person. @param persisted_face_id Id referencing a particular persistedFaceId of an existing face. @param [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [Concurrent::Promise] Promise object which holds the HTTP response.

# File lib/1.0/generated/azure_cognitiveservices_face/large_person_group_person.rb, line 629
def delete_face_async(large_person_group_id, person_id, persisted_face_id, custom_headers:nil)
  fail ArgumentError, '@client.endpoint is nil' if @client.endpoint.nil?
  fail ArgumentError, 'large_person_group_id is nil' if large_person_group_id.nil?
  fail ArgumentError, "'large_person_group_id' should satisfy the constraint - 'MaxLength': '64'" if !large_person_group_id.nil? && large_person_group_id.length > 64
  fail ArgumentError, "'large_person_group_id' should satisfy the constraint - 'Pattern': '^[a-z0-9-_]+$'" if !large_person_group_id.nil? && large_person_group_id.match(Regexp.new('^^[a-z0-9-_]+$$')).nil?
  fail ArgumentError, 'person_id is nil' if person_id.nil?
  fail ArgumentError, 'persisted_face_id is nil' if persisted_face_id.nil?


  request_headers = {}
  request_headers['Content-Type'] = 'application/json; charset=utf-8'

  # Set Headers
  request_headers['x-ms-client-request-id'] = SecureRandom.uuid
  request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
  path_template = 'largepersongroups/{largePersonGroupId}/persons/{personId}/persistedfaces/{persistedFaceId}'

  request_url = @base_url || @client.base_url
request_url = request_url.gsub('{Endpoint}', @client.endpoint)

  options = {
      middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
      path_params: {'largePersonGroupId' => large_person_group_id,'personId' => person_id,'persistedFaceId' => persisted_face_id},
      headers: request_headers.merge(custom_headers || {}),
      base_url: request_url
  }
  promise = @client.make_request_async(:delete, path_template, options)

  promise = promise.then do |result|
    http_response = result.response
    status_code = http_response.status
    response_content = http_response.body
    unless status_code == 200
      error_model = JSON.load(response_content)
      fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
    end

    result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
    result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
    result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?

    result
  end

  promise.execute
end
delete_face_with_http_info(large_person_group_id, person_id, persisted_face_id, custom_headers:nil) click to toggle source

Delete a face from a person in a large person group by specified largePersonGroupId, personId and persistedFaceId. <br /> Adding/deleting faces to/from a same person will be processed sequentially. Adding/deleting faces to/from different persons are processed in parallel.

@param large_person_group_id [String] Id referencing a particular large person group. @param person_id Id referencing a particular person. @param persisted_face_id Id referencing a particular persistedFaceId of an existing face. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [MsRestAzure::AzureOperationResponse] HTTP response information.

# File lib/1.0/generated/azure_cognitiveservices_face/large_person_group_person.rb, line 608
def delete_face_with_http_info(large_person_group_id, person_id, persisted_face_id, custom_headers:nil)
  delete_face_async(large_person_group_id, person_id, persisted_face_id, custom_headers:custom_headers).value!
end
delete_with_http_info(large_person_group_id, person_id, custom_headers:nil) click to toggle source

Delete an existing person from a large person group. The persistedFaceId, userData, person name and face feature in the person entry will all be deleted.

@param large_person_group_id [String] Id referencing a particular large person group. @param person_id Id referencing a particular person. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [MsRestAzure::AzureOperationResponse] HTTP response information.

# File lib/1.0/generated/azure_cognitiveservices_face/large_person_group_person.rb, line 299
def delete_with_http_info(large_person_group_id, person_id, custom_headers:nil)
  delete_async(large_person_group_id, person_id, custom_headers:custom_headers).value!
end
get(large_person_group_id, person_id, custom_headers:nil) click to toggle source

Retrieve a person's name and userData, and the persisted faceIds representing the registered person face feature.

@param large_person_group_id [String] Id referencing a particular large person group. @param person_id Id referencing a particular person. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [Person] operation results.

# File lib/1.0/generated/azure_cognitiveservices_face/large_person_group_person.rb, line 374
def get(large_person_group_id, person_id, custom_headers:nil)
  response = get_async(large_person_group_id, person_id, custom_headers:custom_headers).value!
  response.body unless response.nil?
end
get_async(large_person_group_id, person_id, custom_headers:nil) click to toggle source

Retrieve a person's name and userData, and the persisted faceIds representing the registered person face feature.

@param large_person_group_id [String] Id referencing a particular large person group. @param person_id Id referencing a particular person. @param [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [Concurrent::Promise] Promise object which holds the HTTP response.

# File lib/1.0/generated/azure_cognitiveservices_face/large_person_group_person.rb, line 407
def get_async(large_person_group_id, person_id, custom_headers:nil)
  fail ArgumentError, '@client.endpoint is nil' if @client.endpoint.nil?
  fail ArgumentError, 'large_person_group_id is nil' if large_person_group_id.nil?
  fail ArgumentError, "'large_person_group_id' should satisfy the constraint - 'MaxLength': '64'" if !large_person_group_id.nil? && large_person_group_id.length > 64
  fail ArgumentError, "'large_person_group_id' should satisfy the constraint - 'Pattern': '^[a-z0-9-_]+$'" if !large_person_group_id.nil? && large_person_group_id.match(Regexp.new('^^[a-z0-9-_]+$$')).nil?
  fail ArgumentError, 'person_id is nil' if person_id.nil?


  request_headers = {}
  request_headers['Content-Type'] = 'application/json; charset=utf-8'

  # Set Headers
  request_headers['x-ms-client-request-id'] = SecureRandom.uuid
  request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
  path_template = 'largepersongroups/{largePersonGroupId}/persons/{personId}'

  request_url = @base_url || @client.base_url
request_url = request_url.gsub('{Endpoint}', @client.endpoint)

  options = {
      middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
      path_params: {'largePersonGroupId' => large_person_group_id,'personId' => person_id},
      headers: request_headers.merge(custom_headers || {}),
      base_url: request_url
  }
  promise = @client.make_request_async(:get, path_template, options)

  promise = promise.then do |result|
    http_response = result.response
    status_code = http_response.status
    response_content = http_response.body
    unless status_code == 200
      error_model = JSON.load(response_content)
      fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
    end

    result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
    result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
    result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
    # Deserialize Response
    if status_code == 200
      begin
        parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
        result_mapper = Azure::CognitiveServices::Face::V1_0::Models::Person.mapper()
        result.body = @client.deserialize(result_mapper, parsed_response)
      rescue Exception => e
        fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
      end
    end

    result
  end

  promise.execute
end
get_face(large_person_group_id, person_id, persisted_face_id, custom_headers:nil) click to toggle source

Retrieve information about a persisted face (specified by persistedFaceId, personId and its belonging largePersonGroupId).

@param large_person_group_id [String] Id referencing a particular large person group. @param person_id Id referencing a particular person. @param persisted_face_id Id referencing a particular persistedFaceId of an existing face. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [PersistedFace] operation results.

# File lib/1.0/generated/azure_cognitiveservices_face/large_person_group_person.rb, line 690
def get_face(large_person_group_id, person_id, persisted_face_id, custom_headers:nil)
  response = get_face_async(large_person_group_id, person_id, persisted_face_id, custom_headers:custom_headers).value!
  response.body unless response.nil?
end
get_face_async(large_person_group_id, person_id, persisted_face_id, custom_headers:nil) click to toggle source

Retrieve information about a persisted face (specified by persistedFaceId, personId and its belonging largePersonGroupId).

@param large_person_group_id [String] Id referencing a particular large person group. @param person_id Id referencing a particular person. @param persisted_face_id Id referencing a particular persistedFaceId of an existing face. @param [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [Concurrent::Promise] Promise object which holds the HTTP response.

# File lib/1.0/generated/azure_cognitiveservices_face/large_person_group_person.rb, line 727
def get_face_async(large_person_group_id, person_id, persisted_face_id, custom_headers:nil)
  fail ArgumentError, '@client.endpoint is nil' if @client.endpoint.nil?
  fail ArgumentError, 'large_person_group_id is nil' if large_person_group_id.nil?
  fail ArgumentError, "'large_person_group_id' should satisfy the constraint - 'MaxLength': '64'" if !large_person_group_id.nil? && large_person_group_id.length > 64
  fail ArgumentError, "'large_person_group_id' should satisfy the constraint - 'Pattern': '^[a-z0-9-_]+$'" if !large_person_group_id.nil? && large_person_group_id.match(Regexp.new('^^[a-z0-9-_]+$$')).nil?
  fail ArgumentError, 'person_id is nil' if person_id.nil?
  fail ArgumentError, 'persisted_face_id is nil' if persisted_face_id.nil?


  request_headers = {}
  request_headers['Content-Type'] = 'application/json; charset=utf-8'

  # Set Headers
  request_headers['x-ms-client-request-id'] = SecureRandom.uuid
  request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
  path_template = 'largepersongroups/{largePersonGroupId}/persons/{personId}/persistedfaces/{persistedFaceId}'

  request_url = @base_url || @client.base_url
request_url = request_url.gsub('{Endpoint}', @client.endpoint)

  options = {
      middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
      path_params: {'largePersonGroupId' => large_person_group_id,'personId' => person_id,'persistedFaceId' => persisted_face_id},
      headers: request_headers.merge(custom_headers || {}),
      base_url: request_url
  }
  promise = @client.make_request_async(:get, path_template, options)

  promise = promise.then do |result|
    http_response = result.response
    status_code = http_response.status
    response_content = http_response.body
    unless status_code == 200
      error_model = JSON.load(response_content)
      fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
    end

    result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
    result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
    result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
    # Deserialize Response
    if status_code == 200
      begin
        parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
        result_mapper = Azure::CognitiveServices::Face::V1_0::Models::PersistedFace.mapper()
        result.body = @client.deserialize(result_mapper, parsed_response)
      rescue Exception => e
        fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
      end
    end

    result
  end

  promise.execute
end
get_face_with_http_info(large_person_group_id, person_id, persisted_face_id, custom_headers:nil) click to toggle source

Retrieve information about a persisted face (specified by persistedFaceId, personId and its belonging largePersonGroupId).

@param large_person_group_id [String] Id referencing a particular large person group. @param person_id Id referencing a particular person. @param persisted_face_id Id referencing a particular persistedFaceId of an existing face. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [MsRestAzure::AzureOperationResponse] HTTP response information.

# File lib/1.0/generated/azure_cognitiveservices_face/large_person_group_person.rb, line 709
def get_face_with_http_info(large_person_group_id, person_id, persisted_face_id, custom_headers:nil)
  get_face_async(large_person_group_id, person_id, persisted_face_id, custom_headers:custom_headers).value!
end
get_with_http_info(large_person_group_id, person_id, custom_headers:nil) click to toggle source

Retrieve a person's name and userData, and the persisted faceIds representing the registered person face feature.

@param large_person_group_id [String] Id referencing a particular large person group. @param person_id Id referencing a particular person. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [MsRestAzure::AzureOperationResponse] HTTP response information.

# File lib/1.0/generated/azure_cognitiveservices_face/large_person_group_person.rb, line 391
def get_with_http_info(large_person_group_id, person_id, custom_headers:nil)
  get_async(large_person_group_id, person_id, custom_headers:custom_headers).value!
end
list(large_person_group_id, start:nil, top:nil, custom_headers:nil) click to toggle source

List all persons in a large person group, and retrieve person information (including personId, name, userData and persistedFaceIds of registered faces of the person).

@param large_person_group_id [String] Id referencing a particular large person group. @param start [String] Starting person id to return (used to list a range of persons). @param top [Integer] Number of persons to return starting with the person id indicated by the 'start' parameter. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [Array] operation results.

# File lib/1.0/generated/azure_cognitiveservices_face/large_person_group_person.rb, line 154
def list(large_person_group_id, start:nil, top:nil, custom_headers:nil)
  response = list_async(large_person_group_id, start:start, top:top, custom_headers:custom_headers).value!
  response.body unless response.nil?
end
list_async(large_person_group_id, start:nil, top:nil, custom_headers:nil) click to toggle source

List all persons in a large person group, and retrieve person information (including personId, name, userData and persistedFaceIds of registered faces of the person).

@param large_person_group_id [String] Id referencing a particular large person group. @param start [String] Starting person id to return (used to list a range of persons). @param top [Integer] Number of persons to return starting with the person id indicated by the 'start' parameter. @param [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [Concurrent::Promise] Promise object which holds the HTTP response.

# File lib/1.0/generated/azure_cognitiveservices_face/large_person_group_person.rb, line 195
def list_async(large_person_group_id, start:nil, top:nil, custom_headers:nil)
  fail ArgumentError, '@client.endpoint is nil' if @client.endpoint.nil?
  fail ArgumentError, 'large_person_group_id is nil' if large_person_group_id.nil?
  fail ArgumentError, "'large_person_group_id' should satisfy the constraint - 'MaxLength': '64'" if !large_person_group_id.nil? && large_person_group_id.length > 64
  fail ArgumentError, "'large_person_group_id' should satisfy the constraint - 'Pattern': '^[a-z0-9-_]+$'" if !large_person_group_id.nil? && large_person_group_id.match(Regexp.new('^^[a-z0-9-_]+$$')).nil?
  fail ArgumentError, "'top' should satisfy the constraint - 'InclusiveMaximum': '1000'" if !top.nil? && top > 1000
  fail ArgumentError, "'top' should satisfy the constraint - 'InclusiveMinimum': '1'" if !top.nil? && top < 1


  request_headers = {}
  request_headers['Content-Type'] = 'application/json; charset=utf-8'

  # Set Headers
  request_headers['x-ms-client-request-id'] = SecureRandom.uuid
  request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?
  path_template = 'largepersongroups/{largePersonGroupId}/persons'

  request_url = @base_url || @client.base_url
request_url = request_url.gsub('{Endpoint}', @client.endpoint)

  options = {
      middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
      path_params: {'largePersonGroupId' => large_person_group_id},
      query_params: {'start' => start,'top' => top},
      headers: request_headers.merge(custom_headers || {}),
      base_url: request_url
  }
  promise = @client.make_request_async(:get, path_template, options)

  promise = promise.then do |result|
    http_response = result.response
    status_code = http_response.status
    response_content = http_response.body
    unless status_code == 200
      error_model = JSON.load(response_content)
      fail MsRest::HttpOperationError.new(result.request, http_response, error_model)
    end

    result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
    result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
    result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?
    # Deserialize Response
    if status_code == 200
      begin
        parsed_response = response_content.to_s.empty? ? nil : JSON.load(response_content)
        result_mapper = {
          client_side_validation: true,
          required: false,
          serialized_name: 'parsed_response',
          type: {
            name: 'Sequence',
            element: {
                client_side_validation: true,
                required: false,
                serialized_name: 'PersonElementType',
                type: {
                  name: 'Composite',
                  class_name: 'Person'
                }
            }
          }
        }
        result.body = @client.deserialize(result_mapper, parsed_response)
      rescue Exception => e
        fail MsRest::DeserializationError.new('Error occurred in deserializing the response', e.message, e.backtrace, result)
      end
    end

    result
  end

  promise.execute
end
list_with_http_info(large_person_group_id, start:nil, top:nil, custom_headers:nil) click to toggle source

List all persons in a large person group, and retrieve person information (including personId, name, userData and persistedFaceIds of registered faces of the person).

@param large_person_group_id [String] Id referencing a particular large person group. @param start [String] Starting person id to return (used to list a range of persons). @param top [Integer] Number of persons to return starting with the person id indicated by the 'start' parameter. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [MsRestAzure::AzureOperationResponse] HTTP response information.

# File lib/1.0/generated/azure_cognitiveservices_face/large_person_group_person.rb, line 175
def list_with_http_info(large_person_group_id, start:nil, top:nil, custom_headers:nil)
  list_async(large_person_group_id, start:start, top:top, custom_headers:custom_headers).value!
end
update(large_person_group_id, person_id, name:nil, user_data:nil, custom_headers:nil) click to toggle source

Update name or userData of a person.

@param large_person_group_id [String] Id referencing a particular large person group. @param person_id Id referencing a particular person. @param name [String] User defined name, maximum length is 128. @param user_data [String] User specified data. Length should not exceed 16KB. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

# File lib/1.0/generated/azure_cognitiveservices_face/large_person_group_person.rb, line 475
def update(large_person_group_id, person_id, name:nil, user_data:nil, custom_headers:nil)
  response = update_async(large_person_group_id, person_id, name:name, user_data:user_data, custom_headers:custom_headers).value!
  nil
end
update_async(large_person_group_id, person_id, name:nil, user_data:nil, custom_headers:nil) click to toggle source

Update name or userData of a person.

@param large_person_group_id [String] Id referencing a particular large person group. @param person_id Id referencing a particular person. @param name [String] User defined name, maximum length is 128. @param user_data [String] User specified data. Length should not exceed 16KB. @param [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [Concurrent::Promise] Promise object which holds the HTTP response.

# File lib/1.0/generated/azure_cognitiveservices_face/large_person_group_person.rb, line 510
def update_async(large_person_group_id, person_id, name:nil, user_data:nil, custom_headers:nil)
  fail ArgumentError, '@client.endpoint is nil' if @client.endpoint.nil?
  fail ArgumentError, 'large_person_group_id is nil' if large_person_group_id.nil?
  fail ArgumentError, "'large_person_group_id' should satisfy the constraint - 'MaxLength': '64'" if !large_person_group_id.nil? && large_person_group_id.length > 64
  fail ArgumentError, "'large_person_group_id' should satisfy the constraint - 'Pattern': '^[a-z0-9-_]+$'" if !large_person_group_id.nil? && large_person_group_id.match(Regexp.new('^^[a-z0-9-_]+$$')).nil?
  fail ArgumentError, 'person_id is nil' if person_id.nil?
  fail ArgumentError, "'name' should satisfy the constraint - 'MaxLength': '128'" if !name.nil? && name.length > 128
  fail ArgumentError, "'user_data' should satisfy the constraint - 'MaxLength': '16384'" if !user_data.nil? && user_data.length > 16384

  body = NameAndUserDataContract.new
  unless name.nil? && user_data.nil?
    body.name = name
    body.user_data = user_data
  end

  request_headers = {}
  request_headers['Content-Type'] = 'application/json; charset=utf-8'

  # Set Headers
  request_headers['x-ms-client-request-id'] = SecureRandom.uuid
  request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?

  # Serialize Request
  request_mapper = Azure::CognitiveServices::Face::V1_0::Models::NameAndUserDataContract.mapper()
  request_content = @client.serialize(request_mapper,  body)
  request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil

  path_template = 'largepersongroups/{largePersonGroupId}/persons/{personId}'

  request_url = @base_url || @client.base_url
request_url = request_url.gsub('{Endpoint}', @client.endpoint)

  options = {
      middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
      path_params: {'largePersonGroupId' => large_person_group_id,'personId' => person_id},
      body: request_content,
      headers: request_headers.merge(custom_headers || {}),
      base_url: request_url
  }
  promise = @client.make_request_async(:patch, path_template, options)

  promise = promise.then do |result|
    http_response = result.response
    status_code = http_response.status
    response_content = http_response.body
    unless status_code == 200
      error_model = JSON.load(response_content)
      fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
    end

    result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
    result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
    result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?

    result
  end

  promise.execute
end
update_face(large_person_group_id, person_id, persisted_face_id, user_data:nil, custom_headers:nil) click to toggle source

Update a person persisted face's userData field.

@param large_person_group_id [String] Id referencing a particular large person group. @param person_id Id referencing a particular person. @param persisted_face_id Id referencing a particular persistedFaceId of an existing face. @param user_data [String] User-provided data attached to the face. The size limit is 1KB. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

# File lib/1.0/generated/azure_cognitiveservices_face/large_person_group_person.rb, line 798
def update_face(large_person_group_id, person_id, persisted_face_id, user_data:nil, custom_headers:nil)
  response = update_face_async(large_person_group_id, person_id, persisted_face_id, user_data:user_data, custom_headers:custom_headers).value!
  nil
end
update_face_async(large_person_group_id, person_id, persisted_face_id, user_data:nil, custom_headers:nil) click to toggle source

Update a person persisted face's userData field.

@param large_person_group_id [String] Id referencing a particular large person group. @param person_id Id referencing a particular person. @param persisted_face_id Id referencing a particular persistedFaceId of an existing face. @param user_data [String] User-provided data attached to the face. The size limit is 1KB. @param [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [Concurrent::Promise] Promise object which holds the HTTP response.

# File lib/1.0/generated/azure_cognitiveservices_face/large_person_group_person.rb, line 837
def update_face_async(large_person_group_id, person_id, persisted_face_id, user_data:nil, custom_headers:nil)
  fail ArgumentError, '@client.endpoint is nil' if @client.endpoint.nil?
  fail ArgumentError, 'large_person_group_id is nil' if large_person_group_id.nil?
  fail ArgumentError, "'large_person_group_id' should satisfy the constraint - 'MaxLength': '64'" if !large_person_group_id.nil? && large_person_group_id.length > 64
  fail ArgumentError, "'large_person_group_id' should satisfy the constraint - 'Pattern': '^[a-z0-9-_]+$'" if !large_person_group_id.nil? && large_person_group_id.match(Regexp.new('^^[a-z0-9-_]+$$')).nil?
  fail ArgumentError, 'person_id is nil' if person_id.nil?
  fail ArgumentError, 'persisted_face_id is nil' if persisted_face_id.nil?
  fail ArgumentError, "'user_data' should satisfy the constraint - 'MaxLength': '1024'" if !user_data.nil? && user_data.length > 1024

  body = UpdateFaceRequest.new
  unless user_data.nil?
    body.user_data = user_data
  end

  request_headers = {}
  request_headers['Content-Type'] = 'application/json; charset=utf-8'

  # Set Headers
  request_headers['x-ms-client-request-id'] = SecureRandom.uuid
  request_headers['accept-language'] = @client.accept_language unless @client.accept_language.nil?

  # Serialize Request
  request_mapper = Azure::CognitiveServices::Face::V1_0::Models::UpdateFaceRequest.mapper()
  request_content = @client.serialize(request_mapper,  body)
  request_content = request_content != nil ? JSON.generate(request_content, quirks_mode: true) : nil

  path_template = 'largepersongroups/{largePersonGroupId}/persons/{personId}/persistedfaces/{persistedFaceId}'

  request_url = @base_url || @client.base_url
request_url = request_url.gsub('{Endpoint}', @client.endpoint)

  options = {
      middlewares: [[MsRest::RetryPolicyMiddleware, times: 3, retry: 0.02], [:cookie_jar]],
      path_params: {'largePersonGroupId' => large_person_group_id,'personId' => person_id,'persistedFaceId' => persisted_face_id},
      body: request_content,
      headers: request_headers.merge(custom_headers || {}),
      base_url: request_url
  }
  promise = @client.make_request_async(:patch, path_template, options)

  promise = promise.then do |result|
    http_response = result.response
    status_code = http_response.status
    response_content = http_response.body
    unless status_code == 200
      error_model = JSON.load(response_content)
      fail MsRestAzure::AzureOperationError.new(result.request, http_response, error_model)
    end

    result.request_id = http_response['x-ms-request-id'] unless http_response['x-ms-request-id'].nil?
    result.correlation_request_id = http_response['x-ms-correlation-request-id'] unless http_response['x-ms-correlation-request-id'].nil?
    result.client_request_id = http_response['x-ms-client-request-id'] unless http_response['x-ms-client-request-id'].nil?

    result
  end

  promise.execute
end
update_face_with_http_info(large_person_group_id, person_id, persisted_face_id, user_data:nil, custom_headers:nil) click to toggle source

Update a person persisted face's userData field.

@param large_person_group_id [String] Id referencing a particular large person group. @param person_id Id referencing a particular person. @param persisted_face_id Id referencing a particular persistedFaceId of an existing face. @param user_data [String] User-provided data attached to the face. The size limit is 1KB. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [MsRestAzure::AzureOperationResponse] HTTP response information.

# File lib/1.0/generated/azure_cognitiveservices_face/large_person_group_person.rb, line 818
def update_face_with_http_info(large_person_group_id, person_id, persisted_face_id, user_data:nil, custom_headers:nil)
  update_face_async(large_person_group_id, person_id, persisted_face_id, user_data:user_data, custom_headers:custom_headers).value!
end
update_with_http_info(large_person_group_id, person_id, name:nil, user_data:nil, custom_headers:nil) click to toggle source

Update name or userData of a person.

@param large_person_group_id [String] Id referencing a particular large person group. @param person_id Id referencing a particular person. @param name [String] User defined name, maximum length is 128. @param user_data [String] User specified data. Length should not exceed 16KB. @param custom_headers [Hash{String => String}] A hash of custom headers that will be added to the HTTP request.

@return [MsRestAzure::AzureOperationResponse] HTTP response information.

# File lib/1.0/generated/azure_cognitiveservices_face/large_person_group_person.rb, line 493
def update_with_http_info(large_person_group_id, person_id, name:nil, user_data:nil, custom_headers:nil)
  update_async(large_person_group_id, person_id, name:name, user_data:user_data, custom_headers:custom_headers).value!
end