Skip to content
Closed
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 @@ -85,6 +85,19 @@ public partial class FaceClient : ServiceClient<FaceClient>, IFaceClient
/// </summary>
public virtual ILargeFaceListOperations LargeFaceList { 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 @@ -135,6 +148,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 @@ -63,6 +63,8 @@ public FaceListOperations(FaceClient client)
/// <param name='userData'>
/// User specified data. Length should not exceed 16KB.
/// </param>
/// <param name='recognitionModel'>
/// </param>
/// <param name='customHeaders'>
/// Headers that will be added to request.
/// </param>
Expand All @@ -81,7 +83,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 +118,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
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,14 @@ public static partial class FaceListOperationsExtensions
/// <param name='userData'>
/// User specified data. Length should not exceed 16KB.
/// </param>
/// <param name='recognitionModel'>
/// </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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -858,6 +858,9 @@ public FaceOperations(FaceClient client)
/// and emotion. Note that each face attribute analysis has additional
/// computational and time cost.
/// </param>
/// <param name='recognitionModel'>
/// Recognition model name, maximum length is 128.
/// </param>
/// <param name='customHeaders'>
/// Headers that will be added to request.
/// </param>
Expand All @@ -879,12 +882,19 @@ public FaceOperations(FaceClient client)
/// <return>
/// A response object containing the response body and response headers.
/// </return>
public async Task<HttpOperationResponse<IList<DetectedFace>>> DetectWithUrlWithHttpMessagesAsync(string url, bool? returnFaceId = true, bool? returnFaceLandmarks = false, IList<FaceAttributeType> returnFaceAttributes = default(IList<FaceAttributeType>), Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
public async Task<HttpOperationResponse<IList<DetectedFace>>> DetectWithUrlWithHttpMessagesAsync(string url, bool? returnFaceId = true, bool? returnFaceLandmarks = false, IList<FaceAttributeType> returnFaceAttributes = default(IList<FaceAttributeType>), string recognitionModel = default(string), Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
{
if (Client.Endpoint == null)
{
throw new ValidationException(ValidationRules.CannotBeNull, "this.Client.Endpoint");
}
if (recognitionModel != null)
{
if (recognitionModel.Length > 128)
{
throw new ValidationException(ValidationRules.MaxLength, "recognitionModel", 128);
}
}
if (url == null)
{
throw new ValidationException(ValidationRules.CannotBeNull, "url");
Expand All @@ -904,6 +914,7 @@ public FaceOperations(FaceClient client)
tracingParameters.Add("returnFaceId", returnFaceId);
tracingParameters.Add("returnFaceLandmarks", returnFaceLandmarks);
tracingParameters.Add("returnFaceAttributes", returnFaceAttributes);
tracingParameters.Add("recognitionModel", recognitionModel);
tracingParameters.Add("imageUrl", imageUrl);
tracingParameters.Add("cancellationToken", cancellationToken);
ServiceClientTracing.Enter(_invocationId, this, "DetectWithUrl", tracingParameters);
Expand All @@ -925,6 +936,10 @@ public FaceOperations(FaceClient client)
{
_queryParameters.Add(string.Format("returnFaceAttributes={0}", System.Uri.EscapeDataString(string.Join(",", returnFaceAttributes))));
}
if (recognitionModel != null)
{
_queryParameters.Add(string.Format("RecognitionModel={0}", System.Uri.EscapeDataString(recognitionModel)));
}
if (_queryParameters.Count > 0)
{
_url += "?" + string.Join("&", _queryParameters);
Expand Down Expand Up @@ -1259,6 +1274,9 @@ public FaceOperations(FaceClient client)
/// and emotion. Note that each face attribute analysis has additional
/// computational and time cost.
/// </param>
/// <param name='recognitionModel'>
/// Recognition model name, maximum length is 128.
/// </param>
/// <param name='customHeaders'>
/// Headers that will be added to request.
/// </param>
Expand All @@ -1280,7 +1298,7 @@ public FaceOperations(FaceClient client)
/// <return>
/// A response object containing the response body and response headers.
/// </return>
public async Task<HttpOperationResponse<IList<DetectedFace>>> DetectWithStreamWithHttpMessagesAsync(Stream image, bool? returnFaceId = true, bool? returnFaceLandmarks = false, IList<FaceAttributeType> returnFaceAttributes = default(IList<FaceAttributeType>), Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
public async Task<HttpOperationResponse<IList<DetectedFace>>> DetectWithStreamWithHttpMessagesAsync(Stream image, bool? returnFaceId = true, bool? returnFaceLandmarks = false, IList<FaceAttributeType> returnFaceAttributes = default(IList<FaceAttributeType>), string recognitionModel = default(string), Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken))
{
if (Client.Endpoint == null)
{
Expand All @@ -1290,6 +1308,13 @@ public FaceOperations(FaceClient client)
{
throw new ValidationException(ValidationRules.CannotBeNull, "image");
}
if (recognitionModel != null)
{
if (recognitionModel.Length > 128)
{
throw new ValidationException(ValidationRules.MaxLength, "recognitionModel", 128);
}
}
// Tracing
bool _shouldTrace = ServiceClientTracing.IsEnabled;
string _invocationId = null;
Expand All @@ -1301,6 +1326,7 @@ public FaceOperations(FaceClient client)
tracingParameters.Add("returnFaceLandmarks", returnFaceLandmarks);
tracingParameters.Add("returnFaceAttributes", returnFaceAttributes);
tracingParameters.Add("image", image);
tracingParameters.Add("recognitionModel", recognitionModel);
tracingParameters.Add("cancellationToken", cancellationToken);
ServiceClientTracing.Enter(_invocationId, this, "DetectWithStream", tracingParameters);
}
Expand All @@ -1321,6 +1347,10 @@ public FaceOperations(FaceClient client)
{
_queryParameters.Add(string.Format("returnFaceAttributes={0}", System.Uri.EscapeDataString(string.Join(",", returnFaceAttributes))));
}
if (recognitionModel != null)
{
_queryParameters.Add(string.Format("RecognitionModel={0}", System.Uri.EscapeDataString(recognitionModel)));
}
if (_queryParameters.Count > 0)
{
_url += "?" + string.Join("&", _queryParameters);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,12 +181,15 @@ public static partial class FaceOperationsExtensions
/// and emotion. Note that each face attribute analysis has additional
/// computational and time cost.
/// </param>
/// <param name='recognitionModel'>
/// Recognition model name, maximum length is 128.
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
public static async Task<IList<DetectedFace>> DetectWithUrlAsync(this IFaceOperations operations, string url, bool? returnFaceId = true, bool? returnFaceLandmarks = false, IList<FaceAttributeType> returnFaceAttributes = default(IList<FaceAttributeType>), CancellationToken cancellationToken = default(CancellationToken))
public static async Task<IList<DetectedFace>> DetectWithUrlAsync(this IFaceOperations operations, string url, bool? returnFaceId = true, bool? returnFaceLandmarks = false, IList<FaceAttributeType> returnFaceAttributes = default(IList<FaceAttributeType>), string recognitionModel = default(string), CancellationToken cancellationToken = default(CancellationToken))
{
using (var _result = await operations.DetectWithUrlWithHttpMessagesAsync(url, returnFaceId, returnFaceLandmarks, returnFaceAttributes, null, cancellationToken).ConfigureAwait(false))
using (var _result = await operations.DetectWithUrlWithHttpMessagesAsync(url, returnFaceId, returnFaceLandmarks, returnFaceAttributes, recognitionModel, null, cancellationToken).ConfigureAwait(false))
{
return _result.Body;
}
Expand Down Expand Up @@ -255,12 +258,15 @@ public static partial class FaceOperationsExtensions
/// and emotion. Note that each face attribute analysis has additional
/// computational and time cost.
/// </param>
/// <param name='recognitionModel'>
/// Recognition model name, maximum length is 128.
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
public static async Task<IList<DetectedFace>> DetectWithStreamAsync(this IFaceOperations operations, Stream image, bool? returnFaceId = true, bool? returnFaceLandmarks = false, IList<FaceAttributeType> returnFaceAttributes = default(IList<FaceAttributeType>), CancellationToken cancellationToken = default(CancellationToken))
public static async Task<IList<DetectedFace>> DetectWithStreamAsync(this IFaceOperations operations, Stream image, bool? returnFaceId = true, bool? returnFaceLandmarks = false, IList<FaceAttributeType> returnFaceAttributes = default(IList<FaceAttributeType>), string recognitionModel = default(string), CancellationToken cancellationToken = default(CancellationToken))
{
using (var _result = await operations.DetectWithStreamWithHttpMessagesAsync(image, returnFaceId, returnFaceLandmarks, returnFaceAttributes, null, cancellationToken).ConfigureAwait(false))
using (var _result = await operations.DetectWithStreamWithHttpMessagesAsync(image, returnFaceId, returnFaceLandmarks, returnFaceAttributes, recognitionModel, null, cancellationToken).ConfigureAwait(false))
{
return _result.Body;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ public partial interface IFaceListOperations
/// <param name='userData'>
/// User specified data. Length should not exceed 16KB.
/// </param>
/// <param name='recognitionModel'>
/// </param>
/// <param name='customHeaders'>
/// The headers that will be added to request.
/// </param>
Expand All @@ -48,7 +50,7 @@ public partial interface IFaceListOperations
/// <exception cref="Microsoft.Rest.ValidationException">
/// Thrown when a required parameter is null
/// </exception>
Task<HttpOperationResponse> CreateWithHttpMessagesAsync(string faceListId, string name = default(string), string userData = default(string), Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
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));
/// <summary>
/// Retrieve a face list's information.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,9 @@ public partial interface IFaceOperations
/// facialHair, glasses and emotion. Note that each face attribute
/// analysis has additional computational and time cost.
/// </param>
/// <param name='recognitionModel'>
/// Recognition model name, maximum length is 128.
/// </param>
/// <param name='customHeaders'>
/// The headers that will be added to request.
/// </param>
Expand All @@ -208,7 +211,7 @@ public partial interface IFaceOperations
/// <exception cref="Microsoft.Rest.ValidationException">
/// Thrown when a required parameter is null
/// </exception>
Task<HttpOperationResponse<IList<DetectedFace>>> DetectWithUrlWithHttpMessagesAsync(string url, bool? returnFaceId = true, bool? returnFaceLandmarks = false, IList<FaceAttributeType> returnFaceAttributes = default(IList<FaceAttributeType>), Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
Task<HttpOperationResponse<IList<DetectedFace>>> DetectWithUrlWithHttpMessagesAsync(string url, bool? returnFaceId = true, bool? returnFaceLandmarks = false, IList<FaceAttributeType> returnFaceAttributes = default(IList<FaceAttributeType>), string recognitionModel = default(string), Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// Verify whether two faces belong to a same person. Compares a face
/// Id with a Person Id
Expand Down Expand Up @@ -271,6 +274,9 @@ public partial interface IFaceOperations
/// facialHair, glasses and emotion. Note that each face attribute
/// analysis has additional computational and time cost.
/// </param>
/// <param name='recognitionModel'>
/// Recognition model name, maximum length is 128.
/// </param>
/// <param name='customHeaders'>
/// The headers that will be added to request.
/// </param>
Expand All @@ -286,6 +292,6 @@ public partial interface IFaceOperations
/// <exception cref="Microsoft.Rest.ValidationException">
/// Thrown when a required parameter is null
/// </exception>
Task<HttpOperationResponse<IList<DetectedFace>>> DetectWithStreamWithHttpMessagesAsync(Stream image, bool? returnFaceId = true, bool? returnFaceLandmarks = false, IList<FaceAttributeType> returnFaceAttributes = default(IList<FaceAttributeType>), Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
Task<HttpOperationResponse<IList<DetectedFace>>> DetectWithStreamWithHttpMessagesAsync(Stream image, bool? returnFaceId = true, bool? returnFaceLandmarks = false, IList<FaceAttributeType> returnFaceAttributes = default(IList<FaceAttributeType>), string recognitionModel = default(string), Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
}
}
Loading