Пример #1
0
        public static async Task <IEnumerable <FaceModel> > GetFacesAsync(byte[] byteData)
        {
            try
            {
                HttpClient client = new HttpClient();
                client.DefaultRequestHeaders.Add(AzureApiConstants.SubscriptionKeyHeader, AzureApiConstants.SubscriptionKey);

                string uri = AzureApiConstants.UriBase + "?" + AzureApiConstants.DefaultRequestParameters;

                HttpResponseMessage response;
                using (ByteArrayContent content = new ByteArrayContent(byteData))
                {
                    content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream");
                    response = await client.PostAsync(uri, content);
                }

                return(FaceModel.FromJson(await response.Content.ReadAsStringAsync()));
            }
            catch (Exception e)
            {
                Console.WriteLine("\n" + e.Message);
            }

            return(null);
        }