Ejemplo n.º 1
0
        async void UploadAndDetectFaces(string imageFilePath)
        {
            try
            {
                StorageFolder appInstalledFolder = Windows.ApplicationModel.Package.Current.InstalledLocation;
                StorageFolder assets             = await appInstalledFolder.GetFolderAsync("Assets");

                var storageFile = await assets.GetFileAsync(imageFilePath);

                var randomAccessStream = await storageFile.OpenReadAsync();

                using (Stream stream = randomAccessStream.AsStreamForRead())
                {
                    // This is the fragment where the face is recognized:
                    var faces = await faceServiceClient.DetectAsync(stream);

                    var faceRects = faces.Select(face => face.FaceRectangle);
                    _faceRectangles = faceRects.ToArray();
                    // Forces a redraw on the canvas control
                    CustomCanvas.Invalidate();
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
            }
        }