예제 #1
0
        async Task ChooseImage(FaceSelectionCollectionViewController selectionController)
        {
            try
            {
                var image = await this.ShowImageSelectionDialog();

                if (image != null)
                {
                    //make sure the image is in the .Up position
                    image.FixOrientation();

                    this.ShowHUD("Detecting faces");

                    var detectedFaces = await FaceClient.Shared.DetectFacesInPhoto(image);

                    if (detectedFaces.Count == 0)
                    {
                        this.ShowSimpleHUD("No faces detected");
                    }
                    else
                    {
                        selectionController.SetDetectedFaces(image, detectedFaces);

                        this.HideHUD();
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex);
                this.HideHUD().ShowSimpleAlert("Error using image selected");
            }
        }
예제 #2
0
        async Task ChooseImage(FaceSelectionCollectionViewController selectionController)
        {
            try
            {
                var image = await this.ShowImageSelectionDialog();

                if (image != null)
                {
                    //make sure the image is in the .Up position
                    image.FixOrientation();

                    this.ShowHUD("Detecting faces");

                    var detectedFaces = await FaceClient.Shared.DetectFacesInPhoto(image);

                    if (detectedFaces.Count == 0)
                    {
                        this.ShowSimpleHUD("No faces detected");
                    }
                    else
                    {
                        if (selectionController == Face1SelectionController)
                        {
                            selectionController.AppendDetectedFaces(image, detectedFaces);
                            TotalFacesLabel.Text = $"Total faces: {selectionController.Faces.Count}";
                        }
                        else                         //Face2SelectionController
                        {
                            selectionController.SetDetectedFaces(image, detectedFaces);
                        }

                        this.HideHUD();
                    }

                    checkInputs();
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex);
                this.HideHUD().ShowSimpleAlert("Error using image selected");
            }
        }