private string GetFaceDescriptionFromMousePosition(MouseMovePayload param)
        {
            var result = string.Empty;

            var faces            = _faceAPIService.DetectedFaces();
            var faceDescriptions = _faceAPIService.DetectedFacesDescriptions();
            var resizeFactor     = _faceAPIService.GetResizeFactor();

            try
            {
                // If the REST call has not completed, return from this method.
                if (faces != null)
                {
                    var FacePhotoImage = (Image)param.Sender;

                    // Find the mouse position relative to the image.
                    var mouseXY = param.Args.GetPosition(FacePhotoImage);

                    var imageSource  = FacePhotoImage.Source;
                    var bitmapSource = (BitmapSource)imageSource;

                    // Scale adjustment between the actual size and displayed size.
                    var scale = FacePhotoImage.ActualWidth / (bitmapSource.PixelWidth / resizeFactor);

                    // Check if this mouse position is over a face rectangle.
                    var mouseOverFace = false;

                    for (var i = 0; i < faces.Length; ++i)
                    {
                        var fr     = faces[i].FaceRectangle;
                        var left   = fr.Left * scale;
                        var top    = fr.Top * scale;
                        var width  = fr.Width * scale;
                        var height = fr.Height * scale;

                        // Display the face description for this face if the mouse is over this face rectangle.
                        if (mouseXY.X >= left && mouseXY.X <= left + width && mouseXY.Y >= top && mouseXY.Y <= top + height)
                        {
                            result        = faceDescriptions[i];
                            mouseOverFace = true;
                            break;
                        }
                    }

                    // If the mouse is not over a face rectangle.
                    if (!mouseOverFace)
                    {
                        result = "Place the mouse pointer over a face to see the face description.";
                    }
                }
            }
            // Catch and display other errors.
            catch (Exception e)
            {
                var message = e.Message;
            }

            return(result);
        }
        static void ElementMouseMove(object sender, MouseEventArgs e)
        {
            var mouseMovePayload = new MouseMovePayload();

            mouseMovePayload.Sender = sender;
            mouseMovePayload.Args   = e;
            var element = (FrameworkElement)sender;
            var command = GetMouseMoveCommand(element);

            command.Execute(mouseMovePayload);
        }
 /// <summary>
 /// Showing face description if mouse position is over a face rectangle.
 /// </summary>
 /// <param name="faces"></param>
 /// <param name="faceDescriptions"></param>
 /// <param name="resizeFactor"></param>
 /// <param name="param"></param>
 /// <returns></returns>
 public string FaceDescriptionFromMousePosition(MouseMovePayload param)
 {
     return(GetFaceDescriptionFromMousePosition(param));
 }