private async void BtnGetFacialFeatures_Click(object sender, RoutedEventArgs e)
        {
            TxtCognitiveServicesAnalysisResponse.Text = string.Empty;

            if (!System.IO.File.Exists(_validatedImageFileLocation))
            {
                return;
            }

            var httpClient = new CognitiveServicesRestHttpClient();

            var imageStream = CommonFramework.Library.Helpers.ImagesHelpers.GetImagesAsStream(_validatedImageFileLocation);

            var request = new CognitiveServicesRequest
            {
                EndPointKey1          = Properties.Settings.Default.EndPointKey1,
                EndPoint              = Properties.Settings.Default.EndPoint,
                ImageStream           = imageStream,
                EndPointExtension     = "/face/v1.0/detect",
                RestRequestParameters = "returnFaceId=true&returnFaceLandmarks=false" +
                                        "&returnFaceAttributes=age,gender,headPose,smile,facialHair,glasses," +
                                        "emotion,hair,makeup,occlusion,accessories,blur,exposure,noise",
            };

            // ReSharper disable once PossibleNullReferenceException

            var response = await httpClient.GetRestHttpStringResponse(request);

            var visualFeatures = CommonFramework.Library.Helpers.JsonHelpers.JsonPrettyPrint(response.RestResponse);

            TxtCognitiveServicesAnalysisResponse.Text = response.Success
                ? visualFeatures
                : response.FailureInformation;
        }
Exemplo n.º 2
0
        public override async Task <GetThumbnailResponse> GetThumbnail(GetThumbnailRequest request)
        {
            var cognitiveServicesRestHttpClient = new CognitiveServicesRestHttpClient();
            var restHttpResponse = await cognitiveServicesRestHttpClient.GetRestHttpStreamResponse(request);

            var servicesStreamResponseApi = new GetThumbnailResponse
            {
                Success             = restHttpResponse.Success,
                ImplementedInModule = restHttpResponse.ImplementedInModule,
                FailureInformation  = restHttpResponse.FailureInformation,
                Thumbnail           = restHttpResponse.RestResponse,
            };

            return(servicesStreamResponseApi);
        }
Exemplo n.º 3
0
        public override async Task <GetVisualFeaturesStringResponse> GetVisualFeatures(CognitiveServicesRequest request)
        {
            var cognitiveServicesRestHttpClient = new CognitiveServicesRestHttpClient();
            var restHttpResponse = await cognitiveServicesRestHttpClient.GetRestHttpStringResponse(request);

            var getVisualFeaturesResponse = new GetVisualFeaturesStringResponse
            {
                Success             = restHttpResponse.Success,
                ImplementedInModule = restHttpResponse.ImplementedInModule,
                FailureInformation  = restHttpResponse.FailureInformation,
                VisualFeatures      =
                    CommonFramework.Library.Helpers.JsonHelpers.JsonPrettyPrint(restHttpResponse.RestResponse),
            };

            return(getVisualFeaturesResponse);
        }
Exemplo n.º 4
0
        public override async Task <PerformOcrStringResponse> PerformOcr(CognitiveServicesRequest request)
        {
            var cognitiveServicesRestHttpClient = new CognitiveServicesRestHttpClient();
            var restHttpResponse = await cognitiveServicesRestHttpClient.GetRestHttpStringResponse(request);

            var performOcrResponse = new PerformOcrStringResponse
            {
                Success             = restHttpResponse.Success,
                ImplementedInModule = restHttpResponse.ImplementedInModule,
                FailureInformation  = restHttpResponse.FailureInformation,
                // LinesFound = new List<string>(),
                // WordsFound = new List<PerformOcrWordInstance>(),
            };

            performOcrResponse.LinesFound.Add(CommonFramework.Library.Helpers.JsonHelpers.JsonPrettyPrint(restHttpResponse.RestResponse));

            return(performOcrResponse);
        }