Exemplo n.º 1
0
        public virtual async Task <RawAzureOcrResult> Execute(Stream imageStream)
        {
            try
            {
                using (var client = _httpClientBuilder.BuildWithSubscriptionKey(_config.SubscriptionKey))
                {
                    HttpResponseMessage response;

                    using (var content = _streamToByteContent.Execute(imageStream))
                    {
                        response = await client.PostAsync(_config.BuildUri().AbsoluteUri, content);
                    }

                    return(JsonConvert.DeserializeObject <RawAzureOcrResult>(await response.Content.ReadAsStringAsync()));
                }
            }
            catch (Exception e)
            {
                throw new AzureOcrException(e);
            }
        }