Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,19 @@ public partial class FaceClient : ServiceClient<FaceClient>, IFaceClient
/// </summary>
public virtual ISnapshotOperations Snapshot { get; private set; }

/// <summary>
/// Initializes a new instance of the FaceClient class.
/// </summary>
/// <param name='httpClient'>
/// HttpClient to be used
/// </param>
/// <param name='disposeHttpClient'>
/// True: will dispose the provided httpClient on calling FaceClient.Dispose(). False: will not dispose provided httpClient</param>
protected FaceClient(HttpClient httpClient, bool disposeHttpClient) : base(httpClient, disposeHttpClient)
{
Initialize();
}

/// <summary>
/// Initializes a new instance of the FaceClient class.
/// </summary>
Expand Down Expand Up @@ -140,6 +153,33 @@ public FaceClient(ServiceClientCredentials credentials, params DelegatingHandler
}
}

/// <summary>
/// Initializes a new instance of the FaceClient class.
/// </summary>
/// <param name='credentials'>
/// Required. Subscription credentials which uniquely identify client subscription.
/// </param>
/// <param name='httpClient'>
/// HttpClient to be used
/// </param>
/// <param name='disposeHttpClient'>
/// True: will dispose the provided httpClient on calling FaceClient.Dispose(). False: will not dispose provided httpClient</param>
/// <exception cref="System.ArgumentNullException">
/// Thrown when a required parameter is null
/// </exception>
public FaceClient(ServiceClientCredentials credentials, HttpClient httpClient, bool disposeHttpClient) : this(httpClient, disposeHttpClient)
{
if (credentials == null)
{
throw new System.ArgumentNullException("credentials");
}
Credentials = credentials;
if (Credentials != null)
{
Credentials.InitializeServiceClient(this);
}
}

/// <summary>
/// Initializes a new instance of the FaceClient class.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,36 @@ public FaceListOperations(FaceClient client)
public FaceClient Client { get; private set; }

