public async Task DetectEmotionAsync() { try { if (this.ImageUrl != null) { this.DetectedEmotion = await EmotionServiceHelper.RecognizeAsync(this.ImageUrl); } else if (this.GetImageStreamCallback != null) { this.DetectedEmotion = await EmotionServiceHelper.RecognizeAsync(this.GetImageStreamCallback); } if (this.FilterOutSmallFaces) { this.DetectedEmotion = this.DetectedEmotion.Where(f => CoreUtil.IsFaceBigEnoughForDetection(f.FaceRectangle.Height, this.DecodedImageHeight)); } } catch (Exception e) { ErrorTrackingHelper.TrackException(e, "Emotion API RecognizeAsync error"); this.DetectedEmotion = Enumerable.Empty <Emotion>(); if (this.ShowDialogOnFaceApiErrors) { await ErrorTrackingHelper.GenericApiCallExceptionHandler(e, "Emotion detection failed."); } } finally { this.OnEmotionRecognitionCompleted(); } }
public async Task DetectFacesAsync(bool detectFaceAttributes = false, bool detectFaceLandmarks = false) { try { if (this.ImageUrl != null) { this.DetectedFaces = await FaceServiceHelper.DetectAsync( this.ImageUrl, returnFaceId : true, returnFaceLandmarks : detectFaceLandmarks, returnFaceAttributes : detectFaceAttributes?DefaultFaceAttributeTypes : null); } else if (this.GetImageStreamCallback != null) { this.DetectedFaces = await FaceServiceHelper.DetectAsync( this.GetImageStreamCallback, returnFaceId : true, returnFaceLandmarks : detectFaceLandmarks, returnFaceAttributes : detectFaceAttributes?DefaultFaceAttributeTypes : null); } if (this.FilterOutSmallFaces) { this.DetectedFaces = this.DetectedFaces.Where(f => CoreUtil.IsFaceBigEnoughForDetection(f.FaceRectangle.Height, this.DecodedImageHeight)); } } catch (Exception e) { ErrorTrackingHelper.TrackException(e, "Face API DetectAsync error"); this.DetectedFaces = Enumerable.Empty <Face>(); if (this.ShowDialogOnFaceApiErrors) { await ErrorTrackingHelper.GenericApiCallExceptionHandler(e, "Face detection failed."); } } finally { this.OnFaceDetectionCompleted(); } }