Пример #1
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);
            }
        }
Пример #2
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);
            }
        }
Пример #3
0
 public static async Task <Emotion[]> GetEmotionResultsFromMediaFile(MediaFile mediaFile, bool disposeMediaFile)
 {
     using (var handle = Insights.TrackTime(InsightsConstants.AnalyzeEmotion))
         return(await EmotionClient.RecognizeAsync(MediaService.GetPhotoStream(mediaFile, disposeMediaFile)).ConfigureAwait(false));
 }
Пример #4
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());
            }
        }