Esempio n. 1
0
        public static async Task <List <Emotion> > GetEmotionResultsFromMediaFile(MediaFile mediaFile, bool disposeMediaFile)
        {
            using (var handle = AnalyticsHelpers.TrackTime(AnalyticsConstants.AnalyzeEmotion))
            {
                var faceApiResponseList = await FaceApiClient.Face.DetectWithStreamAsync(MediaService.GetPhotoStream(mediaFile, disposeMediaFile),
                                                                                         returnFaceAttributes : new List <FaceAttributeType> {
                    { FaceAttributeType.Emotion }
                }).ConfigureAwait(false);

                return(faceApiResponseList.Select(x => x.FaceAttributes.Emotion).ToList());
            }
        }
Esempio n. 2
0
        public static async Task <Emotion[]> GetEmotionResultsFromMediaFile(MediaFile mediaFile, bool disposeMediaFile)
        {
            Device.BeginInvokeOnMainThread(() => Application.Current.MainPage.IsBusy = true);

            try
            {
                using (var handle = AnalyticsHelpers.TrackTime(AnalyticsConstants.AnalyzeEmotion))
                    return(await EmotionClient.RecognizeAsync(MediaService.GetPhotoStream(mediaFile, disposeMediaFile)));
            }
            finally
            {
                Device.BeginInvokeOnMainThread(() => Application.Current.MainPage.IsBusy = false);
            }
        }
Esempio n. 3
0
        public static async Task <List <Emotion> > GetEmotionResultsFromMediaFile(MediaFile mediaFile, bool disposeMediaFile)
        {
            Device.BeginInvokeOnMainThread(() => Application.Current.MainPage.IsBusy = true);

            try
            {
                using (var handle = AnalyticsHelpers.TrackTime(AnalyticsConstants.AnalyzeEmotion))
                {
                    var faceApiResponseList = await FaceApiClient.Face.DetectWithStreamAsync(MediaService.GetPhotoStream(mediaFile, disposeMediaFile),
                                                                                             returnFaceAttributes : new List <FaceAttributeType> {
                        { FaceAttributeType.Emotion }
                    }).ConfigureAwait(false);

                    return(faceApiResponseList.Select(x => x.FaceAttributes.Emotion).ToList());
                }
            }
            finally
            {
                Device.BeginInvokeOnMainThread(() => Application.Current.MainPage.IsBusy = false);
            }
        }