Exemplo n.º 1
0
        private async void ConfirmButton_Click(object sender, RoutedEventArgs e)
        {
            if (LiveFeedPanel.Visibility == Visibility.Visible)
            {
                StorageFile file = await webcam.CapturePhoto();

                if (null != file)
                {
                    await PersonFaceCmds.updateToBlob(file);
                }

                personFaceProgressRing.IsActive         = false;
                appbarFaceRefreshButton.IsEnabled       = true;
                appbarFaceAddFromCameraButton.IsEnabled = true;
                appbarFaceAddFromFileButton.IsEnabled   = true;
            }
            else
            {
                if (null != photoFile)
                {
                    await PersonFaceCmds.updateToBlob(photoFile);
                }

                personFaceProgressRing.IsActive = false;
                //appbarDeleteFaceButton.IsEnabled = true;
                appbarFaceRefreshButton.IsEnabled       = true;
                appbarFaceAddFromCameraButton.IsEnabled = true;
                appbarFaceAddFromFileButton.IsEnabled   = true;
            }
            AppBarButtonPersonFaceRefresh_Click(null, null);
            appBarTrainButton_Click(null, null);
        }
Exemplo n.º 2
0
        private async void AppBarButtonPersonFaceRefresh_Click(object sender, RoutedEventArgs e)
        {
            List <ImageChannel> imageChannel = new List <ImageChannel>();

            textBlockFace.Text = "Face - " + globals.gPersonSelected.name;

            if (null != globals.gPersonSelected && globals.gPersonSelected.name.Equals("...") == false)
            {
                appbarFaceRefreshButton.IsEnabled = false;
                personFaceProgressRing.IsActive   = true;

                appbarFaceAddFromCameraButton.IsEnabled = false;
                appbarFaceAddFromFileButton.IsEnabled   = false;
                //appbarDeleteFaceButton.IsEnabled = false;

                //blob
                CloudBlobDirectory    userface = HttpHandler.blobContainer.GetDirectoryReference(globals.gPersonGroupSelected.personGroupId + "/" + globals.gPersonSelected.personId);
                BlobContinuationToken token    = null;
                idImageMaxWidth = personFaceListView.ActualHeight / 4 - 10;
                var blobcount = 0;
                do
                {
                    BlobResultSegment resultSegment = await userface.ListBlobsSegmentedAsync(token);

                    token = resultSegment.ContinuationToken;

                    foreach (IListBlobItem item in resultSegment.Results)
                    {
                        if (item.GetType() == typeof(CloudBlockBlob))
                        {
                            blobcount++;
                        }
                    }
                } while (token != null);
                userIDImages = new Image[blobcount];
                var num = 0;
                do
                {
                    BlobResultSegment resultSegment = await userface.ListBlobsSegmentedAsync(token);

                    token = resultSegment.ContinuationToken;

                    foreach (IListBlobItem item in resultSegment.Results)
                    {
                        if (item.GetType() == typeof(CloudBlockBlob))
                        {
                            CloudBlockBlob blob = (CloudBlockBlob)item;
                            var            sas1 = blob.GetSharedAccessSignature(new SharedAccessBlobPolicy()
                            {
                                Permissions            = SharedAccessBlobPermissions.Read,
                                SharedAccessExpiryTime = DateTime.UtcNow.AddHours(1),//Set this date/time according to your requirements
                            });
                            var         imageuri       = string.Format("{0}{1}", blob.Uri, sas1);
                            string      bloburi        = new Uri(imageuri).ToString();
                            BitmapImage idImage        = new BitmapImage(new Uri(bloburi));
                            Image       idImageControl = new Image();
                            idImageControl.Source    = idImage;
                            idImageControl.MaxHeight = idImageMaxWidth;
                            userIDImages[num++]      = idImageControl;
                        }
                    }
                } while (token != null);
                personFaceListView.ItemsSource = userIDImages;


                imageChannel.Clear();
                foreach (string persistedFaceId in globals.gPersonSelected.persistedFaceIds)
                {
                    FaceData faceInfo = await PersonFaceCmds.GetPersonFace(globals.gPersonGroupSelected.personGroupId,
                                                                           globals.gPersonSelected.personId,
                                                                           persistedFaceId);

                    if (null != faceInfo)
                    {
                        imageChannel.Add(new ImageChannel()
                        {
                            ImagePath       = faceInfo.userData,
                            PersistedFaceId = persistedFaceId,
                            FaceInfo        = faceInfo
                        });
                    }
                }
                //personFaceListView.ItemsSource = imageChannel;

                personFaceProgressRing.IsActive         = false;
                appbarFaceAddFromCameraButton.IsEnabled = true;
                appbarFaceAddFromFileButton.IsEnabled   = true;
                appbarFaceRefreshButton.IsEnabled       = true;
            }
            else
            {
                MessageDialog dialog = new MessageDialog("Person to be selected to find associated Faces", "Refresh Error");
                await dialog.ShowAsync();
            }
        }