/// <summary>
/// Create an empty face list. Up to 64 face lists are allowed to exist in one
/// Create an empty face list with user-specified faceListId, name, an optional
/// userData and recognitionModel. Up to 64 face lists are allowed in one
/// subscription.
/// &lt;br /&gt; Face list is a list of faces, up to 1,000 faces, and used by
/// [Face - Find
/// Similar](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395237).
/// &lt;br /&gt; After creation, user should use [FaceList - Add
/// Face](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395250)
/// to import the faces. Faces are stored on server until [FaceList -
/// Delete](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f3039524f)
/// is called.
/// &lt;br /&gt; Find Similar is used for scenario like finding celebrity-like
/// faces, similar face filtering, or as a light way face identification. But
/// if the actual use is to identify person, please use
/// [PersonGroup](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395244)
/// /
/// [LargePersonGroup](/docs/services/563879b61984550e40cbbe8d/operations/599acdee6ac60f11b48b5a9d)
/// and [Face -
/// Identify](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395239).
/// &lt;br /&gt; Please consider
/// [LargeFaceList](/docs/services/563879b61984550e40cbbe8d/operations/5a157b68d2de3616c086f2cc)
/// when the face number is large. It can support up to 1,000,000 faces.
/// 'recognitionModel' should be specified to associate with this face list.
/// The default value for 'recognitionModel' is 'recognition_01', if the latest
/// model needed, please explicitly specify the model you need in this
/// parameter. New faces that are added to an existing face list will use the
/// recognition model that's already associated with the collection. Existing
/// face features in a face list can't be updated to features extracted by
/// another version of recognition model.
///
/// </summary>
/// <param name='faceListId'>
/// Id referencing a particular face list.
Expand All @@ -63,6 +91,9 @@ public FaceListOperations(FaceClient client)
/// <param name='userData'>
/// User specified data. Length should not exceed 16KB.
/// </param>
/// <param name='recognitionModel'>
/// Possible values include: 'recognition_01', 'recognition_02'
/// </param>
/// <param name='customHeaders'>
/// Headers that will be added to request.
/// </param>
Expand All @@ -81,7 +112,7 @@ public FaceListOperations(FaceClient client)
/// <return>
/// A response object containing the response body and response headers.
/// </return>
public async Task<HttpOperationResponse> CreateWithHttpMessagesAsync(string faceListId, string name = default(string), string userData = default(string), Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
public async Task<HttpOperationResponse> CreateWithHttpMessagesAsync(string faceListId, string name = default(string), string userData = default(string), string recognitionModel = default(string), Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
{
if (Client.Endpoint == null)
{
Expand Down Expand Up @@ -116,11 +147,12 @@ public FaceListOperations(FaceClient client)
throw new ValidationException(ValidationRules.MaxLength, "userData", 16384);
}
}
NameAndUserDataContract body = new NameAndUserDataContract();
if (name != null || userData != null)
MetaDataContract body = new MetaDataContract();
if (name != null || userData != null || recognitionModel != null)
{
body.Name = name;
body.UserData = userData;
body.RecognitionModel = recognitionModel;
}
// Tracing
bool _shouldTrace = ServiceClientTracing.IsEnabled;
Expand Down Expand Up @@ -228,11 +260,17 @@ public FaceListOperations(FaceClient client)
}

/// <summary>
/// Retrieve a face list's information.
/// Retrieve a face list’s faceListId, name, userData, recognitionModel and
/// faces in the face list.
///
/// </summary>
/// <param name='faceListId'>
/// Id referencing a particular face list.
/// </param>
/// <param name='returnRecognitionModel'>
/// A value indicating whether the operation should return 'recognitionModel'
/// in response.
/// </param>
/// <param name='customHeaders'>
/// Headers that will be added to request.
/// </param>
Expand All @@ -254,7 +292,7 @@ public FaceListOperations(FaceClient client)
/// <return>
/// A response object containing the response body and response headers.
/// </return>
public async Task<HttpOperationResponse<FaceList>> GetWithHttpMessagesAsync(string faceListId, Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
public async Task<HttpOperationResponse<FaceList>> GetWithHttpMessagesAsync(string faceListId, bool? returnRecognitionModel = false, Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
{
if (Client.Endpoint == null)
{
Expand Down Expand Up @@ -283,6 +321,7 @@ public FaceListOperations(FaceClient client)
_invocationId = ServiceClientTracing.NextInvocationId.ToString();
Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
tracingParameters.Add("faceListId", faceListId);
tracingParameters.Add("returnRecognitionModel", returnRecognitionModel);
tracingParameters.Add("cancellationToken", cancellationToken);
ServiceClientTracing.Enter(_invocationId, this, "Get", tracingParameters);
}
Expand All @@ -291,6 +330,15 @@ public FaceListOperations(FaceClient client)
var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "facelists/{faceListId}";
_url = _url.Replace("{Endpoint}", Client.Endpoint);
_url = _url.Replace("{faceListId}", System.Uri.EscapeDataString(faceListId));
List<string> _queryParameters = new List<string>();
if (returnRecognitionModel != null)
{
_queryParameters.Add(string.Format("returnRecognitionModel={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(returnRecognitionModel, Client.SerializationSettings).Trim('"'))));
}
if (_queryParameters.Count > 0)
{
_url += "?" + string.Join("&", _queryParameters);
}
// Create HTTP transport objects
var _httpRequest = new HttpRequestMessage();
HttpResponseMessage _httpResponse = null;
Expand Down Expand Up @@ -712,9 +760,16 @@ public FaceListOperations(FaceClient client)
}

/// <summary>
/// Retrieve information about all existing face lists. Only faceListId, name
/// and userData will be returned.
/// List face lists’ faceListId, name, userData and recognitionModel. &lt;br
/// /&gt;
/// To get face information inside faceList use [FaceList -
/// Get](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f3039524c)
///
/// </summary>
/// <param name='returnRecognitionModel'>
/// A value indicating whether the operation should return 'recognitionModel'
/// in response.
/// </param>
/// <param name='customHeaders'>
/// Headers that will be added to request.
/// </param>
Expand All @@ -736,7 +791,7 @@ public FaceListOperations(FaceClient client)
/// <return>
/// A response object containing the response body and response headers.
/// </return>
public async Task<HttpOperationResponse<IList<FaceList>>> ListWithHttpMessagesAsync(Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
public async Task<HttpOperationResponse<IList<FaceList>>> ListWithHttpMessagesAsync(bool? returnRecognitionModel = false, Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
{
if (Client.Endpoint == null)
{
Expand All @@ -749,13 +804,23 @@ public FaceListOperations(FaceClient client)
{
_invocationId = ServiceClientTracing.NextInvocationId.ToString();
Dictionary<string, object> tracingParameters = new Dictionary<string, object>();
tracingParameters.Add("returnRecognitionModel", returnRecognitionModel);
tracingParameters.Add("cancellationToken", cancellationToken);
ServiceClientTracing.Enter(_invocationId, this, "List", tracingParameters);
}
// Construct URL
var _baseUrl = Client.BaseUri;
var _url = _baseUrl + (_baseUrl.EndsWith("/") ? "" : "/") + "facelists";
_url = _url.Replace("{Endpoint}", Client.Endpoint);
List<string> _queryParameters = new List<string>();
if (returnRecognitionModel != null)
{
_queryParameters.Add(string.Format("returnRecognitionModel={0}", System.Uri.EscapeDataString(Rest.Serialization.SafeJsonConvert.SerializeObject(returnRecognitionModel, Client.SerializationSettings).Trim('"'))));
}
if (_queryParameters.Count > 0)
{
_url += "?" + string.Join("&", _queryParameters);
}
// Create HTTP transport objects
var _httpRequest = new HttpRequestMessage();
HttpResponseMessage _httpResponse = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,36 @@ namespace Microsoft.Azure.CognitiveServices.Vision.Face
public static partial class FaceListOperationsExtensions
{
/// <summary>
/// Create an empty face list. Up to 64 face lists are allowed to exist in one
/// Create an empty face list with user-specified faceListId, name, an optional
/// userData and recognitionModel. Up to 64 face lists are allowed in one
/// subscription.
/// &lt;br /&gt; Face list is a list of faces, up to 1,000 faces, and used by
/// [Face - Find
/// Similar](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395237).
/// &lt;br /&gt; After creation, user should use [FaceList - Add
/// Face](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395250)
/// to import the faces. Faces are stored on server until [FaceList -
/// Delete](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f3039524f)
/// is called.
/// &lt;br /&gt; Find Similar is used for scenario like finding celebrity-like
/// faces, similar face filtering, or as a light way face identification. But
/// if the actual use is to identify person, please use
/// [PersonGroup](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395244)
/// /
/// [LargePersonGroup](/docs/services/563879b61984550e40cbbe8d/operations/599acdee6ac60f11b48b5a9d)
/// and [Face -
/// Identify](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f30395239).
/// &lt;br /&gt; Please consider
/// [LargeFaceList](/docs/services/563879b61984550e40cbbe8d/operations/5a157b68d2de3616c086f2cc)
/// when the face number is large. It can support up to 1,000,000 faces.
/// 'recognitionModel' should be specified to associate with this face list.
/// The default value for 'recognitionModel' is 'recognition_01', if the latest
/// model needed, please explicitly specify the model you need in this
/// parameter. New faces that are added to an existing face list will use the
/// recognition model that's already associated with the collection. Existing
/// face features in a face list can't be updated to features extracted by
/// another version of recognition model.
///
/// </summary>
/// <param name='operations'>
/// The operations group for this extension method.
Expand All @@ -38,29 +66,38 @@ public static partial class FaceListOperationsExtensions
/// <param name='userData'>
/// User specified data. Length should not exceed 16KB.
/// </param>
/// <param name='recognitionModel'>
/// Possible values include: 'recognition_01', 'recognition_02'
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
public static async Task CreateAsync(this IFaceListOperations operations, string faceListId, string name = default(string), string userData = default(string), CancellationToken cancellationToken = default(CancellationToken))
public static async Task CreateAsync(this IFaceListOperations operations, string faceListId, string name = default(string), string userData = default(string), string recognitionModel = default(string), CancellationToken cancellationToken = default(CancellationToken))
{
(await operations.CreateWithHttpMessagesAsync(faceListId, name, userData, null, cancellationToken).ConfigureAwait(false)).Dispose();
(await operations.CreateWithHttpMessagesAsync(faceListId, name, userData, recognitionModel, null, cancellationToken).ConfigureAwait(false)).Dispose();
}

/// <summary>
/// Retrieve a face list's information.
/// Retrieve a face list’s faceListId, name, userData, recognitionModel and
/// faces in the face list.
///
/// </summary>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='faceListId'>
/// Id referencing a particular face list.
/// </param>
/// <param name='returnRecognitionModel'>
/// A value indicating whether the operation should return 'recognitionModel'
/// in response.
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
public static async Task<FaceList> GetAsync(this IFaceListOperations operations, string faceListId, CancellationToken cancellationToken = default(CancellationToken))
public static async Task<FaceList> GetAsync(this IFaceListOperations operations, string faceListId, bool? returnRecognitionModel = false, CancellationToken cancellationToken = default(CancellationToken))
{
using (var _result = await operations.GetWithHttpMessagesAsync(faceListId, null, cancellationToken).ConfigureAwait(false))
using (var _result = await operations.GetWithHttpMessagesAsync(faceListId, returnRecognitionModel, null, cancellationToken).ConfigureAwait(false))
{
return _result.Body;
}
Expand Down Expand Up @@ -108,18 +145,25 @@ public static partial class FaceListOperationsExtensions
}

/// <summary>
/// Retrieve information about all existing face lists. Only faceListId, name
/// and userData will be returned.
/// List face lists’ faceListId, name, userData and recognitionModel. &lt;br
/// /&gt;
/// To get face information inside faceList use [FaceList -
/// Get](/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f3039524c)
///
/// </summary>
/// <param name='operations'>
/// The operations group for this extension method.
/// </param>
/// <param name='returnRecognitionModel'>
/// A value indicating whether the operation should return 'recognitionModel'
/// in response.
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
public static async Task<IList<FaceList>> ListAsync(this IFaceListOperations operations, CancellationToken cancellationToken = default(CancellationToken))
public static async Task<IList<FaceList>> ListAsync(this IFaceListOperations operations, bool? returnRecognitionModel = false, CancellationToken cancellationToken = default(CancellationToken))
{
using (var _result = await operations.ListWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false))
using (var _result = await operations.ListWithHttpMessagesAsync(returnRecognitionModel, null, cancellationToken).ConfigureAwait(false))
{
return _result.Body;
}
Expand Down
Loading